docs: support docs versioning, new update hook decorators docs added

This commit is contained in:
Aleksandr Bukhalo
2020-09-10 11:23:04 +03:00
parent 7043f247da
commit df2b6a5ab3
20 changed files with 711 additions and 20 deletions

View File

@@ -0,0 +1,35 @@
---
id: webhooks
title: Webhooks
sidebar_label: Webhooks
slug: webhooks
---
If you want to configure a telegram bot webhook, you need to get a middleware from `TelegrafProvider` for connect it in your `main.ts` file.
To access it, you must use the `app.get()` method, followed by the provider reference:
```typescript
const telegrafProvider = app.get('TelegrafProvider');
```
Now you can connect middleware:
```typescript
app.use(telegrafProvider.webhookCallback('/secret-path'));
```
The last step is to specify launchOptions in `forRoot` method:
```typescript
TelegrafModule.forRootAsync({
imports: [ConfigModule.forFeature(telegrafModuleConfig)],
useFactory: async (configService: ConfigService) => ({
token: configService.get<string>('TELEGRAM_BOT_TOKEN'),
launchOptions: {
webhook: {
domain: 'domain.tld',
hookPath: '/secret-path',
}
}
}),
inject: [ConfigService],
});
```