From 77495f31e36b6fa437427fd95b36da24f77e9237 Mon Sep 17 00:00:00 2001 From: riyap Date: Wed, 24 Apr 2024 00:42:26 -0500 Subject: [PATCH] get all events --- src/services/events/events-router.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/services/events/events-router.ts b/src/services/events/events-router.ts index 5faf425..02e52da 100644 --- a/src/services/events/events-router.ts +++ b/src/services/events/events-router.ts @@ -30,4 +30,17 @@ eventRouter.get("/:eventId", async (req, res, next) => { } }); +eventRouter.get("/", async (req, res, next) => { + try { + const events = await Database.EVENTS.find({}); + + if (!events) { + return { error: "No events" }; + } + return res.status(StatusCodes.OK).json(events); + } catch (error) { + next(error); + } +}); + export default eventRouter;