Socket
Book a DemoInstallSign in
Socket

ifmcommon

Package Overview
Dependencies
Maintainers
7
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

ifmcommon

0.0.88
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
7
Weekly downloads
 
Created
Source

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

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();
  }

Keywords

nestJs

FAQs

Package last updated on 13 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.