Skip to content

Commit

Permalink
Feat: Progress Bar 구현 #33
Browse files Browse the repository at this point in the history
  • Loading branch information
shu07002 committed Sep 20, 2024
2 parents 7a5e5d8 + 9ebe22b commit 90918dc
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/api/people/getMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 0 additions & 1 deletion src/app/api/people/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
8 changes: 8 additions & 0 deletions src/app/api/project/getProjects.ts
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 11 additions & 0 deletions src/app/api/project/route.ts
Original file line number Diff line number Diff line change
@@ -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 })
}
}
4 changes: 3 additions & 1 deletion src/app/people/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<main>
<People1 />
Expand Down
Empty file removed src/client-api/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions src/client-api/api.ts
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 4 additions & 3 deletions src/models/member-schema.ts
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
14 changes: 14 additions & 0 deletions src/models/project-schema.ts
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 90918dc

Please sign in to comment.