Last active
April 24, 2019 13:39
-
-
Save martijnvdbrug/7ec39bea7bd94ce831665f955f394ba9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable, Module} from '@nestjs/common'; | |
import {NestFactory} from '@nestjs/core'; | |
@Injectable() | |
export class SlowService { | |
constructor() { | |
console.log(`Created SlowService`); | |
} | |
} | |
@Injectable() | |
export class DbService { | |
constructor() { | |
console.log(`Created DbService`); | |
} | |
} | |
@Module({ | |
imports: [], | |
providers: [SlowService, DbService], | |
exports: [SlowService, DbService] | |
}) | |
export class BaseModule {} | |
@Injectable() | |
export class OtherService { | |
constructor(private service: DbService) { | |
console.log(`Created OtherService with dependency DbService`); | |
} | |
} | |
@Module({ | |
imports: [BaseModule], | |
providers: [OtherService], | |
}) | |
export class OtherModule {} | |
@Module({ | |
imports: [ | |
BaseModule, | |
OtherModule | |
], | |
}) | |
export class AppModule {} | |
NestFactory.createApplicationContext(AppModule).then((app) => console.log('🥑 context created')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment