territory/src/main.ts

28 lines
894 B
TypeScript
Raw Normal View History

2023-02-06 12:50:07 +00:00
import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { join } from 'path';
import { AppModule } from './app.module';
async function bootstrap() {
2023-04-04 08:52:30 +00:00
const app = await NestFactory.create(AppModule);
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.TCP,
});
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.GRPC,
options: {
package: ['territory', 'health'],
protoPath: [
join(__dirname, 'modules/territory/adapters/primaries/territory.proto'),
join(__dirname, 'modules/health/adapters/primaries/health.proto'),
],
url: process.env.SERVICE_URL + ':' + process.env.SERVICE_PORT,
loader: { keepCase: true },
2023-02-06 12:50:07 +00:00
},
2023-04-04 08:52:30 +00:00
});
await app.startAllMicroservices();
await app.listen(process.env.HEALTH_SERVICE_PORT);
2023-02-06 12:50:07 +00:00
}
bootstrap();