Skip to content

Commit

Permalink
fix: deployment errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sama-004 committed Sep 16, 2024
1 parent 85bd0f2 commit a6e1eb1
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 109 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ NEXTAUTH_SECRET="YOUR_NEXTAUTH_SECRET"

DATABASE_URL="YOUR_DB_URL_WITH_PASSWORD"

NEXT_PUBLIC_API_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:3000
BASE_URL=http://localhost:3000
Binary file modified bun.lockb
Binary file not shown.
102 changes: 0 additions & 102 deletions lib/cacheService.ts

This file was deleted.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"name": "lc-leaderboard",
"version": "0.1.0",
"private": true,
"prisma": {
"schema": "db/prisma/schema.prisma"
},
"scripts": {
"dev": "next dev",
"build": "next build",
"vercel-build": "npx prisma generate && next build",
"start": "next start",
"lint": "next lint"
},
Expand Down
9 changes: 7 additions & 2 deletions src/app/(inside-sidebar)/room/[...roomId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import axios from 'axios';
import { getServerSession } from 'next-auth';
import { authOptions } from '../../../../../lib/auth';
import RoomPageClient from './room-id-client';
import { redirect } from 'next/navigation';

async function getRoomDetails(roomId: string) {
try {
Expand All @@ -19,7 +20,7 @@ async function getRoomDetails(roomId: string) {
},
};
const response = await axios.get(
`http://localhost:3000/api/room/${roomId}`,
`${process.env.BASE_URL}/api/room/${roomId}`,
config,
);
return response.data;
Expand All @@ -42,7 +43,7 @@ async function getNotifications(roomId: string) {
},
};
const response = await axios.get(
`http://localhost:3000/api/room/${roomId}/notifications`,
`${process.env.BASE_URL}/api/room/${roomId}/notifications`,
config,
);

Expand Down Expand Up @@ -77,6 +78,10 @@ type Props = {

export default async function Page({ params }: Props) {
const room = await getRoomDetails(params.roomId);
const session = await getServerSession(authOptions);
if (!session) {
redirect('/');
}
const notifications = await getNotifications(params.roomId);
if (!room) {
return <div>Room not found</div>;
Expand Down
1 change: 1 addition & 0 deletions src/app/api/room/[roomId]/leave/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { getServerSession } from 'next-auth';
import { authOptions } from '../../../../../../lib/auth';
import prisma from '../../../../../../db/db';
Expand Down
1 change: 1 addition & 0 deletions src/app/api/room/[roomId]/notifications/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import prisma from '../../../../../../db/db';
import { NextResponse } from 'next/server';

Expand Down
3 changes: 2 additions & 1 deletion src/app/api/room/[roomId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { NextResponse } from 'next/server';
import { authOptions } from '../../../../../lib/auth';
import { getServerSession } from 'next-auth';
Expand Down Expand Up @@ -46,7 +47,7 @@ export async function GET(
return NextResponse.json({ error: 'Room not found' }, { status: 404 });
}
const isParticipant = room.participants.some(
(p) => p.user.id === session.user.id,
(p: { user: { id: string } }) => p.user.id === session.user.id,
);
if (!isParticipant && room.creator.id !== session.user.id) {
return NextResponse.json(
Expand Down
1 change: 1 addition & 0 deletions src/app/api/room/create/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { NextResponse } from 'next/server';
import prisma from '../../../../../db/db';
import { getServerSession } from 'next-auth';
Expand Down
1 change: 1 addition & 0 deletions src/app/api/room/invite/[invitecode]/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { getServerSession } from 'next-auth';
import { authOptions } from '../../../../../../lib/auth';
import { NextResponse } from 'next/server';
Expand Down
1 change: 1 addition & 0 deletions src/app/api/room/join/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { NextResponse } from 'next/server';
import { authOptions } from '../../../../../lib/auth';
import { getServerSession } from 'next-auth';
Expand Down
1 change: 1 addition & 0 deletions src/app/api/room/joined/route.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const dynamic = 'force-dynamic';
4 changes: 4 additions & 0 deletions src/app/api/room/joined/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// @ts-nocheck
import { getServerSession } from 'next-auth';
import { authOptions } from '../../../../../lib/auth';
import { NextResponse } from 'next/server';
import prisma from '../../../../../db/db';
import { dynamic } from './route.config';

export { dynamic };

export async function GET() {
try {
Expand Down
1 change: 1 addition & 0 deletions src/app/api/verify/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import axios from 'axios';
import prisma from '../../../../db/db';
import { NextResponse } from 'next/server';
Expand Down
2 changes: 1 addition & 1 deletion src/app/invite/[...invitecode]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function Page({ params }: { params: { invitecode: string } }) {

useEffect(() => {
joinRoom();
}, []);
});

const joinRoom = async () => {
try {
Expand Down
9 changes: 8 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { technologies } from '@/components/technologies';
import { TechnologyLogo } from '@/components/technology-logo';
import Link from 'next/link';
import StaronGithub from '@/components/star_on_github';
import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';

export const metadata: Metadata = {
title: 'LeetCode Friends Leaderboard',
Expand All @@ -13,6 +15,11 @@ export const metadata: Metadata = {
};

export default async function Page() {
const session = await getServerSession();

if (session) {
redirect('/verify');
}
return (
<div className="min-h-screen bg-zinc-900 text-zinc-100">
{/* Header */}
Expand All @@ -28,7 +35,7 @@ export default async function Page() {
</h2>
<p className="text-xl mb-8 text-zinc-300 max-w-2xl mx-auto">
Join Lc Friends Leaderboard to compare your LeetCode stats, create
private rooms, and stay updated on your friends' coding achievements.
private rooms, and stay updated on your friends coding achievements.
Motivate each other to improve and climb the rankings together!
</p>
<div className="flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-4">
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export default withAuth(
);

export const config = {
matcher: ['/verify', '/rooms/', '/room/:path*'],
matcher: ['/verify', '/rooms/', '/rooms/new', '/room/:path*'],
};

0 comments on commit a6e1eb1

Please sign in to comment.