diff --git a/src/index.js b/src/index.js index 85fef6b70d0ab41ec11d7e75a7157157f93b0e4e..d4c7f4baa96eef5e6e00ebbb7fe0460465c165e4 100644 --- a/src/index.js +++ b/src/index.js @@ -8,18 +8,18 @@ const app = express(); const port = process.env.PORT; app.use(express.json()); -app.get("/",(req,res) =>{ +app.get("/", (req, res) => { console.log("testing"); res.send("Hello"); - + }) const notificationRouter = require("./routes/notification"); -app.use("/notification",notificationRouter); +app.use("/notification", notificationRouter); - app.listen(port, function(){ - console.log("Notifcation Microservice is running ..."); - }) +app.listen(port, function () { + console.log("Notifcation Microservice is running at http://localhost:${port}"); +}) diff --git a/src/routes/notification.js b/src/routes/notification.js index b2ef76d444d6401f40099c6450266dd3d3b0b415..f53ce6e20e25c313f2d2c2f0a3b96e11f27dd4cc 100644 --- a/src/routes/notification.js +++ b/src/routes/notification.js @@ -18,6 +18,7 @@ const jwtAlgorithm = "HS512"; // retrieve all the notifications for a user that are stored in the database. router.get("/info", async (req, res) => { + console.log("fetching notifications called") try { // Get the JWT secret from the environment variables @@ -39,10 +40,13 @@ router.get("/info", async (req, res) => { // Get the user id from the decoded token payload. const userId = payload.id; + console.log("fetching the notifications for user: " + userId) + // Find all the notifications for the user and return them without the user_id and __v fields. // as this should not be exposed to the user. const notifications = await Notification.find({ user_id: userId }, { user_id: 0, __v: 0 }); + console.log("found notifications for user: " + userId + " " + notifications.length + " notifications found.") res.status(200).send(notifications);