-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (26 loc) · 864 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
const express = require('express'),
helmet = require('helmet'),
bodyParser = require('body-parser'),
port = 80,
threads = 1,
compression = require('compression');
const createAppServer = () => {
const app = express();
app.use(helmet());
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
next();
});
app.use(bodyParser.json({
limit: '1mb'
}));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());
//compresses the angular bundle size further by using gzipped encoding for faster loading
app.use(compression());
require('./routes')(app);
module.exports = app;
return app;
}
const app = createAppServer();
app.listen(port, () => console.log(`service is running on port ${port} with ${process.pid} pid`));