{"id":21931511,"url":"https://github.com/sar1008/nestjs-airgram","last_synced_at":"2026-05-10T19:39:02.095Z","repository":{"id":230783689,"uuid":"780067534","full_name":"sar1008/nestjs-airgram","owner":"sar1008","description":"Airgram module for Nest framework (node.js) ✈️","archived":false,"fork":false,"pushed_at":"2024-03-31T16:00:04.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T12:22:24.197Z","etag":null,"topics":["nestjs","nodejs","tdl","telegram","telegram-api","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sar1008.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-31T15:59:19.000Z","updated_at":"2024-03-31T16:01:09.000Z","dependencies_parsed_at":"2024-03-31T23:35:11.009Z","dependency_job_id":null,"html_url":"https://github.com/sar1008/nestjs-airgram","commit_stats":null,"previous_names":["sar1008/nestjs-airgram"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sar1008%2Fnestjs-airgram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sar1008%2Fnestjs-airgram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sar1008%2Fnestjs-airgram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sar1008%2Fnestjs-airgram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sar1008","download_url":"https://codeload.github.com/sar1008/nestjs-airgram/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959453,"owners_count":20538628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nestjs","nodejs","tdl","telegram","telegram-api","typescript"],"created_at":"2024-11-28T23:14:11.208Z","updated_at":"2026-05-10T19:38:57.066Z","avatar_url":"https://github.com/sar1008.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo_text.svg\" width=\"320\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/nestjs-airgram\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/nestjs-airgram.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/nestjs-airgram\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/nestjs-airgram.svg\" alt=\"Package License\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/nestjs-airgram\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/nestjs-airgram.svg\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Description\n\n[Airgram](https://github.com/airgram/airgram) module for [Nest](https://github.com/nestjs/nest).\n\n## Installation\n\n**NPM**\n```bash\n$ npm i -s nestjs-airgram\n```\n\n**Yarn**\n```bash\n$ yarn add nestjs-airgram\n```\n\n## Quick Start\nOnce the installation process is complete, now we need **TDLib 1.7** binaries, how to get them you need to build them by this [guide](https://github.com/tdlib/td#building), or you can found [here](https://github.com/Bannerets/tdl#installation),\nthen place binaries somewhere in your project workspace. Then we can import the module `TdlModule` either synchronously or asynchronosly into the root `AppModule`.\n\nIt is important to specify the correct path to the TDLib binaries in the `command` field.\nIt is directly passed to dlopen / LoadLibrary. Check your OS documentation to see where it searches for the library.\n\n\u0026nbsp;\n\n### Synchronous configuration\n```typescript\nimport { Module } from '@nestjs/common';\nimport { AirgramModule } from 'nestjs-airgram';\n\n@Module({\n  imports: [\n    AirgramModule.forRoot({\n      apiId: 'YOUR_APP_ID',\n      apiHash: 'YOUR_API_HASH',\n      command: path.resolve('tdjson.dll'), // Path to tdlib\n      auth: {\n        // ...\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nThen we can inject `Airgram` into our services. And use decorators for events.\n\n```typescript\nimport { Injectable, OnModuleInit } from '@nestjs/common';\nimport {\n  Airgram,\n  Context,\n  GetMeMiddleware,\n  UpdateNewMessageMiddleware,\n} from 'airgram';\nimport {\n  ExtractMiddlewareContext,\n  InjectAirgram,\n  OnEvent,\n  OnRequest,\n  OnUpdate,\n} from 'nestjs-airgram';\n\n@Injectable()\nexport class AppService implements OnModuleInit {\n  constructor(@InjectAirgram() private airgram: Airgram) {\n    setTimeout(() =\u003e this.onModuleInit(), 4000);\n  }\n\n  async onModuleInit(): Promise\u003cvoid\u003e {\n    const me = await this.airgram.api.getMe();\n    console.log('[Me]', me);\n  }\n\n  @OnEvent()\n  onAnyEvent(ctx: Context): void {\n    // This code will be invoked before every request and after all updates.\n  }\n\n  @OnUpdate()\n  async onUpdate(update: unknown): Promise\u003cvoid\u003e {\n    // This code will be invoked after update.\n  }\n\n  @OnRequest()\n  async onRequest(): Promise\u003cvoid\u003e {\n    // This code will be invoked before request.\n  }\n\n  @OnEvent('getMe')\n  onGetMe(ctx: ExtractMiddlewareContext\u003cGetMeMiddleware\u003e): void {\n    console.log('\"GetMe\" request triggered', ctx);\n    // This code will be invoked before \"Get me\" request.\n  }\n\n  @OnEvent('updateNewMessage')\n  onNewMessage(\n    ctx: ExtractMiddlewareContext\u003cUpdateNewMessageMiddleware\u003e,\n  ): void {\n    console.log('\"NewMessage\" update triggered', ctx);\n    // This code will be invoked after \"New message\" update.\n  }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsar1008%2Fnestjs-airgram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsar1008%2Fnestjs-airgram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsar1008%2Fnestjs-airgram/lists"}