server.js 821 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'
Soo Hyun Kim's avatar
Soo Hyun Kim committed
5
import chatRouter from './routes/chat.routers.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)
Soo Hyun Kim's avatar
Soo Hyun Kim committed
18
app.use(chatRouter)
우지원's avatar
우지원 committed
19
//userRouter로 이동
Choi Ga Young's avatar
Choi Ga Young committed
20

Soo Hyun Kim's avatar
Soo Hyun Kim committed
21
22
23
24
25
26
27
// app.post('/makeChat', (req, res) => { 
//     app.use(chatRouter)
// })

// app.get('/', (req, res) => {
//     res.send('Hello World. 안녕하세요')
// })
Choi Ga Young's avatar
Choi Ga Young committed
28

우지원's avatar
우지원 committed
29
30
app.listen(3030, () => {
    console.log('Listening on port 3030')
31
})