dt-common-libs

2.0.41 • Public • Published

Project Overview

This project consists of a collection of modules and utilities for handling various aspects of web development, including exception handling, constants, API responses, Redis operations, Axios wrapper, configuration reading, validation messages, HTTP request helpers, helper functions, middleware, and request validation.

Modules and Utilities

Exception Handling

  • Provides error classes for different types of exceptions: AuthenticationError, UnauthorizedError, ValidationError, DatabaseError, RedisError, ThirdPartyError, and KafkaError.

Constants

  • Exports a collection of constants from ./constants/constants.js.

API Responses

  • Exports functions for sending different types of API responses: sendResponse, sendSuccessResponse, sendFailureResponse, sendUnauthorizedResponse, sendValidationFailureResponse, and sendServerErrorResponse.

Redis Operations

  • Exports functions for performing Redis operations such as deleting, writing, reading, and cleanup.

Axios Wrapper

  • Provides an Axios wrapper for making HTTP requests.

Configuration Reading

  • Exports a function readConfig to read configuration settings from a file.

Validation Messages

  • Exports default validation messages from ./message/validation.js.

HTTP Request Helpers

  • Provides helper functions for making HTTP requests using various methods such as GET, POST, PATCH, PUT, and DELETE.

Helper Functions

  • Exports various helper functions like isEmpty, getErrorMessage, paginateHelper, isUnique, and isDataExists.

Middleware

  • Exports middleware functions such as setAcceptedLanguage, graphqlAuth, authHandler, and parseUserHeaders.

Request Validation

  • Exports a function baseValidateResponse for validating requests.

Usage

To use any of the functionalities provided by this project, import the required modules and utilities into your codebase using ES6 import syntax.

Example:

import { sendResponse, sendSuccessResponse } from './libs/ApiResponse.js';

// Use sendResponse and sendSuccessResponse functions

Feel free to replace the comment with your actual examples and instructions.

Package Sidebar

Install

npm i dt-common-libs

Weekly Downloads

151

Version

2.0.41

License

ISC

Unpacked Size

603 kB

Total Files

124

Last publish

Collaborators

  • maxca789