auth/src/main.ts

43 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-12-15 09:59:45 +00:00
import { NestFactory } from '@nestjs/core';
2022-12-16 15:46:14 +00:00
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { join } from 'path';
2022-12-15 09:59:45 +00:00
import { AppModule } from './app.module';
2023-10-17 12:48:05 +00:00
import {
GRPC_AUTHENTICATION_PACKAGE_NAME,
GRPC_AUTHORIZATION_PACKAGE_NAME,
GRPC_HEALTH_PACKAGE_NAME,
} from './app.constants';
2022-12-15 09:59:45 +00:00
async function bootstrap() {
2023-04-04 08:14:41 +00:00
const app = await NestFactory.create(AppModule);
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.TCP,
});
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.GRPC,
options: {
2023-10-17 12:48:05 +00:00
package: [
GRPC_AUTHENTICATION_PACKAGE_NAME,
GRPC_AUTHORIZATION_PACKAGE_NAME,
GRPC_HEALTH_PACKAGE_NAME,
],
2023-04-04 08:14:41 +00:00
protoPath: [
join(
__dirname,
2023-07-06 14:23:18 +00:00
'modules/authentication/interface/grpc-controllers/authentication.proto',
2023-04-04 08:14:41 +00:00
),
join(
__dirname,
2023-07-12 08:39:55 +00:00
'modules/authorization/interface/grpc-controllers/authorization.proto',
),
2023-07-17 14:52:35 +00:00
join(__dirname, 'health.proto'),
2023-04-04 08:14:41 +00:00
],
2023-10-17 12:48:05 +00:00
url: `${process.env.SERVICE_URL}:${process.env.SERVICE_PORT}`,
2023-04-04 08:14:41 +00:00
loader: { keepCase: true, enums: String },
2022-12-16 15:46:14 +00:00
},
2023-04-04 08:14:41 +00:00
});
await app.startAllMicroservices();
2023-10-17 12:48:05 +00:00
await app.listen(process.env.HEALTH_SERVICE_PORT as unknown as number);
2022-12-15 09:59:45 +00:00
}
bootstrap();