🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@luxury-presence/nestjs-plunk

Package Overview
Dependencies
Maintainers
62
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@luxury-presence/nestjs-plunk

Plunk module for Nest based on the plunk api package.

unpublished
latest
npmnpm
Version
3.0.0
Version published
Maintainers
62
Created
Source

Description

Plunk module for Nest based on the plunk api.

Installation

$ npm i --save @luxury-presence/nestjs-plunk @nestjs/axios rxjs

Usage

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);
  }
}

Async options

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.

License

MIT

Keywords

nestjs

FAQs

Package last updated on 28 Mar 2024

Did you know?

Socket

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.

Install

Related posts