File size: 1,578 Bytes
3206347 |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import createError from 'http-errors';
import express from 'express';
import cors from 'cors';
import appConfig from './config/app.js';
import corsOptions from './config/cors-options.js';
import morgan from './helpers/morgan.js';
import * as Sentry from './helpers/sentry.ee.js';
import appAssetsHandler from './helpers/app-assets-handler.js';
import webUIHandler from './helpers/web-ui-handler.js';
import errorHandler from './helpers/error-handler.js';
import './config/orm.js';
import {
createBullBoardHandler,
serverAdapter,
} from './helpers/create-bull-board-handler.js';
import injectBullBoardHandler from './helpers/inject-bull-board-handler.js';
import router from './routes/index.js';
import configurePassport from './helpers/passport.js';
createBullBoardHandler(serverAdapter);
const app = express();
Sentry.init(app);
Sentry.attachRequestHandler(app);
Sentry.attachTracingHandler(app);
injectBullBoardHandler(app, serverAdapter);
appAssetsHandler(app);
app.use(morgan);
app.use(
express.json({
limit: appConfig.requestBodySizeLimit,
verify(req, res, buf) {
req.rawBody = buf;
},
})
);
app.use(
express.urlencoded({
extended: true,
limit: appConfig.requestBodySizeLimit,
verify(req, res, buf) {
req.rawBody = buf;
},
})
);
app.use(cors(corsOptions));
configurePassport(app);
app.use('/', router);
webUIHandler(app);
// catch 404 and forward to error handler
app.use(function (req, res, next) {
next(createError(404));
});
Sentry.attachErrorHandler(app);
app.use(errorHandler);
export default app;
|