Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vassourita/nestjs-provider-helper
Opinionated way to manage your NestJS dependency injection
https://github.com/vassourita/nestjs-provider-helper
dependency-injection dependency-inversion helper liskov-substitution-principle nest nestjs provider solid typescript
Last synced: about 2 months ago
JSON representation
Opinionated way to manage your NestJS dependency injection
- Host: GitHub
- URL: https://github.com/vassourita/nestjs-provider-helper
- Owner: vassourita
- License: mit
- Created: 2020-12-10T23:49:21.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-11T01:48:54.000Z (about 4 years ago)
- Last Synced: 2024-10-12T18:21:52.619Z (3 months ago)
- Topics: dependency-injection, dependency-inversion, helper, liskov-substitution-principle, nest, nestjs, provider, solid, typescript
- Language: TypeScript
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NestJS Provider Helper
This helper creates a provider structure for NestJS modules in a opinionated way, where every provider must be a implementation of a interface
The ProviderHelper class exposes static methods to create ClassProviders, FactoryProviders, ExistingProviders and ValueProviders
### Installing
```sh
npm install nestjs-provider-helper
# or
yarn add nestjs-provider-helper
```### ClassProvider example
```ts
@Module({
controllers: [CatsController],
providers: [
ProviderHelper.createClassProvider('ICatService', CatService),
ProviderHelper.createClassProvider('ICatRepository', CatRepository),
],
})
export class CatsModule {}
```### FactoryProvider example
```ts
@Module({
controllers: [CatsController],
providers: [
ProviderHelper.createClassProvider('ICatRepository', CatRepository),
ProviderHelper.createFactoryProvider(
'ICatService',
(ICatRepository: catRepository) => new CatService(catRepository),
['ICatRepository']
),
],
})
export class CatsModule {}
```