Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@curo__/nestjs-algolia
Advanced tools
The algolia NestJS module based on the official algolia package by @fvilers
npm install @curo__/nestjs-algolia
Register the module
import { AlgoliaModule } from 'nestjs-algolia';
@Module({
imports: [
AlgoliaModule.register({
applicationId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_API_KEY',
}),
],
})
export class AppModule {}
Inject the service
import { AlgoliaService } from 'nestjs-algolia';
@Injectable()
export class AppService {
constructor(private readonly algoliaService: AlgoliaService) {}
addRecordToIndex(
indexName: string,
record: any,
): Promise<algoliasearch.Task> {
const index = this.algoliaService.initIndex(indexName);
return index.addObject(record);
}
}
Quite 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.
AlgoliaModule.registerAsync({
useFactory: () => ({
applicationId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_API_KEY',
}),
});
Obviously, our factory behaves like every other one (might be async
and is able to inject dependencies through inject
).
AlgoliaModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
applicationId: configService.getString('ALGOLIA_APPLICATION_ID'),
apiKey: configService.getString('ALGOLIA_API_KEY'),
}),
inject: [ConfigService],
}),
AlgoliaModule.registerAsync({
useClass: AlgoliaConfigService,
});
Above construction will instantiate AlgoliaConfigService
inside AlgoliaModule
and will leverage it to create options object.
class AlgoliaConfigService implements AlgoliaOptionsFactory {
createAlgoliaOptions(): AlgoliaModuleOptions {
return {
applicationId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_API_KEY',
};
}
}
AlgoliaModule.registerAsync({
imports: [ConfigModule],
useExisting: ConfigService,
}),
It 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.
Use the following table to match this module with the NestJS version
@curo__/nestjs-algolia | nestjs |
---|---|
1.x | 10.x |
FAQs
The algolia NestJS module based on the official algolia package
The npm package @curo__/nestjs-algolia receives a total of 10 weekly downloads. As such, @curo__/nestjs-algolia popularity was classified as not popular.
We found that @curo__/nestjs-algolia demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.