-
Notifications
You must be signed in to change notification settings - Fork 0
Quick start
Aleksandr Melnik edited this page Oct 18, 2024
·
3 revisions
Create a module and a provider using decorators.
import { NsModule, Injectable, Inject } from '@nexus-ioc/core';
@Injectable()
class DependencyService {
public readonly name = 'World';
}
@Injectable()
export class AppService {
constructor(
@Inject(DependencyService)
private readonly dependencyService: DependencyService,
) {
}
getHello(): string {
return `Hello ${this.dependencyService.name}!`;
}
}
@NsModule({
providers: [AppService, DependencyService],
})
export class AppModule {}
Create and bootstrap your application.
import { NexusApplicationsServer } from '@nexus-ioc/core/dist/server';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NexusApplicationsServer.create(AppModule)
.bootstrap();
const appService = app.get<AppService>(AppService);
console.log(appService.getHello());
}
bootstrap();