+
+
Continue with
+
+
+
+
+
OR
+
+
+
-
-
-
-
+ );
}
-
diff --git a/app/routes/test.tsx b/app/routes/test.tsx
index 9ed15dc..6602029 100644
--- a/app/routes/test.tsx
+++ b/app/routes/test.tsx
@@ -1,44 +1,49 @@
-
import { useLoaderData, useOutletContext } from "@remix-run/react";
-import { createServerClient, parse, serialize } from '@supabase/ssr';
-
+import { createServerClient, parse, serialize } from "@supabase/ssr";
-import type { Database } from '../../database.types'
-import type { SupabaseClient } from '@supabase/supabase-js'
-import type { LoaderFunctionArgs } from "@remix-run/node"
+import type { Database } from "../../database.types";
+import type { SupabaseClient } from "@supabase/supabase-js";
+import type { LoaderFunctionArgs } from "@remix-run/node";
import { useEffect } from "react";
export const loader = async ({ request }: LoaderFunctionArgs) => {
- const cookies = parse(request.headers.get('Cookie') ?? '')
- const headers = new Headers()
-
- const supabase = createServerClient(process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY!, {
- cookies: {
- get(key) {
- return cookies[key]
- },
- set(key, value, options) {
- headers.append('Set-Cookie', serialize(key, value, options))
+ const cookies = parse(request.headers.get("Cookie") ?? "");
+ const headers = new Headers();
+
+ const supabase = createServerClient(
+ process.env.SUPABASE_URL!,
+ process.env.SUPABASE_ANON_KEY!,
+ {
+ cookies: {
+ get(key) {
+ return cookies[key];
+ },
+ set(key, value, options) {
+ headers.append(
+ "Set-Cookie",
+ serialize(key, value, options),
+ );
+ },
+ remove(key, options) {
+ headers.append("Set-Cookie", serialize(key, "", options));
+ },
+ },
},
- remove(key, options) {
- headers.append('Set-Cookie', serialize(key, '', options))
- },
- },
- })
+ );
// const data = await supabase.from('profiles').select()
- const { // if user !== null then is authenticated
+ const {
+ // if user !== null then is authenticated
data: { user: data },
- } = await supabase.auth.getUser()
-
- return new Response(JSON.stringify(data), {headers})
-
-}
-
+ } = await supabase.auth.getUser();
-export default function Test(){
+ return new Response(JSON.stringify(data), { headers });
+};
- const { supabase } = useOutletContext<{ supabase: SupabaseClient
}>()
+export default function Test() {
+ const { supabase } = useOutletContext<{
+ supabase: SupabaseClient;
+ }>();
////// get data from server side (in loaders and actions)
// const data = useLoaderData() as string
@@ -46,7 +51,6 @@ export default function Test(){
// console.log(JSON.parse(data))
// }, [])
-
////// get data from client side
// useEffect(() => {
// (async () => {
@@ -55,31 +59,32 @@ export default function Test(){
// })()
// }, [])
-
- function signUp(){
+ function signUp() {
supabase.auth.signUp({
email: "khanghy2130@gmail.com",
- password: "sup3rs3cur3"
- })
+ password: "sup3rs3cur3",
+ });
}
- function logIn(){
+ function logIn() {
supabase.auth.signInWithPassword({
email: "khanghy2130@gmail.com",
- password: "sup3rs3cur3"
- })
+ password: "sup3rs3cur3",
+ });
}
- async function signOut(){
- const { error } = await supabase.auth.signOut()
- if (error){
- console.log(error)
- }
+ async function signOut() {
+ const { error } = await supabase.auth.signOut();
+ if (error) {
+ console.log(error);
+ }
}
- return
-
-
-
-
-}
\ No newline at end of file
+ return (
+
+
+
+
+
+ );
+}
diff --git a/package.json b/package.json
index 801169c..c3058d8 100644
--- a/package.json
+++ b/package.json
@@ -33,6 +33,8 @@
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"jsdom": "^23.0.1",
+ "prettier": "^3.2.5",
+ "prettier-plugin-tailwindcss": "^0.5.12",
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3",
"vitest": "^1.1.0"
diff --git a/yarn.lock b/yarn.lock
index 67946a5..bedf993 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5782,11 +5782,21 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
+prettier-plugin-tailwindcss@^0.5.12:
+ version "0.5.12"
+ resolved "https://registry.yarnpkg.com/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.5.12.tgz#655999849344548ecf4d9b47a051ed856f041c72"
+ integrity sha512-o74kiDBVE73oHW+pdkFSluHBL3cYEvru5YgEqNkBMFF7Cjv+w1vI565lTlfoJT4VLWDe0FMtZ7FkE/7a4pMXSQ==
+
prettier@^2.7.1:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
+prettier@^3.2.5:
+ version "3.2.5"
+ resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368"
+ integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==
+
pretty-format@^27.0.2:
version "27.5.1"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e"