-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update API for cars to query by month
- Loading branch information
Ru Chern Chong
committed
Dec 29, 2023
1 parent
4733bd6
commit 8b348b9
Showing
2 changed files
with
23 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { ApiHandler } from "sst/node/api"; | ||
import { ApiHandler, useQueryParam } from "sst/node/api"; | ||
import { Cars } from "@lta-cars-dataset/core/cars"; | ||
import { createResponse } from "./utils/createResponse"; | ||
|
||
export const electric = ApiHandler(async (_evt) => { | ||
const electricCars = await Cars.electric(); | ||
const month = useQueryParam("month"); | ||
const electricCars = await Cars.electric({ month }); | ||
|
||
return createResponse(electricCars); | ||
}); | ||
|
||
export const petrol = ApiHandler(async (_evt) => { | ||
const petrolCars = await Cars.petrol(); | ||
const month = useQueryParam("month"); | ||
const petrolCars = await Cars.petrol({ month }); | ||
|
||
return createResponse(petrolCars); | ||
}); |