0.1.24 • Published 11 months ago

my-log-kafka-package v0.1.24

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
11 months ago

: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

-Đổi tên

 KafkaLogModule -> KafkaCofastModule
 KafkaLogService -> KafkaCofastService
  • Import vào module cần dùng
import { KafkaCofastModule } from 'nodejs-cofast-package/dist/v1';
    KafkaCofastModule.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 kafkaCofastService: KafkaCofastService
  • Send log
export interface ILogActivity {
    user_id: number;
    log_type: LOG_TYPE_ENUM;
    object_id: number;
    action_type: ACTION_TYPE_ENUM;
    action_detail: string;
    json_data_before: string;
    json_data_after: string;
    platform_type: PLATFORM_TYPE_ENUM;
    timestamp: number;
}

await this.kafkaCofastService.sendLogToKafka(message: ILogActivity);
  • send notification
export interface INotification {
  recipient_user_id: number;
  avatar: string;
  image_url: string;
  title: string;
  content: string;
  object_id: number;
  object_type: LOG_TYPE_ENUM;
  timestamp: number;
}


await this.kafkaCofastService.sendNotificationToKafka(message: INotification);

- KeyRedisGenerate

KeyRedisGenerate.generateKey(REDIS_PREFIX_ENUM.AIR_FREIGHT, request)
0.1.24

11 months ago

0.1.23

11 months ago

0.1.22

11 months ago

0.1.21

11 months ago

0.1.20

11 months ago

0.1.13

11 months ago

0.1.12

11 months ago

0.1.11

11 months ago

0.1.10

11 months ago

0.1.5

11 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.0.25

11 months ago

0.0.21

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago