Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

response-format

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

response-format - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

70

lib/format.js

@@ -1,2 +0,2 @@

"use strict";
"use strict"
/**

@@ -21,21 +21,21 @@ * `format` constructor.

return this;
return this
},
success: (message, data) => {
this.statusCode = 200;
this.error = false;
this.statusCode = 200
this.error = false
this.data = data || null
this.message = message || 'OK'
return this;
return this
},
badRequest: (message, data) => {
this.statusCode = 400;
this.error = true;
this.statusCode = 400
this.error = true
this.data = data || null
this.message = message || 'Bad Request'
return this;
return this
},

@@ -45,82 +45,82 @@

unAuthorized: (message, data) => {
this.statusCode = 402;
this.error = true;
this.statusCode = 402
this.error = true
this.data = data || null
this.message = message || 'Unauth­orized'
return this;
return this
},
forbidden: (message, data) => {
this.statusCode = 403;
this.error = true;
this.statusCode = 403
this.error = true
this.data = data || null
this.message = message || 'Forbidden'
return this;
return this
},
notFound: (message, data) => {
this.statusCode = 404;
this.error = true;
this.statusCode = 404
this.error = true
this.data = data || null
this.message = message || 'Not Found'
return this;
return this
},
notAllowed: (message, data) => {
this.statusCode = 405;
this.error = true;
this.statusCode = 405
this.error = true
this.data = data || null
this.message = message || 'Method Not Allowed'
return this;
return this
},
requestTimeout: (message, data) => {
this.statusCode = 408;
this.error = true;
this.statusCode = 408
this.error = true
this.data = data || null
this.message = message || 'Request Timeout'
return this;
return this
},
internalError: (message, data) => {
this.statusCode = 500;
this.error = true;
this.statusCode = 500
this.error = true
this.data = data || null
this.message = message || 'Internal Server Error'
return this;
return this
},
badGateway: (message, data) => {
this.statusCode = 502;
this.error = true;
this.statusCode = 502
this.error = true
this.data = data || null
this.message = message || 'Bad Gateway'
return this;
return this
},
unavailable: (message, data) => {
this.statusCode = 503;
this.error = true;
this.statusCode = 503
this.error = true
this.data = data || null
this.message = message || 'Service Unavai­lable'
return this;
return this
},
gatewayTimeout: (message, data) => {
this.statusCode = 504;
this.error = true;
this.statusCode = 504
this.error = true
this.data = data || null
this.message = message || 'Gateway Timeout'
return this;
return this
}
}

@@ -8,10 +8,11 @@ "use strict";

*/
module.exports = checkStatusCode = (statusCode, message) => {
if(!statusCode) return null
const checkStatusCode = (statusCode, message) => {
if(!statusCode) return null
if(STATUS_CODES.hasOwnProperty(statusCode)) {
return message || STATUS_CODES[statusCode]
}
if(STATUS_CODES.hasOwnProperty(statusCode)) {
return message || STATUS_CODES[statusCode]
}
return null
}
return null
}
module.exports = checkStatusCode
{
"name": "response-format",
"version": "1.0.1",
"version": "1.0.2",
"description": "Module which will provide HTTP-friendly error objects",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -82,3 +82,3 @@ Response Format

"statusCode": 400,
"error": false,
"error": true,
"message": "Bad Request",

@@ -105,3 +105,3 @@ "data": null

"statusCode": 402,
"error": false,
"error": true,
"message": "Unauth­orized",

@@ -128,3 +128,3 @@ "data": null

"statusCode": 403,
"error": false,
"error": true,
"message": "Forbidden",

@@ -151,3 +151,3 @@ "data": null

"statusCode": 404,
"error": false,
"error": true,
"message": "Not Found",

@@ -174,3 +174,3 @@ "data": null

"statusCode": 405,
"error": false,
"error": true,
"message": "Method Not Allowed",

@@ -197,3 +197,3 @@ "data": null

"statusCode": 408,
"error": false,
"error": true,
"message": "Request Timeout",

@@ -220,3 +220,3 @@ "data": null

"statusCode": 500,
"error": false,
"error": true,
"message": "Internal Server Error",

@@ -243,3 +243,3 @@ "data": null

"statusCode": 502,
"error": false,
"error": true,
"message": "Bad Gateway",

@@ -266,3 +266,3 @@ "data": null

"statusCode": 503,
"error": false,
"error": true,
"message": "Service Unavai­lable",

@@ -289,3 +289,3 @@ "data": null

"statusCode": 504,
"error": false,
"error": true,
"message": "Gateway Timeout",

@@ -292,0 +292,0 @@ "data": null

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