From 62d5fc62994d130a1db8b1775ed7732585d415c3 Mon Sep 17 00:00:00 2001 From: Julien Lengrand-Lambert Date: Sun, 2 Feb 2025 19:37:21 +0100 Subject: [PATCH] Changing sentry connection --- src/index.js | 10 +++++----- src/routes/index.route.js | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index d61d4c4..adcc7a2 100644 --- a/src/index.js +++ b/src/index.js @@ -12,16 +12,11 @@ const Sentry = require("@sentry/node"); Sentry.init({ dsn: "http://e1b49746a229427c9cbb8840bfbde82b@bugsink-rk08sow8w0gw0gk0w44kk08s.138.201.122.228.sslip.io/1", - - // Alternatively, use `process.env.npm_package_version` for a dynamic release version - // if your build tool supports it. release: "sample-node-api@1.0.0", - integrations: [], tracesSampleRate: 0, }); - const express = require('express'); const http = require('http'); const https = require('https'); @@ -38,6 +33,11 @@ app.use(cors()); const routes = require('./routes/index.route'); app.use(routes); +const PORT = process.env.PORT || 3000; +app.listen(PORT, '0.0.0.0', () => { + console.log(`Server is running on port ${PORT}`); +}); + //start http server const httpServer = http.createServer(app); httpServer.listen(port); diff --git a/src/routes/index.route.js b/src/routes/index.route.js index da39f30..19356e7 100644 --- a/src/routes/index.route.js +++ b/src/routes/index.route.js @@ -8,6 +8,9 @@ Copyright IBM Corporation 2020 */ +const Sentry = require("@sentry/node"); + + const express = require('express'); const cars = require('./cars.route'); const accounts = require('./accounts.route'); @@ -21,7 +24,8 @@ router.use('/', swagger); router.get('/', (req, res) => res.send('Sample Node API Version1')); router.get('/error', (req, res) => { - throw new Error("Error Thrown on purpose to send it to Bugsink"); + res.send('Error'); + Sentry.captureException(new Error("Error Thrown on purpose to send it to Bugsink")); }); router.get('/health', (req, res) => {