-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
/
main.ts
27 lines (25 loc) · 903 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { AppModule } from './app.module';
async function bootstrap() {
/**
* This example contains a hybrid application (HTTP + TCP)
* You can switch to a microservice with NestFactory.createMicroservice() as follows:
*
* const app = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule, {
* transport: Transport.TCP,
* options: { retryAttempts: 5, retryDelay: 3000 },
* });
* await app.listen();
*
*/
const app = await NestFactory.create(AppModule);
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.TCP,
options: { retryAttempts: 5, retryDelay: 3000 },
});
await app.startAllMicroservices();
await app.listen(3001);
console.log(`Application is running on: ${await app.getUrl()}`);
}
bootstrap();