-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
780854a
commit e5e3660
Showing
2 changed files
with
47 additions
and
47 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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
// import connectMongoDB from "@utilities/mongodb"; | ||
// import Project from "@models/project"; | ||
// import { Params } from "next/dist/shared/lib/router/utils/route-matcher"; | ||
// import { NextResponse } from "next/server"; | ||
import connectMongoDB from "@utilities/mongodb"; | ||
import Project from "@models/project"; | ||
import { Params } from "next/dist/shared/lib/router/utils/route-matcher"; | ||
import { NextResponse } from "next/server"; | ||
|
||
// export async function PUT(request: Request, { params }: Params) { | ||
// const { id } = params; | ||
// const { | ||
// title: title, | ||
// desc: desc, | ||
// href: href, | ||
// } = await request.json(); | ||
// await connectMongoDB(); | ||
// await Project.findByIdAndUpdate(id, { | ||
// title, | ||
// desc, | ||
// href, | ||
// }); | ||
// return NextResponse.json({ message: "Updated" }, { status: 200 }); | ||
// } | ||
export async function PUT(request: Request, { params }: Params) { | ||
const { id } = params; | ||
const { | ||
title: title, | ||
desc: desc, | ||
href: href, | ||
} = await request.json(); | ||
await connectMongoDB(); | ||
await Project.findByIdAndUpdate(id, { | ||
title, | ||
desc, | ||
href, | ||
}); | ||
return NextResponse.json({ message: "Updated" }, { status: 200 }); | ||
} | ||
|
||
// export async function GET(request: Request, { params }: Params ) { | ||
// const { id } = params; | ||
// await connectMongoDB(); | ||
// const projects = await Project.findOne({ _id: id }); | ||
// return NextResponse.json({ projects }, { status: 200 }); | ||
// }; | ||
export async function GET(request: Request, { params }: Params ) { | ||
const { id } = params; | ||
await connectMongoDB(); | ||
const projects = await Project.findOne({ _id: id }); | ||
return NextResponse.json({ projects }, { status: 200 }); | ||
}; |
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
// import connectMongoDB from "@utilities/mongodb"; | ||
// import Project from "@models/project"; | ||
// import { NextResponse } from "next/server"; | ||
import connectMongoDB from "@utilities/mongodb"; | ||
import Project from "@models/project"; | ||
import { NextResponse } from "next/server"; | ||
|
||
// export async function POST(request: Request, response: Response) { | ||
// const { | ||
// title, | ||
// desc, | ||
// href | ||
// } = await request.json(); | ||
// await connectMongoDB(); | ||
// await Project.create({ | ||
// title, | ||
// desc, | ||
// href | ||
// }); | ||
// return NextResponse.json({ status: 200 }); | ||
// }; | ||
export async function POST(request: Request, response: Response) { | ||
const { | ||
title, | ||
desc, | ||
href | ||
} = await request.json(); | ||
await connectMongoDB(); | ||
await Project.create({ | ||
title, | ||
desc, | ||
href | ||
}); | ||
return NextResponse.json({ status: 200 }); | ||
}; | ||
|
||
// export async function GET() { | ||
// await connectMongoDB(); | ||
// const project = await Project.find(); | ||
// return NextResponse.json({ project }) | ||
// }; | ||
export async function GET() { | ||
await connectMongoDB(); | ||
const project = await Project.find(); | ||
return NextResponse.json({ project }) | ||
}; |