mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-24 22:46:41 +07:00
getting webhook pathname from url
This commit is contained in:
parent
87da9078fe
commit
f444a7d194
3 changed files with 6 additions and 6 deletions
|
@ -3,8 +3,7 @@ http:
|
|||
telegram:
|
||||
key: ''
|
||||
webhook:
|
||||
path: /webhook
|
||||
url: https://something.org:123123/webhook
|
||||
url: https://something.org:65534/webhook
|
||||
enabled: false
|
||||
logger:
|
||||
level: info
|
||||
|
|
|
@ -7,6 +7,7 @@ import logger from "../../service/logger";
|
|||
import { TelegramService } from "../../service/telegram";
|
||||
import http from "http";
|
||||
import { WebhookConfig } from "../../config/types";
|
||||
import url, { URL } from "url";
|
||||
|
||||
export class HttpApi {
|
||||
app: Express;
|
||||
|
@ -37,9 +38,10 @@ export class HttpApi {
|
|||
this.app.use(bodyParser.json());
|
||||
this.app.use(express.json());
|
||||
|
||||
if (this?.webhook?.enabled && this?.webhook?.path) {
|
||||
logger.info(`using webhook at ${this.webhook.path}`);
|
||||
this.app.post(props.webhook.url, this.handleWebhook);
|
||||
if (this?.webhook?.enabled && this?.webhook?.url) {
|
||||
const url = new URL(this.webhook.url);
|
||||
logger.info(`using webhook at ${url.pathname}`);
|
||||
this.app.post(url.pathname, this.handleWebhook);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import { HttpConfig } from "../api/http/types";
|
|||
import { LoggerConfig } from "../service/logger/types";
|
||||
|
||||
export interface WebhookConfig {
|
||||
path?: string;
|
||||
url?: string;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue