Skip to content

Commit

Permalink
add server logs
Browse files Browse the repository at this point in the history
  • Loading branch information
adidoesnt committed Feb 4, 2024
1 parent 0cf4d49 commit 4370ae4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions telegram-bot/src/components/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Bot {
}

setWebhook(): void {
this.logger.info('Setting webhook');
this.client.setWebHook(webhook_url + token);
}

Expand Down
7 changes: 6 additions & 1 deletion telegram-bot/src/components/server.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import express, { type Express } from 'express';
import { json } from 'body-parser';
import type { Bot } from './bot';
import { type Logger as Log4js } from 'log4js';
import { Logger } from './logger';

const { PORT: port = 3000, TELEGRAM_BOT_TOKEN: token = '' } = process.env;

export class Server {
static instance: Server;
private app: Express;
private readonly port: number;
private logger: Log4js;

private constructor() {
this.logger = Logger.getLogger('Server');
this.logger.info('Initialising server');
this.app = express();
this.port = Number(port);
this.app.use(json());
this.app.listen(this.port, () => {
console.log(`Server running on port ${this.port}`);
this.logger.info(`Server running on port ${this.port}`);
});
}

Expand Down

0 comments on commit 4370ae4

Please sign in to comment.