Skip to content

Commit

Permalink
Add API to fetch all cars in a given month
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Jun 23, 2024
1 parent 6d58bc3 commit 6f0a8a0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Car>("cars").find({ month }).toArray());
});

app.get("/cars/:fuelType", async (c) => {
const fuelType = c.req.param("fuelType");
const month = c.req.query("month");
Expand Down

0 comments on commit 6f0a8a0

Please sign in to comment.