-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathserver.js
49 lines (41 loc) · 1.59 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const config = require('@hmcts/properties-volume').addTo(require('config'));
const setupSecrets = require('services/setupSecrets');
// Setup secrets before loading the app
setupSecrets();
const app = require('app.js');
const logger = require('logger');
const https = require('https');
const fs = require('graceful-fs');
const webpack = require('webpack');
const webpackDevConfig = require('./webpack.config.js');
const webpackMiddleware = require('webpack-dev-middleware');
const { fetchAndSetPortsAndCountries } = require('./utils/enumJsonLists');
const logPath = 'server.js';
(async function initialiseEnums() {
await fetchAndSetPortsAndCountries();
setInterval(async() => {
await fetchAndSetPortsAndCountries();
/* eslint-disable-next-line no-magic-numbers */
}, 60 * 60 * 1000);
}());
if (process.env.NODE_ENV === 'development') {
const compiler = webpack(webpackDevConfig);
const wp = webpackMiddleware(compiler, { publicPath: webpackDevConfig.output.publicPath });
app.use(wp);
wp.waitUntilValid(stats => {
app.locals.webpackHash = stats.hash;
https.createServer({
key: fs.readFileSync('src/main/resources/localhost-ssl/localhost.key'), // eslint-disable-line
cert: fs.readFileSync('src/main/resources/localhost-ssl/localhost.crt') // eslint-disable-line
}, app).listen(config.node.port, () => {
logger.trace(`SYA server listening on port: ${config.node.port}`, logPath);
});
});
} else {
app
.listen(config.node.port,
() => {
logger.trace(`SYA server listening on port: ${config.node.port}`, logPath);
});
}
app.timeout = 240000;