2017-08-24 21:54:02 +00:00
|
|
|
const assets = require('../common/assets');
|
|
|
|
const locales = require('../common/locales');
|
|
|
|
const routes = require('./routes');
|
|
|
|
const pages = require('./routes/pages');
|
2018-02-21 04:31:27 +00:00
|
|
|
const tests = require('../test/frontend/routes');
|
2018-06-21 00:05:33 +00:00
|
|
|
const express = require('express');
|
|
|
|
const expressWs = require('express-ws');
|
|
|
|
const config = require('./config');
|
|
|
|
|
|
|
|
const wsapp = express();
|
|
|
|
expressWs(wsapp, null, { perMessageDeflate: false });
|
|
|
|
wsapp.ws('/api/ws', require('./routes/ws'));
|
|
|
|
wsapp.listen(8081, config.listen_address);
|
2017-08-24 21:54:02 +00:00
|
|
|
|
|
|
|
module.exports = function(app, devServer) {
|
|
|
|
assets.setMiddleware(devServer.middleware);
|
|
|
|
locales.setMiddleware(devServer.middleware);
|
|
|
|
routes(app);
|
2018-02-21 04:31:27 +00:00
|
|
|
tests(app);
|
2017-08-24 21:54:02 +00:00
|
|
|
// webpack-dev-server routes haven't been added yet
|
|
|
|
// so wait for next tick to add 404 handler
|
|
|
|
process.nextTick(() => app.use(pages.notfound));
|
|
|
|
};
|