New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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

@luxury-presence/nestjs-plunk

Plunk module for Nest based on the plunk api package.

  • 3.0.0
  • unpublished
  • latest
  • npm
  • Socket score

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc