2022-10-13 17:11:55 +02:00
|
|
|
import express from "express";
|
|
|
|
import messageManager from "../tools/messageManager.js";
|
|
|
|
|
|
|
|
const messageRouter = express.Router();
|
|
|
|
|
2024-02-19 10:52:37 +01:00
|
|
|
messageRouter.get("/", (req, res) => {
|
|
|
|
res.json(messageManager.get());
|
2022-10-26 14:09:10 +02:00
|
|
|
});
|
|
|
|
|
2024-02-19 10:52:37 +01:00
|
|
|
messageRouter.patch("/:messageId/readed", (req, res) => {
|
|
|
|
if (messageManager.markReaded(req.params.messageId)) {
|
2022-10-26 14:09:10 +02:00
|
|
|
res.json(messageManager.get());
|
2024-02-19 10:52:37 +01:00
|
|
|
} else {
|
2022-10-26 14:09:10 +02:00
|
|
|
res.status(404).send();
|
|
|
|
}
|
|
|
|
});
|
2022-10-13 17:11:55 +02:00
|
|
|
|
2024-02-19 10:52:37 +01:00
|
|
|
messageRouter.post("/allReaded", (req, res) => {
|
|
|
|
messageManager.markAllReaded();
|
|
|
|
res.json(messageManager.get());
|
|
|
|
});
|
|
|
|
|
2022-10-13 17:11:55 +02:00
|
|
|
export default messageRouter;
|