-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from CodeChefVIT/staging
Staging
- Loading branch information
Showing
5 changed files
with
98 additions
and
35 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,20 @@ | ||
import { NextResponse } from "next/server"; | ||
import { connectToDatabase } from "@/lib/mongoose"; | ||
import { Course } from "@/db/papers"; | ||
|
||
export const dynamic = "force-dynamic"; | ||
|
||
export async function GET() { | ||
try { | ||
await connectToDatabase(); | ||
const courses = await Course.find().lean(); | ||
|
||
return NextResponse.json(courses, { status: 200 }); | ||
} catch (error) { | ||
console.error(error); | ||
return NextResponse.json( | ||
{ message: "Failed to fetch courses", error }, | ||
{ status: 500 } | ||
); | ||
} | ||
} |
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
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
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
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