Skip to content

Commit

Permalink
Removed restaurant index page and add config file instaed of env
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed Mar 8, 2024
1 parent 80d7023 commit 4bbcc6a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 294 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
- name: Build
run: |
cd website
sed -i "s|SUPABASE_URL|${{ secrets.SUPABASE_URL }}|g" config.js
sed -i "s|SUPABASE_ANON_KEY|${{ secrets.SUPABASE_ANON_KEY }}|g" config.js
npm run build
- name: Configure AWS Credentials
Expand All @@ -43,4 +45,4 @@ jobs:
- name: Deploy to S3
run: |
cd website
aws s3 sync ./out s3://${{ secrets.WEBSITE_BUCKET_NAME }}
aws s3 sync ./out s3://${{ secrets.WEBSITE_BUCKET_NAME }}
255 changes: 0 additions & 255 deletions website/app/restaurants/[restaurant]/page.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions website/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default Object.freeze({
SUPABASE_URL: SUPABASE_URL,
SUPABASE_ANON_KEY: SUPABASE_ANON_KEY,
});
6 changes: 2 additions & 4 deletions website/utils/supabase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { createClient } from "@supabase/supabase-js";
import config from "@/config";

export default createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
export default createClient(config.SUPABASE_URL, config.SUPABASE_ANON_KEY);
6 changes: 2 additions & 4 deletions website/utils/supabase/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { createBrowserClient } from "@supabase/ssr";
import config from "@/config";

export const createClient = () =>
createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
);
createBrowserClient(config.SUPABASE_URL, config.SUPABASE_ANON_KEY);
7 changes: 4 additions & 3 deletions website/utils/supabase/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { type NextRequest, NextResponse } from "next/server";
import config from "@/config";

export const createClient = (request: NextRequest) => {
// Create an unmodified response
Expand All @@ -10,8 +11,8 @@ export const createClient = (request: NextRequest) => {
});

const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
config.SUPABASE_URL,
config.SUPABASE_ANON_KEY,
{
cookies: {
get(name: string) {
Expand Down Expand Up @@ -54,7 +55,7 @@ export const createClient = (request: NextRequest) => {
});
},
},
},
}
);

return { supabase, response };
Expand Down
51 changes: 24 additions & 27 deletions website/utils/supabase/server.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { cookies } from "next/headers";
import config from "@/config";

export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
get(name: string) {
return cookieStore.get(name)?.value;
},
set(name: string, value: string, options: CookieOptions) {
try {
cookieStore.set({ name, value, ...options });
} catch (error) {
// The `set` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
remove(name: string, options: CookieOptions) {
try {
cookieStore.set({ name, value: "", ...options });
} catch (error) {
// The `delete` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
return createServerClient(config.SUPABASE_URL, config.SUPABASE_ANON_KEY, {
cookies: {
get(name: string) {
return cookieStore.get(name)?.value;
},
set(name: string, value: string, options: CookieOptions) {
try {
cookieStore.set({ name, value, ...options });
} catch (error) {
// The `set` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
remove(name: string, options: CookieOptions) {
try {
cookieStore.set({ name, value: "", ...options });
} catch (error) {
// The `delete` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
);
});
};

0 comments on commit 4bbcc6a

Please sign in to comment.