
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
nestjs-custom-injector
Advanced tools
npm i --save nestjs-custom-injector
https://nestjs-custom-injector.site15.ru/api - Demo application with nestjs-custom-injector. https://github.com/EndyKaufman/nestjs-custom-injector-example - Example generated with nest cli for "Usage" sections in readme.
Create common interface with token in animal-provider.interface.ts
export const ANIMAL_PROVIDER = 'ANIMAL_PROVIDER';
export interface AnimalProviderInteface {
type: string;
say(): string;
}
Create first type of logic for cats in animal-cats.service.ts
import { Injectable } from '@nestjs/common';
import { AnimalProviderInteface } from './animal-provider.interface';
@Injectable()
export class AnimalCatsService implements AnimalProviderInteface {
type = 'cat';
say(): string {
return 'meow';
}
}
Create second type of logic for dogs in animal-dogs.service.ts
import { Injectable } from '@nestjs/common';
import { AnimalProviderInteface } from './animal-provider.interface';
@Injectable()
export class AnimalDogsService implements AnimalProviderInteface {
type = 'dog';
say(): string {
return 'woof';
}
}
Create controller animals.controller.ts
import { Controller, Get, Query } from '@nestjs/common';
import { CustomInject } from 'nestjs-custom-injector';
import {
AnimalProviderInteface,
ANIMAL_PROVIDER,
} from './animal-provider.interface';
@Controller('animals')
export class AnimalsController {
@CustomInject(ANIMAL_PROVIDER, { multi: true })
private animalProviders!: AnimalProviderInteface[];
@Get('animal-types')
animalTypes() {
return this.animalProviders.map((animalProvider) => animalProvider.type);
}
@Get('what-says-animals')
whatSaysAnimals() {
return this.animalProviders.map(
(animal) => `${animal.type} say ${animal.say()}`
);
}
@Get('who-say')
whoSay(@Query('voice') voice: string) {
const animal = this.animalProviders.find(
(animal) => animal.say() === voice
);
if (!animal) {
return { error: `I don't know who say ${voice}` };
}
return `${animal.type} say ${animal.say()}`;
}
}
Append all logic to main app module app.module.ts
import { Module } from '@nestjs/common';
import { CustomInjectorModule } from 'nestjs-custom-injector';
import { AnimalCatsService } from './animal-cats.service';
import { AnimalDogsService } from './animal-dogs.service';
import { AnimalsController } from './animals.controller';
@Module({
...
imports: [
...
CustomInjectorModule.forRoot(),
CustomInjectorModule.forFeature({
providers: [{ provide: ANIMAL_PROVIDER, useClass: AnimalCatsService }],
}),
CustomInjectorModule.forFeature({
providers: [
{ provide: ANIMAL_PROVIDER, useValue: new AnimalDogsService() },
],
}),
...
],
controllers: [
...
AnimalsController
...
]
...
})
export class AppModule {}
MIT
FAQs
Custom injecting logic for NestJS with support multi providing
The npm package nestjs-custom-injector receives a total of 44 weekly downloads. As such, nestjs-custom-injector popularity was classified as not popular.
We found that nestjs-custom-injector 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.