Skip to content

Commit

Permalink
🚨 Fixing linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
divyack2 committed Apr 24, 2024
1 parent bac3ab4 commit 31bba0e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: 'yarn'
cache: "yarn"
- name: Install dependencies
run: yarn
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: 'yarn'
cache: "yarn"
- name: Install dependencies
run: yarn
- name: Run ESLint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: 'yarn'
cache: "yarn"
- name: Install dependencies
run: yarn
- name: Run Prettier
Expand Down
9 changes: 7 additions & 2 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
SubscriptionSchema,
} from "./services/subscription/subscription-schema";
import {
NotificationsSchema, NotificationsValidator
NotificationsSchema,
NotificationsValidator,
} from "./services/notifications/notifications-schema";

mongoose.set("toObject", { versionKey: false });
Expand Down Expand Up @@ -60,5 +61,9 @@ export const Database = {
RegistrationSchema,
RegistrationValidator
),
NOTIFICATIONS: initializeModel("notifications", NotificationsSchema, NotificationsValidator),
NOTIFICATIONS: initializeModel(
"notifications",
NotificationsSchema,
NotificationsValidator
),
};
32 changes: 17 additions & 15 deletions src/services/notifications/notifications-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ const notificationsRouter = Router();

// Register user’s device identifier under their userId
notificationsRouter.post(
"/",
"/",
RoleChecker([Role.enum.USER], false),
async (req, res, next) => {
try {
const notificationEnrollmentData = NotificationsValidator.parse(req.body);
try {
const notificationEnrollmentData = NotificationsValidator.parse(
req.body
);

// Upsert the user-device mapping info
await Database.NOTIFICATIONS.findOneAndUpdate(
{ userId: notificationEnrollmentData.userId },
{ deviceId: notificationEnrollmentData.deviceId },
{ upsert: true, new: true }
);
// Upsert the user-device mapping info
await Database.NOTIFICATIONS.findOneAndUpdate(
{ userId: notificationEnrollmentData.userId },
{ deviceId: notificationEnrollmentData.deviceId },
{ upsert: true, new: true }
);

return res.status(StatusCodes.OK).json(notificationEnrollmentData);

} catch (error) {
next(error);
return res.status(StatusCodes.OK).json(notificationEnrollmentData);
} catch (error) {
next(error);
}
}
});
);

export default notificationsRouter;
export default notificationsRouter;
2 changes: 1 addition & 1 deletion src/services/notifications/notifications-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ const NotificationsSchema = new mongoose.Schema({
deviceId: { type: String, required: true },
});

export { NotificationsSchema, NotificationsValidator };
export { NotificationsSchema, NotificationsValidator };

0 comments on commit 31bba0e

Please sign in to comment.