server.js 666 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'
Choi Ga Young's avatar
Choi Ga Young committed
5

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

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

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

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

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

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