Skip to content

Commit

Permalink
🎨 Cleaned some things
Browse files Browse the repository at this point in the history
  • Loading branch information
divyack2 committed Apr 24, 2024
1 parent 31bba0e commit 29a57a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/services/notifications/notifications-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ const notificationsRouter = Router();
// Register user’s device identifier under their userId
notificationsRouter.post(
"/",
RoleChecker([Role.enum.USER], false),
RoleChecker([Role.enum.USER]),
async (req, res, next) => {
try {
const notificationEnrollmentData = NotificationsValidator.parse(
req.body
);

const payload = res.locals.payload;

// Upsert the user-device mapping info
await Database.NOTIFICATIONS.findOneAndUpdate(
{ userId: notificationEnrollmentData.userId },
{ userId: payload.userId },
{ deviceId: notificationEnrollmentData.deviceId },
{ upsert: true, new: true }
);
Expand Down
2 changes: 1 addition & 1 deletion src/services/notifications/notifications-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from "zod";

// Zod schema for notifications
const NotificationsValidator = z.object({
userId: z.string(),
userId: z.coerce.string().regex(/user[0-9]*/),
deviceId: z.string(),
});

Expand Down

0 comments on commit 29a57a3

Please sign in to comment.