add notification delete route
This commit is contained in:
@@ -2,6 +2,7 @@ import { FastifyRequest, FastifyReply } from "fastify";
|
||||
import { PageQueryParams } from "../pagination";
|
||||
import {
|
||||
createNotification,
|
||||
deleteNotification,
|
||||
listNotifications,
|
||||
updateNotification,
|
||||
} from "./notification.service";
|
||||
@@ -63,3 +64,20 @@ export async function updateNotificationHandler(
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteNotificationHandler(
|
||||
req: FastifyRequest,
|
||||
res: FastifyReply
|
||||
) {
|
||||
const { notifId } = req.params as { notifId: string };
|
||||
|
||||
try {
|
||||
const deleteResult = await deleteNotification(notifId, req.user.tenantId);
|
||||
if (deleteResult.deletedCount == 0)
|
||||
return res.code(404).send({ error: "resource not found" });
|
||||
|
||||
return res.code(204).send();
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user