🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

standard-http-error

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

standard-http-error - npm Package Compare versions

Comparing version
1.0.1
to
1.1.0
+1
codes.js
module.exports = require("http").STATUS_CODES
{
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",
"206": "Partial Content",
"207": "Multi-Status",
"300": "Multiple Choices",
"301": "Moved Permanently",
"302": "Moved Temporarily",
"303": "See Other",
"304": "Not Modified",
"305": "Use Proxy",
"307": "Temporary Redirect",
"308": "Permanent Redirect",
"400": "Bad Request",
"401": "Unauthorized",
"402": "Payment Required",
"403": "Forbidden",
"404": "Not Found",
"405": "Method Not Allowed",
"406": "Not Acceptable",
"407": "Proxy Authentication Required",
"408": "Request Time-out",
"409": "Conflict",
"410": "Gone",
"411": "Length Required",
"412": "Precondition Failed",
"413": "Request Entity Too Large",
"414": "Request-URI Too Large",
"415": "Unsupported Media Type",
"416": "Requested Range Not Satisfiable",
"417": "Expectation Failed",
"418": "I'm a teapot",
"422": "Unprocessable Entity",
"423": "Locked",
"424": "Failed Dependency",
"425": "Unordered Collection",
"426": "Upgrade Required",
"428": "Precondition Required",
"429": "Too Many Requests",
"431": "Request Header Fields Too Large",
"500": "Internal Server Error",
"501": "Not Implemented",
"502": "Bad Gateway",
"503": "Service Unavailable",
"504": "Gateway Time-out",
"505": "HTTP Version Not Supported",
"506": "Variant Also Negotiates",
"507": "Insufficient Storage",
"509": "Bandwidth Limit Exceeded",
"510": "Not Extended",
"511": "Network Authentication Required"
}
var $ = require("oolong")
var CODES_JSON = require("../codes.json")
var STATUS_CODES = require("http").STATUS_CODES
describe("codes.json", function() {
// Test for superset rather than equivalence because future Node versions
// might _add_ status codes. I presume they won't remove any though.
$.each(STATUS_CODES, function(name, code) {
it("must have " + code + " equal " + name, function() {
CODES_JSON[code].must.equal(name)
})
})
})
+5
-0

@@ -0,1 +1,6 @@

## 1.1.0 (May 21, 2015)
- Adds support for use in the browser by adding a cached copy of status codes.
For example, use StandardHttpError.js with
[Browserify](https://github.com/substack/node-browserify).
## 1.0.1 (Feb 23, 2015)

@@ -2,0 +7,0 @@ - Fixes subclassing example in README.

+6
-8

@@ -0,5 +1,5 @@

exports = module.exports = HttpError
var StandardError = require("standard-error")
var STATUS_CODE_TO_NAME = require("http").STATUS_CODES
var STATUS_NAME_TO_CODE = require("http-codes")
module.exports = HttpError
var STATUS_CODE_TO_NAME = require("./codes")
var STATUS_NAME_TO_CODE = exports

@@ -18,4 +18,2 @@ function HttpError(code, msg, props) {

assign(HttpError, STATUS_NAME_TO_CODE)
Object.defineProperties(HttpError.prototype, {

@@ -40,5 +38,5 @@ statusCode: alias("code"),

function assign(target, source) {
for (var key in source) target[key] = source[key]
return target
for (var code in STATUS_CODE_TO_NAME) {
var name = STATUS_CODE_TO_NAME[code]
exports[name.replace("'", "").replace(/[- ]/g, "_").toUpperCase()] = +code
}

@@ -45,0 +43,0 @@

@@ -28,2 +28,5 @@ NODE_OPTS =

codes.json: .FORCE
node -e 'console.log(JSON.stringify(require("./codes"), null, "\t"))' > "$@"
publish:

@@ -43,1 +46,2 @@ npm publish

.PHONY: clean
.PHONY: .FORCE
{
"name": "standard-http-error",
"version": "1.0.1",
"version": "1.1.0",
"description": "Standard HTTP error class. Proper serialization, no bloat. Extensible.",

@@ -33,4 +33,7 @@ "keywords": [

"browser": {
"./codes.js": "./codes.json"
},
"dependencies": {
"http-codes": ">= 1.0.0 < 2",
"standard-error": ">= 1.1.0 < 2"

@@ -42,4 +45,5 @@ },

"must": ">= 0.12.0 < 0.13",
"objectware": ">= 1.6.0 < 2"
"oolong": ">= 1.7.0 < 2",
"http-codes": ">= 1.0.0 < 2"
}
}

@@ -156,5 +156,5 @@ StandardHttpError.js

The names are generated automatically from Node.js's `Http.STATUS_CODES` object
during run-time, so they'll always be up to date. Here's the list for reference
as of Node v0.11:
When running on Node.js, the names are generated during run-time from
`Http.STATUS_CODES`, so they'll always be up to date. Here's the list for
reference as of Node v0.12:

@@ -161,0 +161,0 @@ Code | Name

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

var Ow = require("objectware")
var $ = require("oolong")
var STATUS_NAMES = require("http-codes")

@@ -161,3 +161,3 @@ var HttpError = require("..")

Ow.each(STATUS_NAMES, function(code, constant) {
$.each(STATUS_NAMES, function(code, constant) {
it("must have " + constant + " equal " + code, function() {

@@ -164,0 +164,0 @@ HttpError[constant].must.equal(code)