diff --git a/src/app/api/people/getMembers.ts b/src/app/api/people/getMembers.ts index 8e91365..fb34781 100644 --- a/src/app/api/people/getMembers.ts +++ b/src/app/api/people/getMembers.ts @@ -2,7 +2,7 @@ import { connectDb } from '@/libs/connect-db' import { Member } from '@/models/member-schema' export const getMembers = async () => { - const res = await connectDb() + await connectDb() const data = await Member.find() return data } diff --git a/src/app/api/people/route.ts b/src/app/api/people/route.ts index e3e80c9..598fb35 100644 --- a/src/app/api/people/route.ts +++ b/src/app/api/people/route.ts @@ -4,7 +4,6 @@ import { getMembers } from './getMembers' export async function GET(request: NextRequest) { try { const data = await getMembers() - console.log(data) return Response.json({ data }) } catch (error) { return Response.json({ error }, { status: 500 }) diff --git a/src/app/api/project/getProjects.ts b/src/app/api/project/getProjects.ts new file mode 100644 index 0000000..3fa2e44 --- /dev/null +++ b/src/app/api/project/getProjects.ts @@ -0,0 +1,8 @@ +import { connectDb } from '@/libs/connect-db' +import { Project } from '@/models/project-schema' + +export const getProjects = async () => { + await connectDb() + const data = await Project.find() + return data +} diff --git a/src/app/api/project/route.ts b/src/app/api/project/route.ts new file mode 100644 index 0000000..a2336c5 --- /dev/null +++ b/src/app/api/project/route.ts @@ -0,0 +1,11 @@ +import { NextRequest } from 'next/server' +import { getProjects } from './getProjects' + +export async function GET(request: NextRequest) { + try { + const data = await getProjects() + return Response.json({ data }) + } catch (error) { + return Response.json({ error }, { status: 500 }) + } +} diff --git a/src/app/people/page.tsx b/src/app/people/page.tsx index 9078526..d1bf9f2 100644 --- a/src/app/people/page.tsx +++ b/src/app/people/page.tsx @@ -1,8 +1,10 @@ import React from 'react' import People1 from './container/People1' import People2 from './container/People2' +import { getAllMembers } from '@/client-api/api' -export default function PeoplePage() { +export default async function PeoplePage() { + const members = await getAllMembers() return (
diff --git a/src/client-api/.gitkeep b/src/client-api/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/client-api/api.ts b/src/client-api/api.ts new file mode 100644 index 0000000..bbfd04f --- /dev/null +++ b/src/client-api/api.ts @@ -0,0 +1,13 @@ +const API_END_POINT = `${process.env.NEXT_PUBLIC_BASE_URL}` + +export const getAllMembers = async () => { + const res = await fetch(`${API_END_POINT}/api/people`) + const { data } = await res.json() + return data +} + +export const getAllProjects = async () => { + const res = await fetch(`${API_END_POINT}/api/project`) + const { data } = await res.json() + return data +} diff --git a/src/models/member-schema.ts b/src/models/member-schema.ts index 62074cb..908ea92 100644 --- a/src/models/member-schema.ts +++ b/src/models/member-schema.ts @@ -1,9 +1,10 @@ import mongoose, { Schema } from 'mongoose' export const MemberSchema = new Schema({ - 이름: String, - 기수: String, - 포지션: String + _id: String, + name: String, + generation: String, + type: String }) export const Member = diff --git a/src/models/project-schema.ts b/src/models/project-schema.ts new file mode 100644 index 0000000..f50b7bb --- /dev/null +++ b/src/models/project-schema.ts @@ -0,0 +1,14 @@ +import mongoose, { Schema } from 'mongoose' + +export const ProjectSchema = new Schema({ + _id: String, + description: String, + github: String, + imageUrl: String, + member: String, + project: String, + team: String +}) + +export const Project = + mongoose.models.Project ?? mongoose.model('Project', ProjectSchema)