swagger documentation
This commit is contained in:
parent
859580db45
commit
9b06c771a2
@ -1,10 +1,10 @@
|
|||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
export default registerAs('appConfig', () => ({
|
export default registerAs('appConfig', () => ({
|
||||||
user: process.env.RABBITMQ_USER ,
|
user: process.env.RABBITMQ_USER,
|
||||||
pass: process.env.RABBITMQ_PASS ,
|
pass: process.env.RABBITMQ_PASS,
|
||||||
host: process.env.RABBITMQ_HOST ,
|
host: process.env.RABBITMQ_HOST,
|
||||||
port: process.env.RABBITMQ_PORT ,
|
port: process.env.RABBITMQ_PORT,
|
||||||
apiUrl: process.env.RABBITMQ_API_URL || 'https://rabbitmq.dcb.pixpay.sn/api',
|
apiUrl: process.env.RABBITMQ_API_URL || 'https://rabbitmq.dcb.pixpay.sn/api',
|
||||||
queues: {
|
queues: {
|
||||||
smsmo: process.env.RABBITMQ_QUEUE_WEBHOOK || 'smsmo_queue',
|
smsmo: process.env.RABBITMQ_QUEUE_WEBHOOK || 'smsmo_queue',
|
||||||
@ -12,9 +12,9 @@ export default registerAs('appConfig', () => ({
|
|||||||
he: process.env.RABBITMQ_QUEUE_NOTIFICATION || 'he_queue',
|
he: process.env.RABBITMQ_QUEUE_NOTIFICATION || 'he_queue',
|
||||||
},
|
},
|
||||||
keycloak: {
|
keycloak: {
|
||||||
authServerUrl: process.env.KEYCLOAK_AUTH_SERVER_URL ,
|
authServerUrl: process.env.KEYCLOAK_AUTH_SERVER_URL,
|
||||||
clientId: process.env.KEYCLOAK_CLIENT_ID ,
|
clientId: process.env.KEYCLOAK_CLIENT_ID,
|
||||||
clientSecret: process.env.KEYCLOAK_CLIENT_SECRET ,
|
clientSecret: process.env.KEYCLOAK_CLIENT_SECRET,
|
||||||
realm: process.env.KEYCLOAK_REALM ,
|
realm: process.env.KEYCLOAK_REALM,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -10,7 +10,14 @@ import {
|
|||||||
HttpStatus,
|
HttpStatus,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import {
|
||||||
|
ApiBearerAuth,
|
||||||
|
ApiBody,
|
||||||
|
ApiCreatedResponse,
|
||||||
|
ApiOkResponse,
|
||||||
|
ApiOperation,
|
||||||
|
ApiTags,
|
||||||
|
} from '@nestjs/swagger';
|
||||||
import { Resource, Roles } from 'nest-keycloak-connect';
|
import { Resource, Roles } from 'nest-keycloak-connect';
|
||||||
import { InboundSMSMessageNotificationWrapperDto } from 'src/dtos/sms.mo.dto';
|
import { InboundSMSMessageNotificationWrapperDto } from 'src/dtos/sms.mo.dto';
|
||||||
import { SubscriptionDto } from 'src/dtos/subscription.dto';
|
import { SubscriptionDto } from 'src/dtos/subscription.dto';
|
||||||
@ -18,12 +25,25 @@ import { WebhookService } from 'src/services/webhook.service';
|
|||||||
|
|
||||||
@Controller('webhook')
|
@Controller('webhook')
|
||||||
@ApiTags('webhook')
|
@ApiTags('webhook')
|
||||||
|
@ApiBearerAuth()
|
||||||
export class WebhookController {
|
export class WebhookController {
|
||||||
constructor(private readonly webhookService: WebhookService) {}
|
constructor(private readonly webhookService: WebhookService) {}
|
||||||
|
|
||||||
@Post('sms-mo/:operator/:country')
|
@Post('sms-mo/:operator/:country')
|
||||||
@HttpCode(HttpStatus.CREATED)
|
@HttpCode(HttpStatus.CREATED)
|
||||||
@Roles({ roles: ['admin_webhook'] })
|
@Roles({ roles: ['admin_webhook'] })
|
||||||
|
@ApiOperation({ summary: 'Receive callback for SMS MO notification' })
|
||||||
|
@ApiBody({ type: InboundSMSMessageNotificationWrapperDto })
|
||||||
|
@ApiCreatedResponse({
|
||||||
|
description: 'SMS MO callback successfully queued',
|
||||||
|
schema: {
|
||||||
|
example: {
|
||||||
|
status: 'queued',
|
||||||
|
operator: 'Orange',
|
||||||
|
country: 'SN',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
async smsMoNotification(
|
async smsMoNotification(
|
||||||
@Param('country') country: string,
|
@Param('country') country: string,
|
||||||
@Param('operator') operator: string,
|
@Param('operator') operator: string,
|
||||||
@ -41,6 +61,18 @@ export class WebhookController {
|
|||||||
@Post('subscription/:operator/:country')
|
@Post('subscription/:operator/:country')
|
||||||
@HttpCode(HttpStatus.CREATED)
|
@HttpCode(HttpStatus.CREATED)
|
||||||
@Roles({ roles: ['admin_webhook'] })
|
@Roles({ roles: ['admin_webhook'] })
|
||||||
|
@ApiOperation({ summary: 'Receive callback for management of subscription' })
|
||||||
|
@ApiBody({ type: SubscriptionDto })
|
||||||
|
@ApiCreatedResponse({
|
||||||
|
description: 'Subscription event successfully queued',
|
||||||
|
schema: {
|
||||||
|
example: {
|
||||||
|
status: 'queued',
|
||||||
|
operator: 'Orange',
|
||||||
|
country: 'EG',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
async manageSubscription(
|
async manageSubscription(
|
||||||
@Param('country') country: string,
|
@Param('country') country: string,
|
||||||
@Param('operator') operator: string,
|
@Param('operator') operator: string,
|
||||||
@ -57,6 +89,15 @@ export class WebhookController {
|
|||||||
@Get('he/:operator/:country')
|
@Get('he/:operator/:country')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Roles({ roles: ['admin_webhook'] })
|
@Roles({ roles: ['admin_webhook'] })
|
||||||
|
@ApiOperation({ summary: 'Receive callback for HE notification' })
|
||||||
|
@ApiOkResponse({
|
||||||
|
description: 'HE notification successfully queued',
|
||||||
|
schema: {
|
||||||
|
example: {
|
||||||
|
status: 'queued',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
async heNotification(
|
async heNotification(
|
||||||
@Param('country') country: string,
|
@Param('country') country: string,
|
||||||
@Param('operator') operator: string,
|
@Param('operator') operator: string,
|
||||||
@ -73,6 +114,6 @@ export class WebhookController {
|
|||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
|
|
||||||
return { status: 'queued', operator, country, callback };
|
return { status: 'queued' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,38 +1,54 @@
|
|||||||
import { IsString, ValidateNested, IsNotEmpty, IsDateString } from 'class-validator';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import {
|
||||||
|
IsString,
|
||||||
|
ValidateNested,
|
||||||
|
IsNotEmpty,
|
||||||
|
IsDateString,
|
||||||
|
} from 'class-validator';
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
|
|
||||||
export class InboundSMSMessageDto {
|
export class InboundSMSMessageDto {
|
||||||
|
@ApiProperty({ example: '2025-10-30T14:00:00Z' })
|
||||||
@IsDateString()
|
@IsDateString()
|
||||||
dateTime: string;
|
dateTime: string;
|
||||||
|
|
||||||
|
@ApiProperty({ example: '+33612345678' })
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
destinationAddress: string;
|
destinationAddress: string;
|
||||||
|
|
||||||
|
@ApiProperty({ example: 'mes1234' })
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
messageId: string;
|
messageId: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
example: 'recipient id %% The content of the message we should send.',
|
||||||
|
})
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
message: string;
|
message: string;
|
||||||
|
|
||||||
|
@ApiProperty({ example: 'acr:token' })
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
senderAddress: string;
|
senderAddress: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InboundSMSMessageNotificationDto {
|
export class InboundSMSMessageNotificationDto {
|
||||||
|
@ApiProperty({ example: '12345' })
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
callbackData: string;
|
callbackData: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: InboundSMSMessageDto })
|
||||||
@ValidateNested()
|
@ValidateNested()
|
||||||
@Type(() => InboundSMSMessageDto)
|
@Type(() => InboundSMSMessageDto)
|
||||||
inboundSMSMessage: InboundSMSMessageDto;
|
inboundSMSMessage: InboundSMSMessageDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InboundSMSMessageNotificationWrapperDto {
|
export class InboundSMSMessageNotificationWrapperDto {
|
||||||
|
@ApiProperty({ type: InboundSMSMessageNotificationDto })
|
||||||
@ValidateNested()
|
@ValidateNested()
|
||||||
@Type(() => InboundSMSMessageNotificationDto)
|
@Type(() => InboundSMSMessageNotificationDto)
|
||||||
inboundSMSMessageNotification: InboundSMSMessageNotificationDto;
|
inboundSMSMessageNotification: InboundSMSMessageNotificationDto;
|
||||||
|
|||||||
@ -16,6 +16,8 @@ async function bootstrap() {
|
|||||||
.setDescription(
|
.setDescription(
|
||||||
'This is a service dedicated to the reception of callback from external source and sending to rabbitMQ',
|
'This is a service dedicated to the reception of callback from external source and sending to rabbitMQ',
|
||||||
)
|
)
|
||||||
|
.addBearerAuth()
|
||||||
|
.addTag('auth')
|
||||||
.setVersion('1.0')
|
.setVersion('1.0')
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user