aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.ts
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@valuemotive.com>2021-04-18 20:10:34 +0300
committerJan Tuomi <jan.tuomi@valuemotive.com>2021-04-18 20:10:34 +0300
commitcf2e3c99ded0f48bd565858aedc7f10a0d932a61 (patch)
tree699e9c6b78456474b4b0e680a15a6b1bc49aab08 /src/index.ts
parentbaacc7676c688cd2728033e9051208d655255ee5 (diff)
Add db connection
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/index.ts b/src/index.ts
index 71e239f..4edfc2f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,16 +1,14 @@
import { App } from "@tinyhttp/app";
import { logger } from "@tinyhttp/logger";
-import { Telegraf } from "telegraf";
import config from "./config";
-import { tgMiddleware } from "./middleware";
+import { bot } from "./tg";
-const app = new App();
-console.log(`Setting up Telegram bot with token ${config.tgBotToken}`);
-const bot = new Telegraf(config.tgBotToken);
-
-bot.use(tgMiddleware.auth);
-bot.command("/start", (ctx) => ctx.reply("started"));
-bot.command("/stop", (ctx) => ctx.reply("stopped"));
+const app = new App({
+ onError: (err, _req, res) => {
+ console.log(err);
+ res.status(500).send("Something bad happened");
+ },
+});
app
.use(logger({
@@ -19,7 +17,7 @@ app
},
}))
.use(bot.webhookCallback("/webhook/telegram"))
- .get("/", (_, res) => {
+ .get("/", async (_, res) => {
res.send({ service: "hommabot2 API" });
})
.post("/scheduler/trigger", (_req, res) => {