Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.post("/v1/notifications/subscribe", async (req, res) => {
if (!z.object({
uuid: z.string(),
token: z.string(),
type: z.string()
}).check(req.body) || !NOTIFICATION_TYPES.includes(req.body.type)) {
return res.status(400).json({
ok: false,
error: "Invalid request."
});
}
const code = await tokens.verifyPushNotificationToken(req.body.token);
if (!code) return res.status(403).json({
ok: false,
error: "Invalid token."
});