{"id":15288972,"url":"https://github.com/fvilers/nestjs-algolia","last_synced_at":"2025-08-21T00:30:56.860Z","repository":{"id":34238433,"uuid":"172461320","full_name":"fvilers/nestjs-algolia","owner":"fvilers","description":"The algolia NestJS module based on the official algolia package","archived":false,"fork":false,"pushed_at":"2024-06-18T06:59:05.000Z","size":482,"stargazers_count":18,"open_issues_count":5,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-17T12:48:41.903Z","etag":null,"topics":["algolia","algolia-search","nest","nestjs","nodejs","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/fvilers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"fvilers"}},"created_at":"2019-02-25T08:04:09.000Z","updated_at":"2024-11-07T05:01:07.000Z","dependencies_parsed_at":"2024-06-21T02:12:15.451Z","dependency_job_id":null,"html_url":"https://github.com/fvilers/nestjs-algolia","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":"0.34545454545454546","last_synced_commit":"e964d9fb96c842c7374875ca6e8102c08203e06b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvilers%2Fnestjs-algolia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvilers%2Fnestjs-algolia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvilers%2Fnestjs-algolia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvilers%2Fnestjs-algolia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fvilers","download_url":"https://codeload.github.com/fvilers/nestjs-algolia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230471175,"owners_count":18231193,"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":["algolia","algolia-search","nest","nestjs","nodejs","typescript"],"created_at":"2024-09-30T15:55:08.802Z","updated_at":"2024-12-19T17:08:57.327Z","avatar_url":"https://github.com/fvilers.png","language":"TypeScript","funding_links":["https://github.com/sponsors/fvilers","https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=JZ26X897M9V9L\u0026currency_code=EUR"],"categories":[],"sub_categories":[],"readme":"# nestjs-algolia\n\nThe algolia NestJS module based on the official algolia package\n\n## Support\n\nIf you use and like this library, feel free to support my Open Source projects.\n\n[![donate](https://www.paypalobjects.com/en_US/BE/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=JZ26X897M9V9L\u0026currency_code=EUR)\n\n## How to install\n\n```\nnpm install nestjs-algolia\nnpm install --save-dev @types/algoliasearch\n```\n\nor\n\n```\nyarn add nestjs-algolia\nyarn add -D @types/algoliasearch\n```\n\n## How to use\n\n**Register the module**\n\n```\nimport { AlgoliaModule } from 'nestjs-algolia';\n\n@Module({\n  imports: [\n    AlgoliaModule.register({\n      applicationId: 'YOUR_APPLICATION_ID',\n      apiKey: 'YOUR_API_KEY',\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n**Inject the service**\n\n```\nimport { AlgoliaService } from 'nestjs-algolia';\n\n@Injectable()\nexport class AppService {\n  constructor(private readonly algoliaService: AlgoliaService) {}\n\n  addRecordToIndex(\n    indexName: string,\n    record: any,\n  ): Promise\u003calgoliasearch.Task\u003e {\n    const index = this.algoliaService.initIndex(indexName);\n\n    return index.addObject(record);\n  }\n}\n```\n\n## Async options\n\nQuite often you might want to asynchronously pass your module options instead of passing them beforehand. In such case, use `registerAsync()` method, that provides a couple of various ways to deal with async data.\n\n### Use factory\n\n```\nAlgoliaModule.registerAsync({\n  useFactory: () =\u003e ({\n    applicationId: 'YOUR_APPLICATION_ID',\n    apiKey: 'YOUR_API_KEY',\n  }),\n});\n```\n\nObviously, our factory behaves like every other one (might be `async` and is able to inject dependencies through `inject`).\n\n```\nAlgoliaModule.registerAsync({\n  imports: [ConfigModule],\n  useFactory: async (configService: ConfigService) =\u003e ({\n    applicationId: configService.getString('ALGOLIA_APPLICATION_ID'),\n    apiKey: configService.getString('ALGOLIA_API_KEY'),\n  }),\n  inject: [ConfigService],\n}),\n```\n\n### Use class\n\n```\nAlgoliaModule.registerAsync({\n  useClass: AlgoliaConfigService,\n});\n```\n\nAbove construction will instantiate `AlgoliaConfigService` inside `AlgoliaModule` and will leverage it to create options object.\n\n```\nclass AlgoliaConfigService implements AlgoliaOptionsFactory {\n  createAlgoliaOptions(): AlgoliaModuleOptions {\n    return {\n      applicationId: 'YOUR_APPLICATION_ID',\n      apiKey: 'YOUR_API_KEY',\n    };\n  }\n}\n```\n\n### Use existing\n\n```\nAlgoliaModule.registerAsync({\n  imports: [ConfigModule],\n  useExisting: ConfigService,\n}),\n```\n\nIt works the same as `useClass` with one critical difference - `AlgoliaModule` will lookup imported modules to reuse already created `ConfigService`, instead of instantiating it on its own.\n\n## Versions\n\nUse the following table to match this module with the NestJS version\n\n| nestjs-algolia | nestjs |\n| -------------- | ------ |\n| 1.x            | 5.x    |\n| 2.x            | 6.x    |\n| 3.x            | 7.x    |\n| 4.x            | 8.x    |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvilers%2Fnestjs-algolia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffvilers%2Fnestjs-algolia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvilers%2Fnestjs-algolia/lists"}