{"id":14978670,"url":"https://github.com/overnested/nestjs-octokit","last_synced_at":"2025-10-28T11:31:44.021Z","repository":{"id":38978236,"uuid":"447916698","full_name":"overnested/nestjs-octokit","owner":"overnested","description":"Octokit module for NestJS","archived":true,"fork":false,"pushed_at":"2023-12-15T17:34:46.000Z","size":303,"stargazers_count":12,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T08:46:49.598Z","etag":null,"topics":["github","nest","nest-js","nestjs","octokit","octokit-js"],"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/overnested.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,"publiccode":null,"codemeta":null}},"created_at":"2022-01-14T09:46:54.000Z","updated_at":"2024-12-30T06:36:03.000Z","dependencies_parsed_at":"2023-12-15T18:45:30.284Z","dependency_job_id":null,"html_url":"https://github.com/overnested/nestjs-octokit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-octokit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-octokit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-octokit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-octokit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overnested","download_url":"https://codeload.github.com/overnested/nestjs-octokit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238645848,"owners_count":19506916,"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":["github","nest","nest-js","nestjs","octokit","octokit-js"],"created_at":"2024-09-24T13:58:10.251Z","updated_at":"2025-10-28T11:31:43.710Z","avatar_url":"https://github.com/overnested.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Octokit Module\n\nThis module facilitates the usage of [Octokit](https://github.com/octokit/octokit.js) in [NestJS](https://github.com/nestjs/nest).\n\n## Introduction\n\nOctokit is \"The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno\".\nUsing `nestjs-octokit` you can register the Octokit module and configure it the way NestJS suggests, then inject it as a standard NestJS injectable.\n\n## Installation\n\nOn Yarn:\n\n```shell\nyarn add nestjs-octokit octokit\n```\n\nOn NPM:\n\n```shell\nnpm install nestjs-octokit octokit\n```\n\n## Usage\n\nFirst register the module:\n\n```ts\nimport { OctokitModule } from 'nestjs-octokit';\n\n@Module({\n  imports: [\n    OctokitModule.forRoot({\n      isGlobal: true,\n      octokitOptions: {\n        auth: 'my-github-token',\n      },\n    }),\n    // ...\n  ],\n})\nexport class AppModule {}\n```\n\nOr if want to inject any dependency:\n\n```ts\nimport { OctokitModule } from 'nestjs-octokit';\n\n@Module({\n  imports: [\n    OctokitModule.forRootAsync({\n      isGlobal: true,\n      imports: [ConfigModule],\n      inject: [ConfigService],\n      useFactory: async (configService: ConfigService) =\u003e ({\n        octokitOptions: {\n          auth: configService.get\u003cstring\u003e('GITHUB_AUTH_TOKEN'),\n        },\n      }),\n    }),\n    // ...\n  ],\n})\nexport class AppModule {}\n```\n\nThen you can inject the service:\n\n```ts\nimport { OctokitService } from 'nestjs-octokit';\n\n@Controller()\nexport class SomeController {\n  constructor(private readonly octokitService: OctokitService) {}\n\n  @Get('/')\n  someEndpoint() {\n    const response = await this.octokitService.rest.search.repos({\n      q: 'nest-js',\n    });\n\n    return response.data.items;\n  }\n}\n```\n\n### Short-lived access tokens\n\nIf your access tokens are short-lived, you can configure a [request\nscoped](https://docs.nestjs.com/fundamentals/injection-scopes#provider-scope)\nOctokit provider with an `auth` callback, to renew the Octokits\nand auth tokens:\n\n```ts\nimport { OctokitModule } from 'nestjs-octokit';\nimport { Scope } from '@nestjs/common';\n\n@Module({\n  imports: [\n    OctokitModule.forRootAsync({\n      isGlobal: true,\n      // Set request scope\n      octokitScope: Scope.REQUEST,\n      imports: [TokenModule],\n      inject: [TokenService],\n      useFactory: async (tokenService: TokenService) =\u003e ({\n        octokitOptions: {\n          // `auth` is a callback now. Return short-lived tokens\n          auth: () =\u003e tokenService.produceToken(),\n        },\n      }),\n    }),\n    // ...\n  ],\n})\nexport class AppModule {}\n```\n\n## Plugins\n\nTo use plugins:\n\n```ts\nimport { OctokitModule } from 'nestjs-octokit';\nimport { throttling } from '@octokit/plugin-throttling';\n\n@Module({\n  imports: [\n    OctokitModule.forRoot({\n      isGlobal: true,\n      plugins: [throttling], // Pass them here\n      octokitOptions: {\n        // Plugin options:\n        throttle: {\n          onRateLimit: (retryAfter, options, octokit) =\u003e {\n            octokit.log.warn(\n              `Request quota exhausted for request ${options.method} ${options.url}`\n            );\n          },\n          onAbuseLimit: (retryAfter, options, octokit) =\u003e {\n            octokit.log.warn(\n              `Abuse detected for request ${options.method} ${options.url}`\n            );\n          },\n        },\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovernested%2Fnestjs-octokit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovernested%2Fnestjs-octokit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovernested%2Fnestjs-octokit/lists"}