0.1.24 • Published 1 year ago

my-log-kafka-package v0.1.24

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
1 year 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

1 year ago

0.1.23

1 year ago

0.1.22

1 year ago

0.1.21

1 year ago

0.1.20

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.0.25

1 year ago

0.0.21

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago