ad/src/main.ts

31 lines
920 B
TypeScript
Raw Normal View History

2023-05-03 11:43:21 +00:00
import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { join } from 'path';
2023-05-03 11:43:21 +00:00
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.TCP,
});
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.GRPC,
options: {
package: ['ad', 'health'],
protoPath: [
2023-06-21 09:50:36 +00:00
join(__dirname, 'modules/ad/interface/grpc-controllers/ad.proto'),
join(
__dirname,
'modules/health/interface/grpc-controllers/health.proto',
),
],
2023-06-29 08:29:33 +00:00
url: `${process.env.SERVICE_URL}:${process.env.SERVICE_PORT}`,
loader: { keepCase: true },
},
});
await app.startAllMicroservices();
await app.listen(process.env.HEALTH_SERVICE_PORT);
2023-05-03 11:43:21 +00:00
}
bootstrap();