backend-common-package v1.2.4
Backend common package
CommonModule
Append the
CommonModule.forRoot()
into your current module import array. This will allow you to use Guards, Services, etc.
import { CommonModule } from 'backend-common-package';
CommonModule.forRoot({
cacheConfig: { store: example_redisStore },
kafkaConfig: {
transport: Transport.KAFKA,
options: {
client: {
clientId: process.env.CLIENT_ID,
brokers: [process.env.BROKERS],
},
consumer: {
groupId: process.env.GROUP_ID,
},
},,
}),
Guards
Request headers:\
key: otp-target-type, value: 'email' or 'phone'
\key: otp-target, value: 'a@a.com' or '+51987654321' for example
\key: otp-new-uuid-for-this-operation, value: 'some random uuid'
import {
SendOperationOtpGuard,
ValidatedOperationOtpGuard,
} from 'backend-common-package';
@UseGuards(SendOperationOtpGuard, ValidatedOperationOtpGuard)
Event
SendOperationOtpGuard
emits a kafka event that should be listened by your email or sms sender:
Topic:
'SEND_OPERATION_OTP'
Payload:
{
targetType: 'email' | 'phone',
target: string,
otp: string,
}
Service
import { GuardsService } from 'backend-common-package';
constructor(
private readonly guardsService: GuardsService,
) {}
await this.guardsService.validateOperationOtp(input: {
operationUUID: string;
otp: string;
}),
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago