node-https-response

1.3.0 • Public • Published

node-https-response

A simple object to return http response object with required headers for AWS api gatway to enable the cors

Build Status NPM version

Installation

npm install node-https-response

Usage

//success method

var response = require('node-https-response');
var res = new response.success(200, 'Successfully submited' , 'This is my Data' , { header1 : 25, header2 :'Play'} );
//statusCode === 200 
//message === OK
//body === {}
//headers === {} , if headers are not passed , default headers will be passed to enable the cors for AWS API gateway .
 
//error method
var response = require('node-https-response');
var res = new response.error(404, 'Page Not found' );
//statusCode === 400
//message === 'Bad Request'

Properties

  • statusCode: Number - the status code of the response
  • body: Object | String - object of statusCode, message, data as a parameter
  • headers: Object - the headers of the response. The keys are automatically made lower case.

License

ISC

Package Sidebar

Install

npm i node-https-response

Weekly Downloads

0

Version

1.3.0

License

ISC

Unpacked Size

4.7 kB

Total Files

6

Last publish

Collaborators

  • pranay2111