
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@luxury-presence/nestjs-liveby
Advanced tools
LiveBy module for for Nest based on the LiveBy's api.
$ npm i --save @luxury-presence/nestjs-liveby @nestjs/axios rxjs
Import LiveByModule
:
@Module({
imports: [LiveByModule.register({
apiKey: 'LIVEBY_API_KEY',
clientId: 'LIVEBY_CLIENT_ID',
baseApi: 'LIVEBY_BASE_API',
})],
providers: [...],
})
export class SearchModule {}
Inject LiveByService
:
@Injectable()
export class SearchService {
constructor(private readonly liveByService: LiveByService) {}
async findWalkScores(lat: number, lon: number): Promise<WalkScores> {
return this.liveByService.findWalkScores(lat, lon);
}
async findAreaOfInterest(
lat: number,
lon: number
): Promise<AreaOfInterest[]> {
return this.liveByService.findAreasOfInterest(lat, lon);
}
}
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
LiveByModule.registerAsync({
useFactory: () => ({
apiKey: 'LIVEBY_API_KEY',
clientId: 'LIVEBY_CLIENT_ID',
baseApi: 'LIVEBY_BASE_API',
}),
});
Obviously, our factory behaves like every other one (might be async
and is able to inject dependencies through inject
).
LiveByModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
apiKey: configService.get('LIVEBY_API_KEY'),
clientId: configService.get('LIVEBY_CLIENT_ID'),
baseApi: configService.get('LIVEBY_BASE_API'),
}),
inject: [ConfigService],
}),
2. Use class
LiveByModule.registerAsync({
useClass: LiveByConfigService,
});
Above construction will instantiate LiveByConfigService
inside LiveByModule
and will leverage it to create options object.
class LiveByConfigService implements LiveByModuleOptionsFactory {
createLiveByModuleOptions(): LiveByModuleOptions {
return {
apiKey: 'LIVEBY_API_KEY',
clientId: 'LIVEBY_CLIENT_ID',
baseApi: 'LIVEBY_BASE_API',
};
}
}
3. Use existing
LiveByModule.registerAsync({
imports: [ConfigModule],
useExisting: ConfigService,
}),
It works the same as useClass
with one critical difference - LiveByModule
will lookup imported modules to reuse already created ConfigService
, instead of instantiating it on its own.
FAQs
A LiveBy API client module for NestJS.
We found that @luxury-presence/nestjs-liveby demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 58 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.