Notification system enhanced

- Base for notifcation center
- Show text in map if no data is available
This commit is contained in:
2020-11-21 14:11:26 +01:00
parent 8b54431449
commit 533749c7c8
26 changed files with 323 additions and 76 deletions

View File

@@ -0,0 +1,22 @@
import { Response } from "express";
import { LivebeatRequest } from "../lib/request";
import { Notification } from "../models/notifications/notification.model";
export async function getNotification(req: LivebeatRequest, res: Response) {
let limit = req.query.limit;
let skip = req.query.skip;
if (limit === undefined) { limit = '100' };
if (skip === undefined) { skip = '0' };
try {
const notifications = await Notification.find({ user: req.user?._id }).limit(Number(limit)).sort({ _id: -1 });
res.status(200).send(notifications);
} catch(error: any) {
if (error instanceof TypeError) {
res.status(400).send({ message: "'Limit' has to be a number" });
} else {
res.status(500).send({ message: "An error occured while processing your request" });
}
}
}