From 6f0a8a08beef85a45c34372e83537df31002f67e Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Sun, 23 Jun 2024 20:50:55 +0800 Subject: [PATCH] Add API to fetch all cars in a given month --- src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.ts b/src/index.ts index 1af6dfb..1d843fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,6 +28,11 @@ app.get("/", async (c) => { return c.json(await getCarsByFuelType(FUEL_TYPE.PETROL, month)); }); +app.get("/cars", async (c) => { + const month = c.req.query("month"); + return c.json(await db.collection("cars").find({ month }).toArray()); +}); + app.get("/cars/:fuelType", async (c) => { const fuelType = c.req.param("fuelType"); const month = c.req.query("month");