From e1e8b620716cf4199cc965270b7d2ab81dc4429f Mon Sep 17 00:00:00 2001 From: tfkhdyt Date: Wed, 27 Sep 2023 10:17:34 +0700 Subject: [PATCH] refactor: rename app.ts to Bot.ts --- src/{app.ts => Bot.ts} | 0 src/main.ts | 9 ++------- 2 files changed, 2 insertions(+), 7 deletions(-) rename src/{app.ts => Bot.ts} (100%) diff --git a/src/app.ts b/src/Bot.ts similarity index 100% rename from src/app.ts rename to src/Bot.ts diff --git a/src/main.ts b/src/main.ts index 953f8ab..9c828b6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,18 +3,16 @@ import { drizzle } from 'drizzle-orm/postgres-js' import { migrate } from 'drizzle-orm/postgres-js/migrator' import { message } from 'telegraf/filters' -import App from './app.js' +import Bot from './Bot.js' import config from './config/config.js' import { db, migrationClient } from './db/postgres/index.js' import { users } from './db/postgres/schemas/user.schema.js' await migrate(drizzle(migrationClient), { migrationsFolder: './drizzle' }) -// class instantiation -const app = new App(config.botToken) +const app = new Bot(config.botToken) const bot = app.bot -// middleware bot.use(async (ctx, next) => { try { const userId = ctx.from?.id @@ -34,7 +32,6 @@ bot.use(async (ctx, next) => { } }) -// event handler bot.start((ctx) => app.sendStartMessage(ctx)) bot.help((ctx) => app.sendHelpMessage(ctx)) @@ -77,9 +74,7 @@ if (config.nodeEnv === 'development') { port: config.port, }, }) - // bot.startWebhook(`/bot${botToken}`, null, port) } -// Enable graceful stop process.once('SIGINT', () => bot.stop('SIGINT')) process.once('SIGTERM', () => bot.stop('SIGTERM'))