From 775b6f5900302e396ed2a5260a12718c87bfdfc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Mon, 5 Dec 2016 22:31:45 +0100 Subject: [PATCH] Delete app.js --- lib/db/app.js | 67 --------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 lib/db/app.js diff --git a/lib/db/app.js b/lib/db/app.js deleted file mode 100644 index 72fc1bf848..0000000000 --- a/lib/db/app.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -const express = require('express'); -const favicon = require('serve-favicon'); -const bodyParser = require('body-parser'); -const cookieParser = require('cookie-parser'); -const validator = require('express-validator'); -const responseTime = require('response-time'); -const log4js = require('log4js'); -const logger = require('./logger'); -const routes = require('./routes'); -const path = require('path'); -const errorHandler = require('errorhandler'); - -const { REQUEST_TIME } = require('./events'); - -module.exports = function (config) { - const app = express(); - - const baseUriPath = config.baseUriPath || ''; - const publicFolder = config.publicFolder; - - app.set('trust proxy'); - app.set('port', config.port); - app.locals.baseUriPath = baseUriPath; - app.use(cookieParser()); - - if (publicFolder) { - app.use(favicon(path.join(publicFolder, 'favicon.ico'))); - } - - app.use(responseTime((req, res, time) => { - const timingInfo = { path: req.path, method: req.method, statusCode: res.statusCode, time }; - config.eventBus.emit(REQUEST_TIME, timingInfo); - })); - - app.use(validator([])); - - if (publicFolder) { - app.use(baseUriPath, express.static(publicFolder)); - } - - app.use(bodyParser.json({ strict: false })); - - if (config.enableRequestLogger) { - app.use(log4js.connectLogger(logger, { - format: ':status :method :url :response-timems', - level: 'auto', // 3XX=WARN, 4xx/5xx=ERROR - })); - } - - // Setup API routes - const apiRouter = express.Router(); // eslint-disable-line new-cap - routes.createAPI(apiRouter, config); - app.use(`${baseUriPath}/api/`, apiRouter); - - // Setup deprecated routes - const router = express.Router(); // eslint-disable-line new-cap - routes.createLegacy(router, config); - app.use(baseUriPath, router); - - if (process.env.NODE_ENV !== 'production') { - app.use(errorHandler()); - } - - return app; -};