-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (29 loc) · 1.16 KB
/
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
const express = require('express');
const http2 = require('spdy');
const pug = require('pug');
const compression = require('compression');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
//const favicon = require('serve-favicon');
const app = express();
const server_port = process.env.PORT || 8090;
const server_ip_address = '0.0.0.0' || '127.0.0.1';
global.swiftMod = (swiftmoModuleName)=>{
const path = require('path');
let desiredMod = path.resolve(process.env.PWD + '/swiftmo_modules/' + swiftmoModuleName);
return require(desiredMod);
};
app.use(compression());
//app.use(favicon('./favicon.ico'));
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.set('trust proxy', 1);
app.use('/frontendStatic', express.static(__dirname + '/frontend'))
require('./routers/main')(app);
app.set('views',[__dirname + '/frontend/views', __dirname + '/backend/views']);
app.set('view engine', 'pug');
app.engine('html', require('pug').renderFile);
app.listen(server_port, server_ip_address, function () {
console.log( `Listening on ${server_port}, server_port ${server_port}.`);
});