![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@luxury-presence/nestjs-plunk
Advanced tools
Plunk module for Nest based on the plunk api package.
Plunk module for Nest based on the plunk api.
$ npm i --save @luxury-presence/nestjs-plunk @nestjs/axios rxjs
Import PlunkModule
:
@Module({
imports: [PlunkModule.register({
apiKey: 'PLUNK_API_KEY',
})],
providers: [...],
})
export class SearchModule {}
Inject PlunkService
:
@Injectable()
export class SearchService {
constructor(private readonly plunkService: PlunkService) {}
async findByAddress(address: string): Promise<Address> {
return this.plunkService.findAddresses(address);
}
async findByParcelId(parcelId: string): Promise<Valuation> {
return this.plunkService.getHomeValuationByParcelId(parcelId);
}
}
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.
1. Use factory
PlunkModule.registerAsync({
useFactory: () => ({
apiKey: 'PLUNK_API_KEY',
})
});
Obviously, our factory behaves like every other one (might be async
and is able to inject dependencies through inject
).
PlunkModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
apiKey: configService.get('PLUNK_API_KEY'),
}),
inject: [ConfigService],
}),
2. Use class
PlunkModule.registerAsync({
useClass: PlunkConfigService
});
Above construction will instantiate PlunkConfigService
inside PlunkModule
and will leverage it to create options object.
class PlunkConfigService implements PlunkModuleOptionsFactory {
createPlunkModuleOptions(): PlunkModuleOptions {
return {
apiKey: 'PLUNK_API_KEY',
};
}
}
3. Use existing
PlunkModule.registerAsync({
imports: [ConfigModule],
useExisting: ConfigService,
}),
It works the same as useClass
with one critical difference - PlunkModule
will lookup imported modules to reuse already created ConfigService
, instead of instantiating it on its own.
FAQs
Plunk module for Nest based on the plunk api package.
We found that @luxury-presence/nestjs-plunk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 62 open source maintainers 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.