Socket
Socket
Sign inDemoInstall

dt-common-libs

Package Overview
Dependencies
16
Maintainers
1
Versions
215
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dt-common-libs

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 reque


Version published
Weekly downloads
215
decreased by-69.93%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 22 Apr 2024

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc