Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/incetarik/nestjs-create-param-decorator-with-injections
A function that is similar to createParamDecorator while allowing service injections.
https://github.com/incetarik/nestjs-create-param-decorator-with-injections
createparamdecorator decorator dependency-injection nestjs
Last synced: about 2 months ago
JSON representation
A function that is similar to createParamDecorator while allowing service injections.
- Host: GitHub
- URL: https://github.com/incetarik/nestjs-create-param-decorator-with-injections
- Owner: incetarik
- License: mpl-2.0
- Created: 2022-07-08T20:55:09.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-07-17T09:26:27.000Z (over 1 year ago)
- Last Synced: 2024-11-14T14:52:50.245Z (about 2 months ago)
- Topics: createparamdecorator, decorator, dependency-injection, nestjs
- Language: TypeScript
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# nestjs-create-param-decorator-with-injections
A library providing service injections through an object that will be used in
the `createParamDecorator` like function.# Example
```ts
import { createParamDecoratorWithInjections } from 'nestjs-create-param-decorator-with-injections'const UserSettings = createParamDecoratorWithInjections(async (_data, _ctx, { user, db }) => {
const settings = await db.settings.where({ owner: user })
return settings
}, { user: UserService, db: DatabaseService }) // Services to inject@Injectable()
class AppService {
getUserTheme(@UserSettings() settings: UserSettings) {
return settings
}
}
```The `createParamDecoratorWithInjections` function is very similar to
`createParamDecorator` but the function it takes also have the two more
arguments where the third argument is providing the services that are injected
and the fourth one contains extra data such as the initial data passed to the
decorator.# Support
To support the project, you can send donations to following addresses:```md
- Bitcoin : bc1qtut2ss8udkr68p6k6axd0na6nhvngm5dqlyhtn
- Bitcoin Cash: qzmmv43ztae0tfsjx8zf4wwnq3uk6k7zzgcfr9jruk
- Ether : 0xf542BED91d0218D9c195286e660da2275EF8eC84
```