use health package; use message broker package; add logger logs management
This commit is contained in:
parent
9a8683aa9d
commit
8eaa56d32b
|
@ -1,7 +1,8 @@
|
|||
# SERVICE
|
||||
SERVICE_URL=0.0.0.0
|
||||
SERVICE_PORT=5099
|
||||
HEALTH_SERVICE_PORT=6099
|
||||
|
||||
# RABBIT MQ
|
||||
RMQ_URI=amqp://v3-broker:5672
|
||||
RMQ_EXCHANGE=mobicoop
|
||||
MESSAGE_BROKER_URI=amqp://v3-broker:5672
|
||||
MESSAGE_BROKER_EXCHANGE=mobicoop
|
||||
|
|
|
@ -13,7 +13,8 @@ services:
|
|||
- .env
|
||||
command: npm run start:dev
|
||||
ports:
|
||||
- '${SERVICE_PORT:-5099}:${SERVICE_PORT:-5099}'
|
||||
- ${SERVICE_PORT:-5099}:${SERVICE_PORT:-5099}
|
||||
- ${HEALTH_SERVICE_PORT:-6099}:${HEALTH_SERVICE_PORT:-6099}
|
||||
networks:
|
||||
v3-network:
|
||||
aliases:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src"
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"assets": ["**/*.proto"],
|
||||
"watchAssets": true
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,6 +25,10 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@golevelup/nestjs-rabbitmq": "^3.4.0",
|
||||
"@grpc/grpc-js": "^1.8.14",
|
||||
"@grpc/proto-loader": "^0.7.6",
|
||||
"@mobicoop/ddd-library": "^0.3.0",
|
||||
"@mobicoop/health-module": "^2.0.0",
|
||||
"@nestjs/axios": "^2.0.0",
|
||||
"@nestjs/common": "^9.0.0",
|
||||
"@nestjs/config": "^2.2.0",
|
||||
|
|
|
@ -1,13 +1,35 @@
|
|||
import { HealthModule } from '@modules/health/health.module';
|
||||
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
||||
import { HealthModule, HealthModuleOptions } from '@mobicoop/health-module';
|
||||
import { LoggerModule } from '@modules/logger/logger.module';
|
||||
import { MESSAGE_PUBLISHER } from '@modules/messager/messager.di-tokens';
|
||||
import { MessagerModule } from '@modules/messager/messager.module';
|
||||
import { HttpModule } from '@nestjs/axios';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
HttpModule,
|
||||
HealthModule.forRootAsync({
|
||||
imports: [LoggerModule, MessagerModule],
|
||||
inject: [MESSAGE_PUBLISHER],
|
||||
useFactory: async (
|
||||
messagePublisher: MessagePublisherPort,
|
||||
): Promise<HealthModuleOptions> => ({
|
||||
serviceName: 'logger',
|
||||
criticalLoggingKey: 'logging.logger.health.crit',
|
||||
checkUrls: [
|
||||
{
|
||||
name: 'google',
|
||||
url: 'https://www.google.fr',
|
||||
},
|
||||
],
|
||||
messagePublisher,
|
||||
}),
|
||||
}),
|
||||
LoggerModule,
|
||||
HealthModule,
|
||||
MessagerModule,
|
||||
],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package health;
|
||||
|
||||
|
||||
service Health {
|
||||
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
|
||||
}
|
||||
|
||||
message HealthCheckRequest {
|
||||
string service = 1;
|
||||
}
|
||||
|
||||
message HealthCheckResponse {
|
||||
enum ServingStatus {
|
||||
UNKNOWN = 0;
|
||||
SERVING = 1;
|
||||
NOT_SERVING = 2;
|
||||
}
|
||||
ServingStatus status = 1;
|
||||
string message = 2;
|
||||
}
|
20
src/main.ts
20
src/main.ts
|
@ -1,10 +1,24 @@
|
|||
import { ConfigService } from '@nestjs/config';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||||
import { join } from 'path';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const configService: ConfigService = app.get(ConfigService);
|
||||
await app.listen(configService.get<number>('SERVICE_PORT'));
|
||||
app.connectMicroservice<MicroserviceOptions>({
|
||||
transport: Transport.TCP,
|
||||
});
|
||||
app.connectMicroservice<MicroserviceOptions>({
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
package: ['health'],
|
||||
protoPath: [join(__dirname, 'health.proto')],
|
||||
url: `${process.env.SERVICE_URL}:${process.env.SERVICE_PORT}`,
|
||||
loader: { keepCase: true },
|
||||
},
|
||||
});
|
||||
|
||||
await app.startAllMicroservices();
|
||||
await app.listen(process.env.HEALTH_SERVICE_PORT);
|
||||
}
|
||||
bootstrap();
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { TerminusModule } from '@nestjs/terminus';
|
||||
import { HttpModule } from '@nestjs/axios';
|
||||
import { HealthController } from './interface/http-controllers/health.http.controller';
|
||||
|
||||
@Module({
|
||||
imports: [TerminusModule, HttpModule],
|
||||
controllers: [HealthController],
|
||||
})
|
||||
export class HealthModule {}
|
|
@ -1,22 +0,0 @@
|
|||
import { Controller, Get } from '@nestjs/common';
|
||||
import {
|
||||
HealthCheckService,
|
||||
HttpHealthIndicator,
|
||||
HealthCheck,
|
||||
} from '@nestjs/terminus';
|
||||
|
||||
@Controller('health')
|
||||
export class HealthController {
|
||||
constructor(
|
||||
private health: HealthCheckService,
|
||||
private http: HttpHealthIndicator,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@HealthCheck()
|
||||
check() {
|
||||
return this.health.check([
|
||||
() => this.http.pingCheck('google.fr', 'https://google.fr'),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import { level } from '../level.enum';
|
||||
import loggerOptions from '../logger.options';
|
||||
|
||||
@Controller()
|
||||
export class AdController {
|
||||
export class AdMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import loggerOptions from '../logger.options';
|
||||
import { level } from '../level.enum';
|
||||
|
||||
@Controller()
|
||||
export class AdminApiController {
|
||||
export class AdminApiMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import loggerOptions from '../logger.options';
|
||||
import { level } from '../level.enum';
|
||||
|
||||
@Controller()
|
||||
export class AuthController {
|
||||
export class AuthMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import loggerOptions from '../logger.options';
|
||||
import { level } from '../level.enum';
|
||||
|
||||
@Controller()
|
||||
export class ConfigurationController {
|
||||
export class ConfigurationMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import loggerOptions from '../logger.options';
|
||||
import { level } from '../level.enum';
|
||||
|
||||
@Controller()
|
||||
export class GatewayApiController {
|
||||
export class GatewayApiMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -0,0 +1,22 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import loggerOptions from '../logger.options';
|
||||
import { level } from '../level.enum';
|
||||
|
||||
export class LoggerMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
@RabbitSubscribe({
|
||||
name: 'loggingLoggerHealthCrit',
|
||||
})
|
||||
public async loggerHealthCriticalHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('logger', level.crit, 'critical', 'health'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import { level } from '../level.enum';
|
||||
import loggerOptions from '../logger.options';
|
||||
|
||||
@Controller()
|
||||
export class MatcherController {
|
||||
export class MatcherMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import loggerOptions from '../logger.options';
|
||||
import { level } from '../level.enum';
|
||||
|
||||
@Controller()
|
||||
export class TerritoryController {
|
||||
export class TerritoryMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -1,12 +1,11 @@
|
|||
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
|
||||
import { Controller, Inject } from '@nestjs/common';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { Logger } from 'winston';
|
||||
import loggerOptions from '../logger.options';
|
||||
import { level } from '../level.enum';
|
||||
|
||||
@Controller()
|
||||
export class UserController {
|
||||
export class UserMessageHandler {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
|
@ -1,297 +1,36 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { Module, Provider } from '@nestjs/common';
|
||||
import { WinstonModule } from 'nest-winston';
|
||||
import * as winston from 'winston';
|
||||
import { AdController } from './interface/message-controllers/ad.controller';
|
||||
import { AuthController } from './interface/message-controllers/auth.controller';
|
||||
import { UserController } from './interface/message-controllers/user.controller';
|
||||
import { ConfigurationController } from './interface/message-controllers/configuration.controller';
|
||||
import { MatcherController } from './interface/message-controllers/matcher.controller';
|
||||
import { TerritoryController } from './interface/message-controllers/territory.controller';
|
||||
import { GatewayApiController } from './interface/message-controllers/gateway-api.controller';
|
||||
import { AdminApiController } from './interface/message-controllers/admin-api.controller';
|
||||
import { AdMessageHandler } from './interface/message-handlers/ad.message-handler';
|
||||
import { AuthMessageHandler } from './interface/message-handlers/auth.message-handler';
|
||||
import { UserMessageHandler } from './interface/message-handlers/user.message-handler';
|
||||
import { ConfigurationMessageHandler } from './interface/message-handlers/configuration.message-handler';
|
||||
import { MatcherMessageHandler } from './interface/message-handlers/matcher.message-handler';
|
||||
import { TerritoryMessageHandler } from './interface/message-handlers/territory.message-handler';
|
||||
import { GatewayApiMessageHandler } from './interface/message-handlers/gateway-api.message-handler';
|
||||
import { AdminApiMessageHandler } from './interface/message-handlers/admin-api.message-handler';
|
||||
import { LoggerMessageHandler } from './interface/message-handlers/logger.message-handler';
|
||||
|
||||
const messageHandlers: Provider[] = [
|
||||
AdMessageHandler,
|
||||
AuthMessageHandler,
|
||||
UserMessageHandler,
|
||||
ConfigurationMessageHandler,
|
||||
LoggerMessageHandler,
|
||||
MatcherMessageHandler,
|
||||
TerritoryMessageHandler,
|
||||
GatewayApiMessageHandler,
|
||||
AdminApiMessageHandler,
|
||||
];
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
RabbitMQModule.forRootAsync(RabbitMQModule, {
|
||||
imports: [ConfigModule],
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
exchanges: [
|
||||
{
|
||||
name: configService.get<string>('RMQ_EXCHANGE'),
|
||||
type: 'topic',
|
||||
},
|
||||
],
|
||||
handlers: {
|
||||
loggingGatewayApiHealthCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.gateway-api.health.crit',
|
||||
queue: 'logging-gateway-api-health-crit',
|
||||
},
|
||||
loggingAdminApiHealthCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.admin-api.health.crit',
|
||||
queue: 'logging-admin-api-health-crit',
|
||||
},
|
||||
loggingAdCreatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.created.info',
|
||||
queue: 'logging-ad-created-info',
|
||||
},
|
||||
loggingAdCreatedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.created.warning',
|
||||
queue: 'logging-ad-created-warning',
|
||||
},
|
||||
loggingAdCreatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.created.crit',
|
||||
queue: 'logging-ad-created-crit',
|
||||
},
|
||||
loggingAdDeletedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.deleted.info',
|
||||
queue: 'logging-ad-deleted-info',
|
||||
},
|
||||
loggingAdDeletedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.deleted.crit',
|
||||
queue: 'logging-ad-deleted-crit',
|
||||
},
|
||||
loggingAdReadWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.read.warning',
|
||||
queue: 'logging-ad-read-warning',
|
||||
},
|
||||
loggingAdUpdatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.updated.info',
|
||||
queue: 'logging-ad-updated-info',
|
||||
},
|
||||
loggingAdUpdatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.updated.crit',
|
||||
queue: 'logging-ad-updated-crit',
|
||||
},
|
||||
loggingAdHealthCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.ad.health.crit',
|
||||
queue: 'logging-ad-health-crit',
|
||||
},
|
||||
loggingAuthCreatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.created.crit',
|
||||
queue: 'logging-auth-created-crit',
|
||||
},
|
||||
loggingAuthDeletedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.deleted.crit',
|
||||
queue: 'logging-auth-deleted-crit',
|
||||
},
|
||||
loggingAuthReadWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.read.warning',
|
||||
queue: 'logging-auth-read-warning',
|
||||
},
|
||||
loggingAuthUsernameCreatedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.username.created.warning',
|
||||
queue: 'logging-auth-username-created-warning',
|
||||
},
|
||||
loggingAuthUsernameDeletedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.username.deleted.warning',
|
||||
queue: 'logging-auth-username-deleted-warning',
|
||||
},
|
||||
loggingAuthUsernameReadWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.username.read.warning',
|
||||
queue: 'logging-auth-username-read-warning',
|
||||
},
|
||||
loggingAuthPasswordUpdatedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.password.updated.warning',
|
||||
queue: 'logging-auth-password-updated-warning',
|
||||
},
|
||||
loggingAuthUsernameUpdatedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.username.updated.warning',
|
||||
queue: 'logging-auth-username-updated-warning',
|
||||
},
|
||||
loggingAuthHealthCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.auth.health.crit',
|
||||
queue: 'logging-auth-health-crit',
|
||||
},
|
||||
loggingConfigurationCreatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.created.info',
|
||||
queue: 'logging-configuration-created-info',
|
||||
},
|
||||
loggingConfigurationCreatedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.created.warning',
|
||||
queue: 'logging-configuration-created-warning',
|
||||
},
|
||||
loggingConfigurationCreatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.created.crit',
|
||||
queue: 'logging-configuration-created-crit',
|
||||
},
|
||||
loggingConfigurationDeletedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.deleted.info',
|
||||
queue: 'logging-configuration-deleted-info',
|
||||
},
|
||||
loggingConfigurationDeletedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.deleted.crit',
|
||||
queue: 'logging-configuration-deleted-crit',
|
||||
},
|
||||
loggingConfigurationReadWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.read.warning',
|
||||
queue: 'logging-configuration-read-warning',
|
||||
},
|
||||
loggingConfigurationUpdatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.updated.info',
|
||||
queue: 'logging-configuration-updated-info',
|
||||
},
|
||||
loggingConfigurationUpdatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.updated.crit',
|
||||
queue: 'logging-configuration-updated-crit',
|
||||
},
|
||||
loggingConfigurationHealthCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.configuration.health.crit',
|
||||
queue: 'logging-configuration-health-crit',
|
||||
},
|
||||
loggingMatcherAdCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.matcher.ad.crit',
|
||||
queue: 'logging-matcher-ad-crit',
|
||||
},
|
||||
loggingMatcherMatchCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.matcher.match.crit',
|
||||
queue: 'logging-matcher-match-crit',
|
||||
},
|
||||
loggingTerritoryCreatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.created.info',
|
||||
queue: 'logging-territory-created-info',
|
||||
},
|
||||
loggingTerritoryCreatedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.created.warning',
|
||||
queue: 'logging-territory-created-warning',
|
||||
},
|
||||
loggingTerritoryCreatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.created.crit',
|
||||
queue: 'logging-territory-created-crit',
|
||||
},
|
||||
loggingTerritoryDeletedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.deleted.info',
|
||||
queue: 'logging-territory-deleted-info',
|
||||
},
|
||||
loggingTerritoryDeletedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.deleted.crit',
|
||||
queue: 'logging-territory-deleted-crit',
|
||||
},
|
||||
loggingTerritoryReadWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.read.warning',
|
||||
queue: 'logging-territory-read-warning',
|
||||
},
|
||||
loggingTerritoryUpdatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.updated.info',
|
||||
queue: 'logging-territory-updated-info',
|
||||
},
|
||||
loggingTerritoryUpdatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.updated.crit',
|
||||
queue: 'logging-territory-updated-crit',
|
||||
},
|
||||
loggingTerritoryHealthCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.territory.health.crit',
|
||||
queue: 'logging-territory-health-crit',
|
||||
},
|
||||
loggingUserCreatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.created.info',
|
||||
queue: 'logging-user-created-info',
|
||||
},
|
||||
loggingUserCreatedWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.created.warning',
|
||||
queue: 'logging-user-created-warning',
|
||||
},
|
||||
loggingUserCreatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.created.crit',
|
||||
queue: 'logging-user-created-crit',
|
||||
},
|
||||
loggingUserDeletedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.deleted.info',
|
||||
queue: 'logging-user-deleted-info',
|
||||
},
|
||||
loggingUserDeletedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.deleted.crit',
|
||||
queue: 'logging-user-deleted-crit',
|
||||
},
|
||||
loggingUserReadWarning: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.read.warning',
|
||||
queue: 'logging-user-read-warning',
|
||||
},
|
||||
loggingUserUpdatedInfo: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.updated.info',
|
||||
queue: 'logging-user-updated-info',
|
||||
},
|
||||
loggingUserUpdatedCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.updated.crit',
|
||||
queue: 'logging-user-updated-crit',
|
||||
},
|
||||
loggingUserHealthCrit: {
|
||||
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
||||
routingKey: 'logging.user.health.crit',
|
||||
queue: 'logging-user-health-crit',
|
||||
},
|
||||
},
|
||||
uri: configService.get<string>('RMQ_URI'),
|
||||
connectionInitOptions: { wait: false },
|
||||
enableControllerDiscovery: true,
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
WinstonModule.forRoot({
|
||||
levels: winston.config.syslog.levels,
|
||||
transports: [],
|
||||
}),
|
||||
],
|
||||
controllers: [
|
||||
AdController,
|
||||
AuthController,
|
||||
UserController,
|
||||
ConfigurationController,
|
||||
MatcherController,
|
||||
TerritoryController,
|
||||
GatewayApiController,
|
||||
AdminApiController,
|
||||
],
|
||||
providers: [],
|
||||
providers: [...messageHandlers],
|
||||
exports: [],
|
||||
})
|
||||
export class LoggerModule {}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export const MESSAGE_PUBLISHER = Symbol('MESSAGE_PUBLISHER');
|
|
@ -0,0 +1,238 @@
|
|||
import { Module, Provider } from '@nestjs/common';
|
||||
import { MESSAGE_PUBLISHER } from './messager.di-tokens';
|
||||
import {
|
||||
MessageBrokerModule,
|
||||
MessageBrokerModuleOptions,
|
||||
MessageBrokerPublisher,
|
||||
} from '@mobicoop/message-broker-module';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
|
||||
const imports = [
|
||||
MessageBrokerModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: async (
|
||||
configService: ConfigService,
|
||||
): Promise<MessageBrokerModuleOptions> => ({
|
||||
uri: configService.get<string>('MESSAGE_BROKER_URI'),
|
||||
exchange: configService.get<string>('MESSAGE_BROKER_EXCHANGE'),
|
||||
name: 'logger',
|
||||
handlers: {
|
||||
loggingGatewayApiHealthCrit: {
|
||||
routingKey: 'logging.gateway-api.health.crit',
|
||||
queue: 'logging-gateway-api-health-crit',
|
||||
},
|
||||
loggingAdminApiHealthCrit: {
|
||||
routingKey: 'logging.admin-api.health.crit',
|
||||
queue: 'logging-admin-api-health-crit',
|
||||
},
|
||||
loggingAdCreatedInfo: {
|
||||
routingKey: 'logging.ad.created.info',
|
||||
queue: 'logging-ad-created-info',
|
||||
},
|
||||
loggingAdCreatedWarning: {
|
||||
routingKey: 'logging.ad.created.warning',
|
||||
queue: 'logging-ad-created-warning',
|
||||
},
|
||||
loggingAdCreatedCrit: {
|
||||
routingKey: 'logging.ad.created.crit',
|
||||
queue: 'logging-ad-created-crit',
|
||||
},
|
||||
loggingAdDeletedInfo: {
|
||||
routingKey: 'logging.ad.deleted.info',
|
||||
queue: 'logging-ad-deleted-info',
|
||||
},
|
||||
loggingAdDeletedCrit: {
|
||||
routingKey: 'logging.ad.deleted.crit',
|
||||
queue: 'logging-ad-deleted-crit',
|
||||
},
|
||||
loggingAdReadWarning: {
|
||||
routingKey: 'logging.ad.read.warning',
|
||||
queue: 'logging-ad-read-warning',
|
||||
},
|
||||
loggingAdUpdatedInfo: {
|
||||
routingKey: 'logging.ad.updated.info',
|
||||
queue: 'logging-ad-updated-info',
|
||||
},
|
||||
loggingAdUpdatedCrit: {
|
||||
routingKey: 'logging.ad.updated.crit',
|
||||
queue: 'logging-ad-updated-crit',
|
||||
},
|
||||
loggingAdHealthCrit: {
|
||||
routingKey: 'logging.ad.health.crit',
|
||||
queue: 'logging-ad-health-crit',
|
||||
},
|
||||
loggingAuthCreatedCrit: {
|
||||
routingKey: 'logging.auth.created.crit',
|
||||
queue: 'logging-auth-created-crit',
|
||||
},
|
||||
loggingAuthDeletedCrit: {
|
||||
routingKey: 'logging.auth.deleted.crit',
|
||||
queue: 'logging-auth-deleted-crit',
|
||||
},
|
||||
loggingAuthReadWarning: {
|
||||
routingKey: 'logging.auth.read.warning',
|
||||
queue: 'logging-auth-read-warning',
|
||||
},
|
||||
loggingAuthUsernameCreatedWarning: {
|
||||
routingKey: 'logging.auth.username.created.warning',
|
||||
queue: 'logging-auth-username-created-warning',
|
||||
},
|
||||
loggingAuthUsernameDeletedWarning: {
|
||||
routingKey: 'logging.auth.username.deleted.warning',
|
||||
queue: 'logging-auth-username-deleted-warning',
|
||||
},
|
||||
loggingAuthUsernameReadWarning: {
|
||||
routingKey: 'logging.auth.username.read.warning',
|
||||
queue: 'logging-auth-username-read-warning',
|
||||
},
|
||||
loggingAuthPasswordUpdatedWarning: {
|
||||
routingKey: 'logging.auth.password.updated.warning',
|
||||
queue: 'logging-auth-password-updated-warning',
|
||||
},
|
||||
loggingAuthUsernameUpdatedWarning: {
|
||||
routingKey: 'logging.auth.username.updated.warning',
|
||||
queue: 'logging-auth-username-updated-warning',
|
||||
},
|
||||
loggingAuthHealthCrit: {
|
||||
routingKey: 'logging.auth.health.crit',
|
||||
queue: 'logging-auth-health-crit',
|
||||
},
|
||||
loggingConfigurationCreatedInfo: {
|
||||
routingKey: 'logging.configuration.created.info',
|
||||
queue: 'logging-configuration-created-info',
|
||||
},
|
||||
loggingConfigurationCreatedWarning: {
|
||||
routingKey: 'logging.configuration.created.warning',
|
||||
queue: 'logging-configuration-created-warning',
|
||||
},
|
||||
loggingConfigurationCreatedCrit: {
|
||||
routingKey: 'logging.configuration.created.crit',
|
||||
queue: 'logging-configuration-created-crit',
|
||||
},
|
||||
loggingConfigurationDeletedInfo: {
|
||||
routingKey: 'logging.configuration.deleted.info',
|
||||
queue: 'logging-configuration-deleted-info',
|
||||
},
|
||||
loggingConfigurationDeletedCrit: {
|
||||
routingKey: 'logging.configuration.deleted.crit',
|
||||
queue: 'logging-configuration-deleted-crit',
|
||||
},
|
||||
loggingConfigurationReadWarning: {
|
||||
routingKey: 'logging.configuration.read.warning',
|
||||
queue: 'logging-configuration-read-warning',
|
||||
},
|
||||
loggingConfigurationUpdatedInfo: {
|
||||
routingKey: 'logging.configuration.updated.info',
|
||||
queue: 'logging-configuration-updated-info',
|
||||
},
|
||||
loggingConfigurationUpdatedCrit: {
|
||||
routingKey: 'logging.configuration.updated.crit',
|
||||
queue: 'logging-configuration-updated-crit',
|
||||
},
|
||||
loggingConfigurationHealthCrit: {
|
||||
routingKey: 'logging.configuration.health.crit',
|
||||
queue: 'logging-configuration-health-crit',
|
||||
},
|
||||
loggingLoggerHealthCrit: {
|
||||
routingKey: 'logging.logger.health.crit',
|
||||
queue: 'logging-logger-health-crit',
|
||||
},
|
||||
loggingMatcherAdCrit: {
|
||||
routingKey: 'logging.matcher.ad.crit',
|
||||
queue: 'logging-matcher-ad-crit',
|
||||
},
|
||||
loggingMatcherMatchCrit: {
|
||||
routingKey: 'logging.matcher.match.crit',
|
||||
queue: 'logging-matcher-match-crit',
|
||||
},
|
||||
loggingTerritoryCreatedInfo: {
|
||||
routingKey: 'logging.territory.created.info',
|
||||
queue: 'logging-territory-created-info',
|
||||
},
|
||||
loggingTerritoryCreatedWarning: {
|
||||
routingKey: 'logging.territory.created.warning',
|
||||
queue: 'logging-territory-created-warning',
|
||||
},
|
||||
loggingTerritoryCreatedCrit: {
|
||||
routingKey: 'logging.territory.created.crit',
|
||||
queue: 'logging-territory-created-crit',
|
||||
},
|
||||
loggingTerritoryDeletedInfo: {
|
||||
routingKey: 'logging.territory.deleted.info',
|
||||
queue: 'logging-territory-deleted-info',
|
||||
},
|
||||
loggingTerritoryDeletedCrit: {
|
||||
routingKey: 'logging.territory.deleted.crit',
|
||||
queue: 'logging-territory-deleted-crit',
|
||||
},
|
||||
loggingTerritoryReadWarning: {
|
||||
routingKey: 'logging.territory.read.warning',
|
||||
queue: 'logging-territory-read-warning',
|
||||
},
|
||||
loggingTerritoryUpdatedInfo: {
|
||||
routingKey: 'logging.territory.updated.info',
|
||||
queue: 'logging-territory-updated-info',
|
||||
},
|
||||
loggingTerritoryUpdatedCrit: {
|
||||
routingKey: 'logging.territory.updated.crit',
|
||||
queue: 'logging-territory-updated-crit',
|
||||
},
|
||||
loggingTerritoryHealthCrit: {
|
||||
routingKey: 'logging.territory.health.crit',
|
||||
queue: 'logging-territory-health-crit',
|
||||
},
|
||||
loggingUserCreatedInfo: {
|
||||
routingKey: 'logging.user.created.info',
|
||||
queue: 'logging-user-created-info',
|
||||
},
|
||||
loggingUserCreatedWarning: {
|
||||
routingKey: 'logging.user.created.warning',
|
||||
queue: 'logging-user-created-warning',
|
||||
},
|
||||
loggingUserCreatedCrit: {
|
||||
routingKey: 'logging.user.created.crit',
|
||||
queue: 'logging-user-created-crit',
|
||||
},
|
||||
loggingUserDeletedInfo: {
|
||||
routingKey: 'logging.user.deleted.info',
|
||||
queue: 'logging-user-deleted-info',
|
||||
},
|
||||
loggingUserDeletedCrit: {
|
||||
routingKey: 'logging.user.deleted.crit',
|
||||
queue: 'logging-user-deleted-crit',
|
||||
},
|
||||
loggingUserReadWarning: {
|
||||
routingKey: 'logging.user.read.warning',
|
||||
queue: 'logging-user-read-warning',
|
||||
},
|
||||
loggingUserUpdatedInfo: {
|
||||
routingKey: 'logging.user.updated.info',
|
||||
queue: 'logging-user-updated-info',
|
||||
},
|
||||
loggingUserUpdatedCrit: {
|
||||
routingKey: 'logging.user.updated.crit',
|
||||
queue: 'logging-user-updated-crit',
|
||||
},
|
||||
loggingUserHealthCrit: {
|
||||
routingKey: 'logging.user.health.crit',
|
||||
queue: 'logging-user-health-crit',
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
];
|
||||
|
||||
const providers: Provider[] = [
|
||||
{
|
||||
provide: MESSAGE_PUBLISHER,
|
||||
useClass: MessageBrokerPublisher,
|
||||
},
|
||||
];
|
||||
|
||||
@Module({
|
||||
imports,
|
||||
providers,
|
||||
exports: [MESSAGE_PUBLISHER],
|
||||
})
|
||||
export class MessagerModule {}
|
Loading…
Reference in New Issue