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

hapi-status

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-status - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

.jscsrc

109

lib/index.js
'use strict';
function Status() {
var status = this,
HTTPStatusCode = require('http-status-code'),
camelcase = require('camelcase'),
submerge = require('submerge'),
delegate = {},
defaults = {
'content-type': 'application/json'
};
const HTTPStatusCode = require('http-status-code'),
camelcase = require('camelcase'),
submerge = require('submerge');
function init() {
var definitions = HTTPStatusCode.getProtocolDefinitions();
let defaults = {
'content-type': 'application/json'
},
Object.keys(definitions).forEach(function(key) {
var name = camelcase(definitions[key].replace(/I'm/, 'I am').replace(/[^a-z\s]+/ig, ' ').toLowerCase());
delegate = {
applicationJson: (result, code, message) => {
let body = {
statusCode: code,
result: result
};
status[name] = create(+key, definitions[key]);
status[name].displayName = definitions[key];
});
}
if (Math.floor(code * 0.01) >= 4) {
body.error = message;
delete body.result;
}
function applyHeaders(headers, response) {
Object.keys(headers).forEach(function(header) {
response.header(header, headers[header]);
});
return body;
}
};
return response;
}
/**
* add headers to the response
*
* @method applyHeaders
* @param {Object} headers
* @param {Object} response
* @return {Object} response
* @private
*/
function applyHeaders(headers, response) {
Object.keys(headers).forEach(header => {
response.header(header, headers[header]);
});
delegate.applicationJson = function applicationJson(result, code, message) {
var body = {
statusCode: code,
result: result
};
return response;
}
if (Math.floor(code * 0.01) >= 4) {
body.error = message;
delete body.result;
}
/**
* the Status class
*
* @class Status
* @constructor
*/
class Status {
/**
* the constructor for the Status class
*
* @method constructor
* @return void
* @public
*/
constructor() {
let status = this,
definitions = HTTPStatusCode.getProtocolDefinitions();
return body;
};
Object.keys(definitions).forEach(key => {
let name = camelcase(definitions[key].replace(/I'm/, 'I am').replace(/[^a-z\s]+/ig, ' ').toLowerCase());
function create(code, message) {
status[name] = status.create(+key, definitions[key]);
status[name].displayName = definitions[key];
});
}
/**
* create a function based on the status code message
*
* @method create
* @param {Number} code
* @param {String} message
* @return {Function}
* @public
*/
create(code, message) {
let status = this;
return function(reply, result, headers) {
var body, type;
let body, type;

@@ -57,6 +92,4 @@ headers = submerge(headers || {}, defaults);

}
init();
}
module.exports = new Status();
{
"name": "hapi-status",
"version": "1.1.0",
"version": "2.0.0",
"description": "Easily add status code and headers to a response in Hapi",
"main": "index.js",
"main": "./lib",
"keywords": [

@@ -26,12 +26,12 @@ "hapi",

"dependencies": {
"camelcase": "^1.0.2",
"http-status-code": "^1.0.3",
"submerge": "^1.0.2"
"camelcase": "^2.0.1",
"http-status-code": "^2.0.1",
"submerge": "^1.0.9"
},
"devDependencies": {
"code": "^1.4.0",
"coveralls": "^2.11.2",
"lab": "^5.8.0",
"plato": "^1.4.0"
"code": "^2.0.1",
"coveralls": "^2.11.4",
"lab": "^7.3.0",
"plato": "^1.5.0"
}
}

@@ -6,4 +6,3 @@ 'use strict';

Code = require('code'),
HTTPStatusCode = require('http-status-code'),
status = require('../index');
status = require('../lib');

@@ -10,0 +9,0 @@ function Reply() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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