Skip to content

Commit

Permalink
refactor: rename app.ts to Bot.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tfkhdyt committed Sep 27, 2023
1 parent 66bc974 commit e1e8b62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
File renamed without changes.
9 changes: 2 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +32,6 @@ bot.use(async (ctx, next) => {
}
})

// event handler
bot.start((ctx) => app.sendStartMessage(ctx))

bot.help((ctx) => app.sendHelpMessage(ctx))
Expand Down Expand Up @@ -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'))

0 comments on commit e1e8b62

Please sign in to comment.