1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-25 15:06:41 +07:00

#5 added healthcheck

This commit is contained in:
Fedor Katurov 2021-05-12 14:24:56 +07:00
parent 46d24cd9dd
commit dd3c281af9
6 changed files with 37 additions and 4 deletions

View file

@ -53,11 +53,12 @@ export class HttpApi {
const url = new URL(this.webhook.url);
logger.info(`using webhook at ${url.pathname}`);
this.app.post(url.pathname, this.handleWebhook);
this.app.get(url.pathname, this.testWebhook);
this.app.get(url.pathname, this.healthcheck);
}
// VK event handler
this.app.post(this.vk.endpoint, this.vk.handle);
this.app.get("/", this.healthcheck);
}
/**
@ -71,7 +72,12 @@ export class HttpApi {
/**
* Just returns 200
*/
private testWebhook = async (req: Request, res: Response) => {
res.sendStatus(200);
private healthcheck = async (req: Request, res: Response) => {
try {
await Promise.all([this.telegram.healthcheck(), this.vk.healthcheck()]);
res.sendStatus(200);
} catch (e) {
res.sendStatus(501);
}
};
}