server.js 683 Bytes
Newer Older
우지원's avatar
우지원 committed
1
2
import express from 'express'
import connectDb from './utils/connectDb.js'
Soo Hyun Kim's avatar
Soo Hyun Kim committed
3
import chatRouter from './routes/chat.routers.js'
Choi Ga Young's avatar
Choi Ga Young committed
4

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

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

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

Soo Hyun Kim's avatar
Soo Hyun Kim committed
14
app.use(chatRouter)
우지원's avatar
우지원 committed
15
//userRouter로 이동
Choi Ga Young's avatar
Choi Ga Young committed
16

Soo Hyun Kim's avatar
Soo Hyun Kim committed
17
18
19
20
21
22
23
// 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
24

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