-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65ada59
commit d9e3d1d
Showing
10 changed files
with
51 additions
and
70 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
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 +1,10 @@ | ||
import db from "../../config/db"; | ||
import { Car } from "./types"; | ||
import { Flatten, WithId } from "mongodb"; | ||
|
||
export const list = async () => db.collection("cars").distinct("make"); | ||
const collection = db.collection<Car>("cars"); | ||
|
||
export const list = async (): Promise<Array<Flatten<WithId<Car>["make"]>>> => | ||
collection.distinct("make"); | ||
|
||
export * as VehicleMake from "./vehicle-make"; |
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,17 +1,17 @@ | ||
import { ApiHandler, useQueryParam } from "sst/node/api"; | ||
import { Cars } from "@lta-cars-dataset/core/cars"; | ||
import { createResponse } from "./utils/createResponse"; | ||
import { WithId } from "mongodb"; | ||
import { Car } from "@lta-cars-dataset/core/types"; | ||
|
||
export const electric = ApiHandler(async (_evt) => { | ||
const month = useQueryParam("month"); | ||
const electricCars = await Cars.electric({ month }); | ||
|
||
return createResponse(electricCars); | ||
const cars: WithId<Car>[] = await Cars.electric({ month }); | ||
return createResponse(cars); | ||
}); | ||
|
||
export const petrol = ApiHandler(async (_evt) => { | ||
const month = useQueryParam("month"); | ||
const petrolCars = await Cars.petrol({ month }); | ||
|
||
return createResponse(petrolCars); | ||
const cars: WithId<Car>[] = await Cars.petrol({ month }); | ||
return createResponse(cars); | ||
}); |
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