-
Notifications
You must be signed in to change notification settings - Fork 0
/
duty.js
37 lines (28 loc) · 893 Bytes
/
duty.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
const express = require('express');
const https = require('https');
const fs = require('fs');
const cors = require('cors');
const compression = require('compression');
const ngnRouter = require('./routes/ngn');
const app = express();
require('dotenv').config();
const port = process.env.PORT || 3000;
const keyFile = fs.readFileSync(__dirname + "/certs/duti.key", 'utf-8');
const certFile = fs.readFileSync(__dirname + "/certs/duti.cert", 'utf-8');
const options = {key: keyFile, cert: certFile};
app.disable('x-powered-by');
app.use(function (req, res, next) {
res.setHeader(
'Content-Security-Policy',
"default-src 'self'; connect-src 'self'"
);
next();
});
app.use(cors({origin: '*'}));
app.use(compression());
app.use('/ngn', ngnRouter);
https
.createServer(options, app)
.listen(port, '0.0.0.0', () => {
console.log(`Server running on port ${port}`);
});