-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
43 lines (35 loc) · 1.06 KB
/
server.js
File metadata and controls
43 lines (35 loc) · 1.06 KB
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
41
42
43
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
const router = express.Router();
const http = require('http');
const config = require('./config/index');
const server = http.createServer(app);
app.use(session({
secret: config.sessionSecret,
resave: false,
saveUninitialized: true
}));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, UPDATE, DELETE, OPTIONS')
next();
});
require('./routes/api')(router);
app.use(bodyParser.urlencoded({
extended: true,
type: 'application/x-www-form-urlencoded',
json: {limit: '50mb'},
urlencoded: {limit: '50mb'}
}));
app.use(bodyParser.json());
app.use('/', router);
/**
* Server Setting
**/
server.listen(config.port, function () {
console.log("Server listening at PORT:" + config.port);
});
module.exports = server;