-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
20,205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SUPABASE_SERVICE_KEY=<read from supabase start> | ||
PUBLIC_SUPABASE_ANON_KEY=<read from supabase start> | ||
SUPABASE_URL=http://localhost:54321 | ||
SERVER_URL=http://localhost:8788 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@remix-run/eslint-config"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.node-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { RemixBrowser } from "@remix-run/react"; | ||
import { hydrate } from "react-dom"; | ||
|
||
hydrate(<RemixBrowser />, document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
<RemixServer context={remixContext} url={request.url} /> | ||
); | ||
|
||
responseHeaders.set("Content-Type", "text/html"); | ||
|
||
return new Response(`<!DOCTYPE html>${injectStylesIntoStaticMarkup(markup)}`, { | ||
status: responseStatusCode, | ||
headers: responseHeaders, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Window>(); | ||
|
||
return ( | ||
<html lang="en"> | ||
<head> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Outlet /> | ||
<ScrollRestoration /> | ||
<script | ||
dangerouslySetInnerHTML={{ | ||
__html: `window.env = ${JSON.stringify( | ||
env, | ||
)}`, | ||
}} | ||
/> | ||
<Scripts /> | ||
<LiveReload /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
export function CatchBoundary() { | ||
const caught = useCatch(); | ||
return ( | ||
<html> | ||
<head> | ||
<title>Oops!</title> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<h1> | ||
{caught.status} {caught.statusText} | ||
</h1> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
body { | ||
background-color: #181818; | ||
min-height: 100%; | ||
overflow: auto; | ||
} | ||
|
||
.auth-box { | ||
max-width: 25em; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
-ms-transform: translate(-50%, -50%); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useState, useEffect } from "react"; | ||
import { Auth } from "@supabase/ui"; | ||
import { supabase } from "~/supabase.client"; | ||
import styles from "~/routes/__auth/auth.css" | ||
|
||
export const links = () => { | ||
// using tailwind only in signin with supabase | ||
return [ | ||
{ | ||
rel: "stylesheet", | ||
href: "https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css", | ||
}, | ||
{ | ||
rel: "stylesheet", | ||
href: styles | ||
} | ||
]; | ||
}; | ||
|
||
const Index = () => { | ||
const [isClient, setIsclient] = useState(false); | ||
useEffect(() => setIsclient(true), []); | ||
|
||
if (isClient) { | ||
return ( | ||
<Auth | ||
className="dark auth-box" | ||
providers={["google"]} | ||
supabaseClient={supabase()} | ||
magicLink={true} | ||
view={"magic_link"} | ||
/> | ||
); | ||
} | ||
return ""; | ||
}; | ||
|
||
export default Index; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
const Index = () => { | ||
return <h1>Hello</h1> | ||
} | ||
|
||
export default Index; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createClient } from '@supabase/supabase-js' | ||
export { SupabaseClient } from '@supabase/supabase-js' | ||
|
||
declare global { | ||
interface Window { | ||
env: { | ||
SUPABASE_URL: string | ||
PUBLIC_SUPABASE_ANON_KEY: string | ||
} | ||
} | ||
} | ||
|
||
export const supabase = () => { | ||
if (!window.env.SUPABASE_URL) | ||
throw new Error('SUPABASE_URL is required') | ||
|
||
if (!window.env.PUBLIC_SUPABASE_ANON_KEY) | ||
throw new Error('PUBLIC_SUPABASE_ANON_KEY is required') | ||
|
||
// Supabase options example (build your own :)) | ||
// https://supabase.com/docs/reference/javascript/initializing#with-additional-parameters | ||
|
||
const supabaseOptions = { | ||
fetch: fetch.bind(globalThis), // see ⚠️ cloudflare | ||
schema: "public", | ||
persistSession: false, | ||
autoRefreshToken: true, | ||
detectSessionInUrl: true | ||
}; | ||
// ⚠️ cloudflare needs you define fetch option : https://github.com/supabase/supabase-js#custom-fetch-implementation | ||
// Use Remix fetch polyfill for node (See https://remix.run/docs/en/v1/other-api/node) | ||
return createClient( | ||
window.env.SUPABASE_URL, | ||
window.env.PUBLIC_SUPABASE_ANON_KEY, | ||
supabaseOptions | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createClient } from '@supabase/supabase-js' | ||
import type { ApiError, Session } from '@supabase/supabase-js' | ||
import { AppLoadContext } from '@remix-run/cloudflare' | ||
|
||
export const supabaseAdmin = (context: AppLoadContext) => { | ||
if (!context.SUPABASE_URL) | ||
throw new Error('ENV: SUPABASE_URL is required') | ||
|
||
if (!context.SUPABASE_SERVICE_KEY) | ||
throw new Error('ENV: SUPABASE_SERVICE_KEY is required') | ||
|
||
const supabaseOptions = { | ||
fetch: fetch.bind(globalThis), // see ⚠️ cloudflare | ||
schema: "public", | ||
autoRefreshToken: true, | ||
}; | ||
|
||
createClient( | ||
context.SUPABASE_URL, | ||
context.SUPABASE_SERVICE_KEY, | ||
supabaseOptions | ||
) | ||
} | ||
|
||
export { Session, ApiError } |
Oops, something went wrong.