mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-25 15:34:38 +03:00
docs(): add standalone applications page, refactoring webhooks page
This commit is contained in:
parent
4e637cbce6
commit
b1a6e50f8f
27
website/docs/extras/standalone-applications.md
Normal file
27
website/docs/extras/standalone-applications.md
Normal 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)
|
||||||
|
:::
|
@ -1,10 +1,16 @@
|
|||||||
---
|
---
|
||||||
id: webhooks
|
id: getting-updates
|
||||||
title: Webhooks
|
title: Getting updates
|
||||||
sidebar_label: Webhooks
|
sidebar_label: Getting updates
|
||||||
slug: webhooks
|
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.
|
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:
|
To access it, you must use the `app.get()` method, followed by the provider reference:
|
@ -2,11 +2,12 @@ module.exports = {
|
|||||||
docs: {
|
docs: {
|
||||||
'Getting Started': [
|
'Getting Started': [
|
||||||
'installation',
|
'installation',
|
||||||
|
'getting-updates',
|
||||||
'telegraf-methods',
|
'telegraf-methods',
|
||||||
'bot-injection',
|
'bot-injection',
|
||||||
'async-configuration',
|
'async-configuration',
|
||||||
'webhooks',
|
|
||||||
],
|
],
|
||||||
|
Extras: ['extras/standalone-applications'],
|
||||||
'API Reference': ['api-reference/decorators'],
|
'API Reference': ['api-reference/decorators'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user