Skip to content

Commit

Permalink
Add COE result endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ru Chern Chong committed Dec 19, 2023
1 parent 6b968ae commit 040b132
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/functions/src/coe.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { ApiHandler } from "sst/node/api";
import { COE } from "@lta-datasets-updater/core/coe";
import db from "../../config/db";

export const updater = ApiHandler(async (_evt) => {
const { message } = await COE.updater();
export const result = ApiHandler(async (_evt) => {
const result = await db
.collection("coe")
.find({ month: "2023-12" })
.toArray();

console.log(`COE result:`, result);

return {
statusCode: 200,
body: JSON.stringify({ status: 200, message }),
body: JSON.stringify(result),
};
});
1 change: 1 addition & 0 deletions stacks/MyStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const api = ({ stack }: StackContext) => {
"GET /brands": "packages/functions/src/brand.brands",
"GET /car/electric": "packages/functions/src/car.electric",
"GET /car/petrol": "packages/functions/src/car.petrol",
"GET /coe": "packages/functions/src/coe.result",
"GET /updater/cars": "packages/functions/src/updater.cars",
"GET /updater/coe": "packages/functions/src/updater.coe",
},
Expand Down

0 comments on commit 040b132

Please sign in to comment.