diff options
| author | Jan Tuomi <jan.tuomi@valuemotive.com> | 2021-11-07 22:13:49 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@valuemotive.com> | 2021-11-07 22:13:49 +0200 |
| commit | 7991ad93470cf42b9c4c96477fc920bbb8899eee (patch) | |
| tree | 2e066c5ffd4895f2bafede1f92cb1cdc08557b4d /src/index.ts | |
| parent | 2c5c47e3c5343419a6efa618b9d6549394da2e9f (diff) | |
Prepare for move to DO
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/index.ts b/src/index.ts index 773ae3c..b675584 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,9 +2,9 @@ import { App } from "@tinyhttp/app"; import { logger } from "@tinyhttp/logger"; import bodyParser from "body-parser"; import config from "./config"; -import { httpMiddleware } from "./middleware"; import { buildSheetsClient } from "./sheets"; import { bot, broadcastMessage } from "./tg"; +import { httpHeaderAuth } from "./middleware"; const main = async () => { const sheets = await buildSheetsClient(); @@ -27,7 +27,7 @@ const main = async () => { .get("/", async (_, res) => { res.send({ service: "hommabot2 API" }); }) - .post("/scheduler/trigger", httpMiddleware.verifyGoogleJWT, async (_req, res) => { + .post("/scheduler/trigger", httpHeaderAuth, async (_req, res) => { try { const sheetData = await sheets.fetchSheetData(); const entries = sheets.processRows(sheetData); @@ -38,8 +38,11 @@ const main = async () => { const taskText = tasks.join("\n"); const msg = `Tällä viikolla tehtävät hommat:\n${taskText}`; await broadcastMessage(msg); + console.log("Broadcasted message:", msg); } else { - await broadcastMessage("Tällä viikolla ei toistuvia hommia! 🎉"); + const msg = "Tällä viikolla ei toistuvia hommia! 🎉"; + await broadcastMessage(msg); + console.log("Broadcasted message:", msg); } const newDateStamps = sheets.updatedLastDoneDateStamps(entries); |
