https://github.com/devcsrj/nestjs-autoconfigure
spring boot's auto-configuration powers as a nestjs module
https://github.com/devcsrj/nestjs-autoconfigure
Last synced: 6 months ago
JSON representation
spring boot's auto-configuration powers as a nestjs module
- Host: GitHub
- URL: https://github.com/devcsrj/nestjs-autoconfigure
- Owner: devcsrj
- License: apache-2.0
- Created: 2023-08-09T10:18:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-09T10:32:55.000Z (over 2 years ago)
- Last Synced: 2025-01-14T08:23:50.078Z (about 1 year ago)
- Language: TypeScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# nestjs-autoconfigure
A [nestjs module](https://docs.nestjs.com/modules) for autoconfiguring other nestjs modules.
This idea is borrowed from [spring-boot-autoconfigure](https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-auto-configuration).
| This project is still experimental. |
|-------------------------------------|
## Idea
Given a generic nestjs `AppModule`:
```ts
import { Module } from '@nestjs/common';
import { AutoConfigurationModule } from '@devcsrj/nestjs-autoconfigure';
@Module({
imports: [AutoConfigurationModule],
})
export class AppModule {}
```
It will automatically populate the nestjs application context with providers according to
various conditions such as:
- Existence of a property (`e.g.: database.url`)
- Existence of a dependency (`e.g.: @nestjs/typeorm, typeorm`)
- Lack of a provider (`e.g.: DataSource`)