-
-
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
6545b1c
commit 7968016
Showing
5 changed files
with
130 additions
and
130 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,41 +1,41 @@ | ||
import connectMongoDB from "@utilities/mongodb"; | ||
import About from "@models/about"; | ||
import { Params } from "next/dist/shared/lib/router/utils/route-matcher"; | ||
import { NextResponse } from "next/server"; | ||
// import connectMongoDB from "@utilities/mongodb"; | ||
// import About from "@models/about"; | ||
// 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, | ||
name: name, | ||
nickname: nickname, | ||
age: age, | ||
birthday: birthday, | ||
sex: sex, | ||
nationality: nationality, | ||
status: status, | ||
languages: languages | ||
} = await request.json(); | ||
await connectMongoDB(); | ||
await About.findByIdAndUpdate(id, { | ||
title, | ||
desc, | ||
name, | ||
nickname, | ||
age, | ||
birthday, | ||
sex, | ||
nationality, | ||
status, | ||
languages | ||
}); | ||
return NextResponse.json({ message: "Updated" }, { status: 200 }); | ||
} | ||
// export async function PUT(request: Request, { params }: Params) { | ||
// const { id } = params; | ||
// const { | ||
// title: title, | ||
// desc: desc, | ||
// name: name, | ||
// nickname: nickname, | ||
// age: age, | ||
// birthday: birthday, | ||
// sex: sex, | ||
// nationality: nationality, | ||
// status: status, | ||
// languages: languages | ||
// } = await request.json(); | ||
// await connectMongoDB(); | ||
// await About.findByIdAndUpdate(id, { | ||
// title, | ||
// desc, | ||
// name, | ||
// nickname, | ||
// age, | ||
// birthday, | ||
// sex, | ||
// nationality, | ||
// status, | ||
// languages | ||
// }); | ||
// return NextResponse.json({ message: "Updated" }, { status: 200 }); | ||
// } | ||
|
||
export async function GET(request: Request, { params }: Params ) { | ||
const { id } = params; | ||
await connectMongoDB(); | ||
const about = await About.findOne({ _id: id }); | ||
return NextResponse.json({ about }, { status: 200 }); | ||
}; | ||
// export async function GET(request: Request, { params }: Params ) { | ||
// const { id } = params; | ||
// await connectMongoDB(); | ||
// const about = await About.findOne({ _id: id }); | ||
// return NextResponse.json({ about }, { 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,37 +1,37 @@ | ||
import connectMongoDB from "@utilities/mongodb"; | ||
import About from "@models/about"; | ||
import { NextResponse } from "next/server"; | ||
// import connectMongoDB from "@utilities/mongodb"; | ||
// import About from "@models/about"; | ||
// import { NextResponse } from "next/server"; | ||
|
||
export async function POST(request: Request, response: Response) { | ||
const { | ||
title, | ||
desc, | ||
name, | ||
nickname, | ||
age, | ||
birthday, | ||
sex, | ||
nationality, | ||
status, | ||
languages | ||
} = await request.json(); | ||
await connectMongoDB(); | ||
await About.create({ | ||
title, | ||
desc, | ||
name, | ||
nickname, | ||
age, | ||
birthday, | ||
sex, | ||
nationality, | ||
status, | ||
languages | ||
}); | ||
}; | ||
// export async function POST(request: Request, response: Response) { | ||
// const { | ||
// title, | ||
// desc, | ||
// name, | ||
// nickname, | ||
// age, | ||
// birthday, | ||
// sex, | ||
// nationality, | ||
// status, | ||
// languages | ||
// } = await request.json(); | ||
// await connectMongoDB(); | ||
// await About.create({ | ||
// title, | ||
// desc, | ||
// name, | ||
// nickname, | ||
// age, | ||
// birthday, | ||
// sex, | ||
// nationality, | ||
// status, | ||
// languages | ||
// }); | ||
// }; | ||
|
||
export async function GET() { | ||
await connectMongoDB(); | ||
const about = await About.find(); | ||
return NextResponse.json({ about }) | ||
}; | ||
// export async function GET() { | ||
// await connectMongoDB(); | ||
// const about = await About.find(); | ||
// return NextResponse.json({ about }) | ||
// }; |
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 }) | ||
// }; |
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,11 +1,11 @@ | ||
import mongoose from "mongoose"; | ||
// import mongoose from "mongoose"; | ||
|
||
const connectMongoDB = async () => { | ||
try { | ||
await mongoose.connect(process.env.MONGODB_URI as string); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
// const connectMongoDB = async () => { | ||
// try { | ||
// await mongoose.connect(process.env.MONGODB_URI as string); | ||
// } catch (error) { | ||
// console.log(error); | ||
// } | ||
// }; | ||
|
||
export default connectMongoDB; | ||
// export default connectMongoDB; |