From 06b4bfc0e23ea2a3ff057876d1b84ebf0ceaa165 Mon Sep 17 00:00:00 2001 From: Niko Korvenlaita Date: Wed, 6 Apr 2022 23:30:36 +0300 Subject: [PATCH] basic setup untill auth --- .env.sample | 4 + .eslintrc | 3 + .node-version | 1 + .nvmrc | 1 + app/custom-types.d.ts | 11 + app/entry.client.tsx | 4 + app/entry.server.tsx | 22 + app/root.tsx | 77 + app/routes/__auth/auth.css | 14 + app/routes/__auth/signin.tsx | 38 + app/routes/index.tsx | 6 + app/supabase.client.ts | 37 + app/supabase.server.ts | 25 + package-lock.json | 19790 +++++++++++++++++++++++++++++++++ package.json | 44 + public/_headers | 2 + public/favicon.ico | Bin 0 -> 16958 bytes remix.config.js | 26 + remix.env.d.ts | 3 + server.js | 12 + supabase/config.toml.sample | 65 + tsconfig.json | 20 + 22 files changed, 20205 insertions(+) create mode 100644 .env.sample create mode 100644 .eslintrc create mode 100644 .node-version create mode 120000 .nvmrc create mode 100644 app/custom-types.d.ts create mode 100644 app/entry.client.tsx create mode 100644 app/entry.server.tsx create mode 100644 app/root.tsx create mode 100644 app/routes/__auth/auth.css create mode 100644 app/routes/__auth/signin.tsx create mode 100644 app/routes/index.tsx create mode 100644 app/supabase.client.ts create mode 100644 app/supabase.server.ts create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 public/_headers create mode 100644 public/favicon.ico create mode 100644 remix.config.js create mode 100644 remix.env.d.ts create mode 100644 server.js create mode 100644 supabase/config.toml.sample create mode 100644 tsconfig.json diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..d15f01a --- /dev/null +++ b/.env.sample @@ -0,0 +1,4 @@ +SUPABASE_SERVICE_KEY= +PUBLIC_SUPABASE_ANON_KEY= +SUPABASE_URL=http://localhost:54321 +SERVER_URL=http://localhost:8788 \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..8828ca3 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["@remix-run/eslint-config"] +} diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..d77ff0e --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +16.7.0 \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 120000 index 0000000..070266a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +.node-version \ No newline at end of file diff --git a/app/custom-types.d.ts b/app/custom-types.d.ts new file mode 100644 index 0000000..861f763 --- /dev/null +++ b/app/custom-types.d.ts @@ -0,0 +1,11 @@ +import '@remix-run/cloudflare' + +// these map with the fields in .env +declare module '@remix-run/cloudflare' { + interface AppLoadContext { + SERVER_URL: string; + SUPABASE_URL: string; + SUPABASE_SERVICE_KEY: string; + PUBLIC_SUPABASE_ANON_KEY: string; + } +} \ No newline at end of file diff --git a/app/entry.client.tsx b/app/entry.client.tsx new file mode 100644 index 0000000..3eec1fd --- /dev/null +++ b/app/entry.client.tsx @@ -0,0 +1,4 @@ +import { RemixBrowser } from "@remix-run/react"; +import { hydrate } from "react-dom"; + +hydrate(, document); diff --git a/app/entry.server.tsx b/app/entry.server.tsx new file mode 100644 index 0000000..14f26e2 --- /dev/null +++ b/app/entry.server.tsx @@ -0,0 +1,22 @@ +import type { EntryContext } from "@remix-run/cloudflare"; +import { RemixServer } from "@remix-run/react"; +import { renderToString } from "react-dom/server"; +import { injectStylesIntoStaticMarkup } from '@mantine/ssr'; + +export default function handleRequest( + request: Request, + responseStatusCode: number, + responseHeaders: Headers, + remixContext: EntryContext +) { + let markup = renderToString( + + ); + + responseHeaders.set("Content-Type", "text/html"); + + return new Response(`${injectStylesIntoStaticMarkup(markup)}`, { + status: responseStatusCode, + headers: responseHeaders, + }); +} diff --git a/app/root.tsx b/app/root.tsx new file mode 100644 index 0000000..7bbbb2f --- /dev/null +++ b/app/root.tsx @@ -0,0 +1,77 @@ +import type { LoaderFunction, MetaFunction } from "@remix-run/cloudflare"; +import { + Links, + LiveReload, + Meta, + Outlet, + Scripts, + ScrollRestoration, + useCatch, + useLoaderData, +} from "@remix-run/react"; + +export const meta: MetaFunction = () => ({ + charset: "utf-8", + title: "New Remix App", + viewport: "width=device-width,initial-scale=1", +}); + +export const loader: LoaderFunction = ({ context }) => { + if (!context.SUPABASE_URL) + throw new Error('SUPABASE_URL is required') + + if (!context.PUBLIC_SUPABASE_ANON_KEY) + throw new Error('PUBLIC_SUPABASE_ANON_KEY is required') + + return { + env: { + SUPABASE_URL: context.SUPABASE_URL, + PUBLIC_SUPABASE_ANON_KEY: context.PUBLIC_SUPABASE_ANON_KEY, + }, + } +} + +export default function App() { + const { env } = useLoaderData(); + + return ( + + + + + + + + +