{"id":22330115,"url":"https://github.com/oblakstudio/nestjs-puppeteer","last_synced_at":"2025-07-29T19:32:19.786Z","repository":{"id":144719564,"uuid":"616056231","full_name":"oblakstudio/nestjs-puppeteer","owner":"oblakstudio","description":"nestjs-puppeteer — Puppeteer module for Nest framework (node.js)","archived":false,"fork":false,"pushed_at":"2024-12-03T11:49:15.000Z","size":384,"stargazers_count":14,"open_issues_count":14,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-03T12:34:46.818Z","etag":null,"topics":["module","nestjs","nestjs-module","puppeteer","puppeteer-extra"],"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/oblakstudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-19T13:45:41.000Z","updated_at":"2024-11-03T16:14:21.000Z","dependencies_parsed_at":"2023-10-15T14:49:59.202Z","dependency_job_id":"f9f42f61-cbd3-4289-a5b8-b8c1bec93129","html_url":"https://github.com/oblakstudio/nestjs-puppeteer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblakstudio%2Fnestjs-puppeteer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblakstudio%2Fnestjs-puppeteer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblakstudio%2Fnestjs-puppeteer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblakstudio%2Fnestjs-puppeteer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oblakstudio","download_url":"https://codeload.github.com/oblakstudio/nestjs-puppeteer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227922135,"owners_count":17840709,"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":["module","nestjs","nestjs-module","puppeteer","puppeteer-extra"],"created_at":"2024-12-04T04:06:08.367Z","updated_at":"2025-07-29T19:32:19.741Z","avatar_url":"https://github.com/oblakstudio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# nestjs-puppeteer\nPuppeteer module for Nest framework (node.js)\n\n[![npm](https://img.shields.io/npm/v/nestjs-puppeteer?logo=npm)](https://npmjs.com/package/nestjs-puppeteer)\n![Puppeter Peer Dep](https://img.shields.io/npm/dependency-version/nestjs-puppeteer/peer/@nestjs/core?logo=nestjs\u0026logoColor=E42844)\n![NestJS Peer Dep](https://img.shields.io/npm/dependency-version/nestjs-puppeteer/peer/puppeteer?logo=puppeteer\u0026logoColor=%23fff)  \n![npm](https://img.shields.io/npm/dm/nestjs-puppeteer)\n![GitHub](https://img.shields.io/github/license/oblakstudio/nestjs-puppeteer)\n![Codecov](https://img.shields.io/codecov/c/github/oblakstudio/nestjs-puppeteer?logo=codecov\u0026color=%23F01F7A)\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\n\n\u003c/div\u003e\n\nHeadless Chrome provider for [NestJS](https://nestjs.com/), enabling easy integration of Puppeteer into your application.\n\n\u003e [!IMPORTANT]\n\u003e Chrome introduces the _\"New Headless\"_ mode in version 112. Most of `puppeteer-extra` plugins are **NOT COMPATIBLE** with this mode. If you want to use `puppeteer-extra` plugins, you need to define `headless: true` in the module configuration.\n\u003e\n\u003e You can read more about the new headless mode [here](https://developer.chrome.com/docs/chromium/new-headless).\n\n## Installation\n\nTo begin using it, we first install the required dependencies.\n\n```sh\n$ npm install --save nestjs-puppeteer puppeteer-extra puppeteer\n```\n## Usage\n\nOnce the installation process is complete we can import the ``PuppeteerModule`` into the root ``AppModule``\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { PuppeteerModule } from 'nestjs-puppeteer';\n\n@Module({\n  imports: [\n    PuppeteerModule.forRoot({ headless: 'new' }),\n  ],\n})\nexport class AppModule {}\n```\n\nThe ``forRoot()`` method supports all the configuration properties exposed by the ``PuppeteerNodeLaunchOptions`` object used by the ``puppeteer.launch()`` method. There are several extra configuration properties described below.\n\n\n| Property  | Description |\n| ------------- | ------------- |\n| ``name``  | Browser name  |\n| ``plugins``  | An array of ``puppeteer-extra`` plugins  |\n| ``isGlobal`` | Should the module be registered in the global context |\n| ``headless`` | `new` for the [New Headless](https://developer.chrome.com/docs/chromium/new-headless) mode, or `true`/`false`  |\n\nOnce this is done, the Puppeteer ``Browser`` instance will be available for injection in any of the providers in the application.\n\n```ts\nimport { Browser } from 'puppeteer';\n\n@Module({\n  imports: [\n    PuppeteerModule.forRoot({ headless: 'new' }),\n  ],\n})\nexport class AppModule {\n  constructor(@InjectBrowser() private readonly browser: Browser) {}\n}\n```\n\nIf you used the name option when registering the module, you can inject the browser by name.\n\n### ForFeature\n\nAfter module registration, we can register specific pages for injection.\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { PuppeteerModule } from 'nestjs-puppeteer';\n\n@Module({\n  imports: [\n    PuppeteerModule.forRoot({ headless: 'new' }),\n    PuppeteerModule.forFeature(['page1', 'page2']),\n  ],\n})\nexport class AppModule {}\n```\n\nOnce this is done the ``Page`` instance will be available for injection in any of the providers in the module.\n\n```ts\nimport { Page } from 'puppeteer';\n\n@Module({\n  imports: [\n    PuppeteerModule.forRoot({ headless: 'new' }),\n    PuppeteerModule.forFeature(['page1', 'page2']),\n  ],\n})\nexport class AppModule {\n  constructor(@InjectPage('page1') private readonly page1: Page) {}\n}\n```\n\n\n### Async configuration\n\nYou may want to pass your repository module options asynchronously instead of statically. In this case, use the ``forRootAsync()`` method, which provides several ways to deal with async configuration.\n\nOne approach is to use a factory function:\n\n```ts\nPuppeteerModule.forRootAsync({\n  useFactory: () =\u003e ({\n    headless: false,\n  }),\n})\n```\n\nOur factory behaves like any other asynchronous provider (e.g., it can be ``async`` and it's able to inject dependencies through ``inject``).\n\n```ts\nPuppeteerModule.forRootAsync({\n  imports: [ConfigModule],\n  useFactory: async (configService: ConfigService) =\u003e ({\n    headless: configService.isHeadless,\n  }),\n  inject: [ConfigService],\n})\n```\n\nAlternatively you can use the ``useClass`` syntax:\n\n```ts\nPuppeteerModule.forRootAsync({\n  useClass: PuppeteerConfigService,\n})\n```\nThe construction above will instantiate ``PuppeteerConfigService`` inside ``PuppeteerModule`` and use it to provide an options object by calling ``createPuppeteerOptions()``.  \nNote that this means that the ``PuppeteerConfigService`` has to implement the ``PuppeteerOptionsFactory`` interface, as shown below:\n\n```ts\n@Injectable()\nclass PuppeteerConfigService implements PuppeteerOptionsFactory {\n  createPuppeteerOptions(): PuppeteerNodeLaunchOptions {\n    return {\n      headless: 'new',\n    };\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foblakstudio%2Fnestjs-puppeteer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foblakstudio%2Fnestjs-puppeteer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foblakstudio%2Fnestjs-puppeteer/lists"}