mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
a96a9f38ce
* #108 Add eslint-config-spt * #108 Ignore bundle.js file * #108 Change eslint ignore path to a glob file * Remove jshint and follow more of eslint rules
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
var express = require('express'),
|
|
bodyParser = require('body-parser'),
|
|
cookieParser = require('cookie-parser'),
|
|
log4js = require('log4js'),
|
|
logger = require('./lib/logger'),
|
|
routes = require('./lib/routes'),
|
|
eventApi = require('./lib/eventApi'),
|
|
featureApi = require('./lib/featureApi'),
|
|
featureArchiveApi = require('./lib/featureArchiveApi'),
|
|
strategyApi = require('./lib/strategyApi'),
|
|
validator = require('express-validator'),
|
|
app = express(),
|
|
router = express.Router(), // eslint-disable-line
|
|
baseUriPath = process.env.BASE_URI_PATH || '';
|
|
|
|
if (app.get('env') === 'development') {
|
|
app.use(require('errorhandler')());
|
|
|
|
var webpack = require('webpack'),
|
|
webpackDevMiddleware = require('webpack-dev-middleware'),
|
|
webpackConfig = require('./webpack.config'),
|
|
compiler = webpack(webpackConfig),
|
|
config = {
|
|
publicPath: '/js',
|
|
noInfo: true
|
|
};
|
|
|
|
app.use(baseUriPath, webpackDevMiddleware(compiler, config));
|
|
}
|
|
|
|
app.use(validator([]));
|
|
|
|
app.set('trust proxy');
|
|
app.locals.baseUriPath = baseUriPath;
|
|
|
|
app.use(log4js.connectLogger(logger, {
|
|
format: ':remote-addr :status :method :url :response-timems',
|
|
level: 'auto' // 3XX=WARN, 4xx/5xx=ERROR
|
|
}));
|
|
|
|
app.set('port', process.env.HTTP_PORT || process.env.PORT || 4242);
|
|
|
|
app.use(baseUriPath, express.static(__dirname + '/public'));
|
|
app.use(bodyParser.json({ strict: false }));
|
|
|
|
app.use(cookieParser());
|
|
|
|
eventApi(router);
|
|
featureApi(router);
|
|
featureArchiveApi(router);
|
|
strategyApi(router);
|
|
routes(router);
|
|
app.use(baseUriPath, router);
|
|
|
|
module.exports = app;
|