2023-05-03 11:43:21 +00:00
|
|
|
import { NestFactory } from '@nestjs/core';
|
2023-05-03 15:31:26 +00:00
|
|
|
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
|
|
|
import { join } from 'path';
|
2023-05-03 11:43:21 +00:00
|
|
|
import { AppModule } from './app.module';
|
2023-10-17 09:27:52 +00:00
|
|
|
import { HEALTH_SERVICE_NAME, SERVICE_NAME } from './app.constants';
|
2023-05-03 11:43:21 +00:00
|
|
|
|
|
|
|
async function bootstrap() {
|
|
|
|
const app = await NestFactory.create(AppModule);
|
2023-05-03 15:31:26 +00:00
|
|
|
app.connectMicroservice<MicroserviceOptions>({
|
|
|
|
transport: Transport.TCP,
|
|
|
|
});
|
|
|
|
app.connectMicroservice<MicroserviceOptions>({
|
|
|
|
transport: Transport.GRPC,
|
|
|
|
options: {
|
2023-10-17 09:27:52 +00:00
|
|
|
package: [SERVICE_NAME, HEALTH_SERVICE_NAME],
|
2023-05-03 15:31:26 +00:00
|
|
|
protoPath: [
|
2023-06-21 09:50:36 +00:00
|
|
|
join(__dirname, 'modules/ad/interface/grpc-controllers/ad.proto'),
|
2023-07-18 15:24:48 +00:00
|
|
|
join(__dirname, 'health.proto'),
|
2023-05-03 15:31:26 +00:00
|
|
|
],
|
2023-06-29 08:29:33 +00:00
|
|
|
url: `${process.env.SERVICE_URL}:${process.env.SERVICE_PORT}`,
|
2023-07-25 14:52:41 +00:00
|
|
|
loader: { keepCase: true, enums: String },
|
2023-05-03 15:31:26 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await app.startAllMicroservices();
|
2023-10-16 15:11:20 +00:00
|
|
|
await app.listen(process.env.HEALTH_SERVICE_PORT as unknown as number);
|
2023-05-03 11:43:21 +00:00
|
|
|
}
|
|
|
|
bootstrap();
|