-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (32 loc) · 1020 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* TODO:
* - MVC 패턴으로 만들기 (중요)
* - 기본적인 로그인 구현하기
* - 유저 모델 만들기
* - 확장성 있게 제작하기
* - JSDoc 이용하기
*/
require('dotenv').config()
const express = require('express');
const app = express();
const logger = require('./modules/logger')
const router = require('./router/index')
const sendRule = require('./modules/send-rule')
const passportJwtAuth = require('./modules/passport-jwt-auth')()
const mongo = require('./modules/mongo-connect').getDB()
const cors = require("cors")
const history = require('connect-history-api-fallback');
app.use(cors())
app.use(history());
app.listen(process.env.PORT || 80, () => {
logger.logc("SERVER OPEN")
})
app.use(express.static('public'))
app.use(express.urlencoded());
app.use(express.json())
app.use(passportJwtAuth.initialize())
app.use(router)
// Error handling
app.use(sendRule.errorHendling()) // 400~500
app.use((req, res, next) => {
sendRule.sendNotFound(res, null)
}) // Page Not Found