New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dsninjas/response

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dsninjas/response

Response Helper for node.js projects

  • 1.0.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

ds-util-response

Response Helpers for node.js projects

This module makes it easy to format your response in node.js applications.

  • Installation
  • Usage

Installation

  • Make sure that Node.js installed.
  • Install Node.js library with npm:
npm install @dsninjas/response
  • You can also install Node.js library with yarn:
yarn add @dsninjas/response

Usage

constructor(Raven)

The constructor helps you configure the response helper class.

const responseHelper = new ResponseHelper(Raven);

The constructor takes the following options:

  1. constructor(Raven) (required): this is a refernce to the global Raven object.

json(status, res, message, data, meta)

This method helps you format your json response.

const responseHelper = new ResponseHelper(Raven);
const status = 200;
const message = 'Success';
const data = {};
responseHelper.json(status, res, message, data);
  1. status (required): this is the status of the response.
  2. res (required): this is the response object.
  3. message (required): this is the message of the response.
  4. data (optional): this is the data with the response.
  5. meta (optional): this is the meta data with the response.

error(err, res)

This method helps you to format your error.

const responseHelper = new ResponseHelper(Raven);
responseHelper.error(err, res);
  1. err (required): this is the error object.
  2. res (required): this is the response object.

customError(res, data)

This method helps you to generate the token.

const responseHelper = new ResponseHelper(Raven);
responseHelper.customError(res, data);
  1. res (required): this is the response object.
  2. data (optional): this is the data with the response.

Keywords

FAQs

Package last updated on 17 Jan 2018

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc