Skip to content

Commit

Permalink
feat: add sentry url
Browse files Browse the repository at this point in the history
  • Loading branch information
wajeht committed Oct 26, 2023
1 parent 3bcf404 commit 1e7993f
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DB_USERNAME="node_user"
DB_PASSWORD="node_password"
DB_DATABASE="gains"
DB_URL=
SENTRY_URL=

# node
PORT=8087
Expand Down
125 changes: 125 additions & 0 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
Expand Up @@ -69,6 +69,7 @@
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/vue-fontawesome": "^3.0.3",
"@popperjs/core": "^2.11.8",
"@sentry/node": "^7.75.1",
"@vitejs/plugin-vue": "^4.4.0",
"adm-zip": "^0.5.10",
"animate.css": "^4.1.1",
Expand Down
11 changes: 10 additions & 1 deletion src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import expressJSDocSwagger from 'express-jsdoc-swagger';
import expressJsdocOptions from '../config/express-jsdoc-options.js';
import * as AppRoutes from './app.routes.js';
import { regularLimiter, apiLimiter } from '../config/rate-limiter.config.js';
import { jwt_secret } from '../config/env.js';
import { jwt_secret, SENTRY_URL } from '../config/env.js';
import * as Middlewares from './api/api.middlewares.js';
import CustomError from './api/api.errors.js';
import logger from '../utils/logger.js';
import redis from '../utils/redis.js';
import Sentry from '@sentry/node';

const app = express();
const server = http.createServer(app);
Expand All @@ -25,6 +26,9 @@ const io = new Server(server, {
},
});

Sentry.init({ dsn: SENTRY_URL });
app.use(Sentry.Handlers.requestHandler());

app.use(
helmet({
contentSecurityPolicy: {
Expand Down Expand Up @@ -56,6 +60,10 @@ app.use(
}),
);

// app.get('/debug-sentry', (req, res) => {
// throw new Error('My first Sentry error!');
// });

app.use('/docs/*', (req, res, next) => Middlewares.authenticateUser(req, res, next, true));

expressJSDocSwagger(app)(expressJsdocOptions);
Expand Down Expand Up @@ -140,6 +148,7 @@ app.use((req, res, next) => {
*/
app.use('*', regularLimiter, AppRoutes.vueHandler);

app.use(Sentry.Handlers.errorHandler());
app.use(AppRoutes.notFoundHandler);
app.use(AppRoutes.errorHandler);

Expand Down
2 changes: 2 additions & 0 deletions src/config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ export const GITHUB = {
};

export const MY_IP = process.env.MY_IP;

export const SENTRY_URL = process.env.SENTRY_URL;

0 comments on commit 1e7993f

Please sign in to comment.