nodejs-cofast-package-localhost
v0.1.1
Published
:pushpin: **Validate Token**
Downloads
7
Readme
:pushpin: Validate Token
- Cách sử dụng + Wrapper
import { GrpcMetadataInterceptor } from "src/utils.common/utils.interceptor/grpc-metadata.interceptor";
@Controller("users")
@UseInterceptors(GrpcMetadataInterceptor)
...
@Get("/:id")
@UseGuards(UserGuard)
async findOneUser(
@Req() request: RequestWithUser,
@Param("id") id: number,
@Res() res: Response,
@AddGrpcMetadata() metadata: Metadata
) {
return res
.status(HttpStatus.OK)
.send(await this.userService.findOneUser(id, metadata));
}
+ Service
async findOneUser(
request: FindOneUserDTO,
metadata: Metadata,
call: ServerUnaryCall<any, any>
): Promise<any> {
console.log(new UtilsUser(call).getUser());
}
:pushpin: Enum
AccountType
AccountStatus
StoreProcedureStatusEnum
:bangbang: Exception
GrpcExceptionFilter
ExceptionStoreProcedure
ExceptionResponseDetail
:file_folder: Store
StoreProcedureResultOutput
StoreProcedureResult
StoreProcedureOutputResultInterface
StoreProcedureResultInterface
:zap: Utils
UtilsTime
Kafka Log Module
Introduction
This module provides functionality to log messages to Kafka.
Cách dùng
- Import vào module cần dùng
import { KafkaLogModule } from 'nodejs-cofast-package/dist/v1';
KafkaLogModule.register({
client_id: 'my-app-test-1', // có thể sửa
host: process.env.CONFIG_KAFKA_HOST,
port: process.env.CONFIG_KAFKA_PORT,
})
- Khai báo service
private readonly kafkaLogService: KafkaLogService
- Send log
await this.kafkaLogService.sendLogToKafka(message);