Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
notification-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Group 5
notification-service
Commits
8ccd6676
Commit
8ccd6676
authored
2 years ago
by
Josh Everett
Browse files
Options
Downloads
Patches
Plain Diff
Added logging for fetching notification
parent
fd7f7c20
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/index.js
+6
-6
6 additions, 6 deletions
src/index.js
src/routes/notification.js
+4
-0
4 additions, 0 deletions
src/routes/notification.js
with
10 additions
and
6 deletions
src/index.js
+
6
−
6
View file @
8ccd6676
...
...
@@ -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}
"
);
})
This diff is collapsed.
Click to expand it.
src/routes/notification.js
+
4
−
0
View file @
8ccd6676
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment