-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
40 lines (31 loc) · 932 Bytes
/
server.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
38
39
40
'use strict';
// 모듈 선언
const _express = require('express');
const _app = _express();
const _bodyParser = require('body-parser');
const _cors = require('cors');
const { sequelize } = require('./src/utils/connect');
const _config = require('config');
const _morgan = require('morgan');
const logger = require('./src/functions/winston');
// 웹세팅
_app.use(_bodyParser.json());
_app.use(_bodyParser.urlencoded({ extended: true }));
_app.use(_cors());
_app.use(_morgan('common', { stream: logger.stream }));
// 라우팅
const api_router = require('./src/routes');
_app.use('/', api_router);
// 서버 연결
_app.listen(_config.get('server.port'), () => {
logger.info(`Server Running on ${_config.get('server.port')} Port!`);
});
// DB 연결
sequelize
.sync({ force: false })
.then(() => {
logger.info('Success Connecting DB!');
})
.catch((err) => {
console.error(err);
});