diff --git a/packages/functions/src/coe.ts b/packages/functions/src/coe.ts index 77b1a74..18cde52 100644 --- a/packages/functions/src/coe.ts +++ b/packages/functions/src/coe.ts @@ -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), }; }); diff --git a/stacks/MyStack.ts b/stacks/MyStack.ts index 571711b..06cea46 100644 --- a/stacks/MyStack.ts +++ b/stacks/MyStack.ts @@ -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", },