server.js 744 Bytes
Newer Older
우지원's avatar
우지원 committed
1
2
3
import express from 'express'
import connectDb from './utils/connectDb.js'
import userRouter from './routes/user.routes.js'
4
import authRouter from './routes/auth.routes.js'
JeongYeonwoo's avatar
JeongYeonwoo committed
5
import profileRouter from './routes/profile.routes.js'
Choi Ga Young's avatar
Choi Ga Young committed
6

우지원's avatar
우지원 committed
7
connectDb()
Choi Ga Young's avatar
Choi Ga Young committed
8

우지원's avatar
우지원 committed
9
const app = express()
Choi Ga Young's avatar
Choi Ga Young committed
10

우지원's avatar
우지원 committed
11
12
13
14
app.use(express.json())
//이부분을 body 파싱함
//express가 req.body라는곳을 자동으로만들어서 json형식으로 보낸것을 객체형식으로 넣음
//이부분 다음부터는 req.body라는 부분을 실행할 수 있음
Choi Ga Young's avatar
Choi Ga Young committed
15

우지원's avatar
우지원 committed
16
app.use(userRouter)
17
app.use(authRouter)
JeongYeonwoo's avatar
JeongYeonwoo committed
18
app.use(profileRouter)
우지원's avatar
우지원 committed
19
//userRouter로 이동
Choi Ga Young's avatar
Choi Ga Young committed
20

우지원's avatar
우지원 committed
21
22
23
app.get('/', (req, res) => {
    res.send('Hello World. 안녕하세요')
})
Choi Ga Young's avatar
Choi Ga Young committed
24

우지원's avatar
우지원 committed
25
26
app.listen(3030, () => {
    console.log('Listening on port 3030')
27
})