Skip to content

[FEAT] Add glitchtip sentry to monitor issues 🗼 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -12,4 +12,7 @@ CRYPTO_SECRET=
TTL=

# CORS
CORS_ORIGIN=
CORS_ORIGIN=

# SENTRY
SENTRY_DSN=
145 changes: 141 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@sentry/node": "7.27.0",
"body-parser": "1.19.2",
"compression": "1.7.4",
"cors": "2.8.5",
2 changes: 2 additions & 0 deletions src/core/env.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ const envSchema = OBJECT.keys({
API_VERSION: STRING_REQUIRED,
// DATABASE
MONGOOSE_URI: STRING_REQUIRED,
// SENTRY
SENTRY_DSN: STRING_REQUIRED,
}).unknown();

try {
1 change: 1 addition & 0 deletions src/core/loaders/database.ts
Original file line number Diff line number Diff line change
@@ -14,5 +14,6 @@ export default async function main() {
logger.info('✅ Init database success');
} catch (err) {
logger.error('❌ Init database failed', err.message);
throw new Error(err.message);
}
}
7 changes: 7 additions & 0 deletions src/core/loaders/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Express } from 'express';
import * as Sentry from '@sentry/node';

import createFolders from '@core/loaders/folder';
import loadMiddlewares from '@core/loaders/middlewares';
@@ -7,12 +8,18 @@ import loadDatabase from '@core/loaders/database';
import error from '@services/internal/middlewares/error';
import notFound from '@services/internal/middlewares/notFound';

Sentry.init({
dsn: process.env.SENTRY_DSN,
});

export default async (app: Express) => {
createFolders();

app.use(Sentry.Handlers.requestHandler());
loadMiddlewares(app);
await loadDatabase();
loadProject(app);
app.use(Sentry.Handlers.errorHandler());

app.use(error);
app.use(notFound);