-
Notifications
You must be signed in to change notification settings - Fork 7
/
server.js
39 lines (33 loc) · 1.3 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
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/webpack.dev.js');
const webpackMiddleware = require('webpack-dev-middleware');
const logPath = 'server.js';
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;