0.0.88 • Published 1 month ago

ifmcommon v0.0.88

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

Description

Nest framework TypeScript starter repository.

Installation

$ npm install ifmcommon

Exception Filters

# usage of nestJs exception filter

import {HttpExceptionFilter ,MongoExceptionFilter } from ifmcommon

# get i18NService from app.module.ts

const i18NService = app.get<I18nService>(I18nService);

# to use as a global exception filter
# first parameter i18NService, second parameter is the kafkaConfig, third parameter is the topic which send to kafka

app.useGlobalFilters(
      new MongoExceptionFilter(i18NService, kafkaConf, Topics.FACILITY_EXCEPTIONS),
      new HttpExceptionFilter(i18NService, kafkaConf, Topics.FACILITY_EXCEPTIONS),
    );

Interceptor

# usage of nestJs common interceptor

import {LoggingInterceptor ,HttpCacheInterceptor, TimeoutInterceptor } from ifmcommon


# to use as a global interceptor
# first parameter is  kafkaConfig, second parameter is the topic which send to kafka for log purpose, third parameter is the topic which send to kafka for history purpose

app.useGlobalInterceptors(
      new LoggingInterceptor(kafkaConf, Topics.FACILITY_LOGGER, Topics.FACILITY_OPERATION),
      new TimeoutInterceptor(),
    );

#   LoggingInterceptor is used to log the request and response 

#  HttpCacheInterceptor is used to cache the request and response for getRequest() if u use @NoCache() decorator in controller it skip the cache

# TimeoutInterceptor is used to timeout the request if u use @Timeout() decorator in controller it skip the timeout

Kafka Connection

import {PostKafka,KafkaService } from ifmcommon
# usage of nestJs kafka connection
 this.postKafka = new PostKafka(new KafkaService(kafkaConfig));

 $kafkaconfig from kafkaJs kafkaConfig options

# producer method in postKafka

 async producerSendMessage(topicName: string, message: string, key?: string) {
    await this.producer.connect();
    await this.producer.send({
      topic: topicName,
      messages: [
        {
          key: key || uuidv4(),
          value: message,
        },
      ],
    });
    await this.producer.disconnect();
  }
0.0.87

1 month ago

0.0.88

1 month ago

0.0.77-beta.0

2 months ago

0.0.85-beta.1

2 months ago

0.0.85-beta.0

2 months ago

0.0.86

3 months ago

0.0.84

9 months ago

0.0.85

9 months ago

0.0.80

9 months ago

0.0.81

9 months ago

0.0.82

9 months ago

0.0.83

9 months ago

0.0.73

10 months ago

0.0.74

10 months ago

0.0.75

10 months ago

0.0.76

10 months ago

0.0.70

11 months ago

0.0.71

11 months ago

0.0.72

10 months ago

0.0.69

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.66

1 year ago

0.0.67

1 year ago

0.0.68

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.56

1 year ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.50

1 year ago

0.0.49

2 years ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago