Added nestjs microservice

This commit is contained in:
Alex Tran 2022-03-25 15:26:55 -05:00
parent 5c9d3cd08b
commit fe693db84f
16 changed files with 6821 additions and 1 deletions

View file

@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}

View file

@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

View file

@ -0,0 +1,9 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
console.log('Hello World 123');
return 'Hello World!';
}
}

15
microservices/src/main.ts Normal file
View file

@ -0,0 +1,15 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { AppService } from './app.service';
async function bootstrap() {
const app = await NestFactory.createApplicationContext(AppModule);
const appService = app.get(AppService);
appService.getHello();
await app.close();
}
bootstrap();