Skip to content

Instantly share code, notes, and snippets.

@martijnvdbrug
Last active April 24, 2019 13:39
Show Gist options
  • Save martijnvdbrug/7ec39bea7bd94ce831665f955f394ba9 to your computer and use it in GitHub Desktop.
Save martijnvdbrug/7ec39bea7bd94ce831665f955f394ba9 to your computer and use it in GitHub Desktop.
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