docs(): add standalone applications page, refactoring webhooks page

This commit is contained in:
Alexander Bukhalo 2020-12-30 23:19:54 +03:00
parent 4e637cbce6
commit b1a6e50f8f
3 changed files with 40 additions and 6 deletions

View File

@ -0,0 +1,27 @@
---
id: standalone-applications
title: Standalone applications
sidebar_label: Standalone applications
slug: standalone-applications
---
If you initialized your application with the [Nest CLI](https://docs.nestjs.com/cli/overview), [Express](https://expressjs.com/) framework will be installed by default along with Nest. Nest and NestJS Telegraf does not require Express for work. So if you don't plan to getting bot updates through webhooks, and you don't need a web server, you can remove Express.
To do this, change the `bootstrap` function in the `main.ts` file of your project on something like that:
```typescript
async function bootstrap() {
const app = await NestFactory.createApplicationContext(AppModule);
}
bootstrap();
```
This initializes Nest as a **standalone application** (without any network listeners).
All that remains is to remove unused dependencies:
```bash
npm un @nestjs/platform-express @types/express
```
:::info
More information about standalone applications located at [Nest documentation](https://docs.nestjs.com/standalone-applications)
:::

View File

@ -1,10 +1,16 @@
---
id: webhooks
title: Webhooks
sidebar_label: Webhooks
slug: webhooks
id: getting-updates
title: Getting updates
sidebar_label: Getting updates
slug: getting-updates
---
## Long polling
By default, the bot receives updates using long-polling and requires no additional action.
## 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:

View File

@ -2,11 +2,12 @@ module.exports = {
docs: {
'Getting Started': [
'installation',
'getting-updates',
'telegraf-methods',
'bot-injection',
'async-configuration',
'webhooks',
],
Extras: ['extras/standalone-applications'],
'API Reference': ['api-reference/decorators'],
},
};