1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- var createError = require('http-errors');
- var express = require('express');
- var path = require('path');
- var cookieParser = require('cookie-parser');
- var logger = require('morgan');
- const knex = require('knex');
- var app = express();
- var RoutingSystem = require('./systems/RoutingSystem');
- var RepositorySystem = require('./systems/RepositorySystem').setDB();
- var AdminSystem = require('./systems/AdminSystem');
- var UserSystem = require('./systems/UserSystem');
- var ModuleSystem = require('./systems/ModuleSystem');
- var Filters = require('./modules/Filters/FilterService');
- ModuleSystem.loadModules();
- ModuleSystem.run();
- app.use(express.json({limit: '50mb'}));
- app.set('view engine', 'html');
- // app.use(logger('dev'));
- // app.use(express.urlencoded({ extended: false }));
- // app.use(cookieParser());
- // app.use(express.static(path.join(__dirname, 'public')));
- app.use(UserSystem.Middleware);
- app.use(Filters.Middleware);
- app.use(RoutingSystem.router);
- // catch 404 and forward to error handler
- app.use(function(req, res, next) {
- next(createError(404));
- });
- // error handler
- app.use(function(err, req, res, next) {
- // set locals, only providing error in development
- if(err.message !== "401")
- throw err;
- res.locals.message = err.message;
- res.locals.error = req.app.get('env') === 'development' ? err : {};
- // render the error page
- res.sendStatus(err.status || 500);
- //res.sendStatus(404);
- });
- module.exports = app;
|