diff --git a/src/App.ts b/src/App.ts index df0eb72062bed5274b864534794c72937db81ed7..b839b7f6ca85950546ef35832deb1206d42139c8 100644 --- a/src/App.ts +++ b/src/App.ts @@ -1,10 +1,11 @@ -import { Handlers } from '@sentry/node'; +import { Handlers, init as sentryInit, Integrations } from '@sentry/node'; import * as bodyParser from 'body-parser'; import * as compress from 'compression'; import * as cors from 'cors'; import * as express from 'express'; import { Request, Response, Router } from 'express'; import * as logger from 'morgan'; +import * as process from 'process'; import { RoutingControllersOptions, useExpressServer } from 'routing-controllers'; import * as swaggerUi from 'swagger-ui-express'; import options from './lib/cors.config'; @@ -53,6 +54,8 @@ class App { // Run configuration methods on the Express instance. constructor() { + App.initializeSentry(); + this._express = express(); this._express.use(Handlers.requestHandler()); @@ -90,6 +93,17 @@ class App { this._express.use(`${staticStatistics.routePrefix}/`, router); } + + private static initializeSentry(): void { + sentryInit({ + dsn: process.env.SENTRY_DSN, + integrations: [ + new Integrations.OnUncaughtException(), new Integrations.OnUnhandledRejection(), + ], + enabled: process.env.NODE_ENV === 'production', + debug: true, + }); + } } export default new App().express; diff --git a/src/main.ts b/src/main.ts index 28b0898e56110538d0d8abf988d874f9396eb834..ca004a63ec1b4d124d0ef2c4ecac934907f18de3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,5 @@ declare function require(name: string): any; -import { init as sentryInit, Integrations } from '@sentry/node'; import * as http from 'http'; import { Server } from 'http'; import * as Minimist from 'minimist'; @@ -38,15 +37,6 @@ interface IInetAddress { address: string; } -sentryInit({ - dsn: process.env.SENTRY_DSN, - integrations: [ - new Integrations.OnUncaughtException(), new Integrations.OnUnhandledRejection(), - ], - enabled: process.env.NODE_ENV === 'production', - debug: true, -}); - (global).DAO = { AssetDAO, CasDAO,