@comodinx/http-errors
Advanced tools
+328
-0
@@ -10,2 +10,6 @@ 'use strict'; | ||
| } | ||
| static get code () { | ||
| return http.codes.CONTINUE; | ||
| } | ||
| } | ||
@@ -17,2 +21,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.SWITCHING_PROTOCOLS; | ||
| } | ||
| } | ||
@@ -24,2 +32,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PROCESSING; | ||
| } | ||
| } | ||
@@ -31,2 +43,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.OK; | ||
| } | ||
| } | ||
@@ -38,2 +54,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.CREATED; | ||
| } | ||
| } | ||
@@ -45,2 +65,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.ACCEPTED; | ||
| } | ||
| } | ||
@@ -52,2 +76,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NON_AUTHORITATIVE_INFORMATION; | ||
| } | ||
| } | ||
@@ -59,2 +87,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NO_CONTENT; | ||
| } | ||
| } | ||
@@ -66,2 +98,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.RESET_CONTENT; | ||
| } | ||
| } | ||
@@ -73,2 +109,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PARTIAL_CONTENT; | ||
| } | ||
| } | ||
@@ -80,2 +120,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.MULTI_STATUS; | ||
| } | ||
| } | ||
@@ -87,2 +131,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.ALREADY_REPORTED; | ||
| } | ||
| } | ||
@@ -94,2 +142,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.IM_USED; | ||
| } | ||
| } | ||
@@ -101,2 +153,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.MULTIPLE_CHOICES; | ||
| } | ||
| } | ||
@@ -108,2 +164,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.MOVED_PERMANENTLY; | ||
| } | ||
| } | ||
@@ -115,2 +175,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.FOUND; | ||
| } | ||
| } | ||
@@ -122,2 +186,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.SEE_OTHER; | ||
| } | ||
| } | ||
@@ -129,2 +197,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NOT_MODIFIED; | ||
| } | ||
| } | ||
@@ -136,2 +208,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.USE_PROXY; | ||
| } | ||
| } | ||
@@ -143,2 +219,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.SWITCH_PROXY; | ||
| } | ||
| } | ||
@@ -150,2 +230,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.TEMPORARY_REDIRECT; | ||
| } | ||
| } | ||
@@ -157,2 +241,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PERMANENT_REDIRECT; | ||
| } | ||
| } | ||
@@ -164,2 +252,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.RESUME_INCOMPLETE; | ||
| } | ||
| } | ||
@@ -171,2 +263,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.BAD_REQUEST; | ||
| } | ||
| } | ||
@@ -178,2 +274,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.UNAUTHORIZED; | ||
| } | ||
| } | ||
@@ -185,2 +285,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PAYMENT_REQUIRED; | ||
| } | ||
| } | ||
@@ -192,2 +296,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.FORBIDDEN; | ||
| } | ||
| } | ||
@@ -199,2 +307,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NOT_FOUND; | ||
| } | ||
| } | ||
@@ -206,2 +318,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.METHOD_NOT_ALLOWED; | ||
| } | ||
| } | ||
@@ -213,2 +329,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NOT_ACCEPTABLE; | ||
| } | ||
| } | ||
@@ -220,2 +340,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PROXY_AUTHENTICATION_REQUIRED; | ||
| } | ||
| } | ||
@@ -227,2 +351,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.REQUEST_TIMEOUT; | ||
| } | ||
| } | ||
@@ -234,2 +362,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.CONFLICT; | ||
| } | ||
| } | ||
@@ -241,2 +373,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.GONE; | ||
| } | ||
| } | ||
@@ -248,2 +384,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.LENGTH_REQUIRED; | ||
| } | ||
| } | ||
@@ -255,2 +395,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PRECONDITION_FAILED; | ||
| } | ||
| } | ||
@@ -262,2 +406,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PAYLOAD_TOO_LARGE; | ||
| } | ||
| } | ||
@@ -269,2 +417,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.URI_TOO_LONG; | ||
| } | ||
| } | ||
@@ -276,2 +428,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.UNSUPPORTED_MEDIA_TYPE; | ||
| } | ||
| } | ||
@@ -283,2 +439,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.RANGE_NOT_SATISFIABLE; | ||
| } | ||
| } | ||
@@ -290,2 +450,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.EXPECTATION_FAILED; | ||
| } | ||
| } | ||
@@ -297,2 +461,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.IM_A_TEAPOT; | ||
| } | ||
| } | ||
@@ -304,2 +472,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.AUTHENTICATION_TIMEOUT; | ||
| } | ||
| } | ||
@@ -311,2 +483,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.METHOD_FAILURE; | ||
| } | ||
| } | ||
@@ -318,2 +494,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.ENHANCE_YOUR_CALM; | ||
| } | ||
| } | ||
@@ -325,2 +505,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.MISDIRECTED_REQUEST; | ||
| } | ||
| } | ||
@@ -332,2 +516,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.UNPROCESSABLE_ENTITY; | ||
| } | ||
| } | ||
@@ -339,2 +527,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.LOCKED; | ||
| } | ||
| } | ||
@@ -346,2 +538,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.FAILED_DEPENDENCY; | ||
| } | ||
| } | ||
@@ -353,2 +549,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.UPGRADE_REQUIRED; | ||
| } | ||
| } | ||
@@ -360,2 +560,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.PRECONDITION_REQUIRED; | ||
| } | ||
| } | ||
@@ -367,2 +571,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.TOO_MANY_REQUESTS; | ||
| } | ||
| } | ||
@@ -374,2 +582,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.REQUEST_HEADER_FIELDS_TOO_LARGE; | ||
| } | ||
| } | ||
@@ -381,2 +593,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.LOGIN_TIMEOUT; | ||
| } | ||
| } | ||
@@ -388,2 +604,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NO_RESPONSE; | ||
| } | ||
| } | ||
@@ -395,2 +615,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.RETRY_WITH; | ||
| } | ||
| } | ||
@@ -402,2 +626,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS; | ||
| } | ||
| } | ||
@@ -409,2 +637,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.UNAVAILABLE_FOR_LEGAL_REASONS; | ||
| } | ||
| } | ||
@@ -416,2 +648,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.REDIRECT; | ||
| } | ||
| } | ||
@@ -423,2 +659,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.REQUEST_HEADER_TOO_LARGE; | ||
| } | ||
| } | ||
@@ -430,2 +670,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.CERT_ERROR; | ||
| } | ||
| } | ||
@@ -437,2 +681,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NO_CERT; | ||
| } | ||
| } | ||
@@ -444,2 +692,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.HTTP_TO_HTTPS; | ||
| } | ||
| } | ||
@@ -451,2 +703,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.TOKEN_EXPIRED_INVALID; | ||
| } | ||
| } | ||
@@ -458,2 +714,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.CLIENT_CLOSED_REQUEST; | ||
| } | ||
| } | ||
@@ -465,2 +725,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.TOKEN_REQUIRED; | ||
| } | ||
| } | ||
@@ -472,2 +736,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.INTERNAL_SERVER_ERROR; | ||
| } | ||
| } | ||
@@ -479,2 +747,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NOT_IMPLEMENTED; | ||
| } | ||
| } | ||
@@ -486,2 +758,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.BAD_GATEWAY; | ||
| } | ||
| } | ||
@@ -493,2 +769,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.SERVICE_UNAVAILABLE; | ||
| } | ||
| } | ||
@@ -500,2 +780,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.GATEWAY_TIMEOUT; | ||
| } | ||
| } | ||
@@ -507,2 +791,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.HTTP_VERSION_NOT_SUPPORTED; | ||
| } | ||
| } | ||
@@ -514,2 +802,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.VARIANT_ALSO_NEGOTIATES; | ||
| } | ||
| } | ||
@@ -521,2 +813,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.INSUFFICIENT_STORAGE; | ||
| } | ||
| } | ||
@@ -528,2 +824,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.LOOP_DETECTED; | ||
| } | ||
| } | ||
@@ -535,2 +835,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.BANDWIDTH_LIMIT_EXCEEDED; | ||
| } | ||
| } | ||
@@ -542,2 +846,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NOT_EXTENDED; | ||
| } | ||
| } | ||
@@ -549,2 +857,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NETWORK_AUTHENTICATION_REQUIRED; | ||
| } | ||
| } | ||
@@ -556,2 +868,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.UNKNOWN_ERROR; | ||
| } | ||
| } | ||
@@ -563,2 +879,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.ORIGIN_CONNECTION_TIMEOUT; | ||
| } | ||
| } | ||
@@ -570,2 +890,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NETWORK_READ_TIMEOUT; | ||
| } | ||
| } | ||
@@ -577,2 +901,6 @@ | ||
| } | ||
| static get code () { | ||
| return http.codes.NETWORK_CONNECT_TIMEOUT_ERROR; | ||
| } | ||
| } | ||
@@ -579,0 +907,0 @@ |
+1
-1
| { | ||
| "name": "@comodinx/http-errors", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "@comodinx/http-errors is a Node.js http errors classes.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+88
-0
@@ -9,2 +9,3 @@ # Http Errors | ||
| * [How is it used?][how_is_it_used]. | ||
| * [Available errors][available_errors]. | ||
| * [Tests][tests]. | ||
@@ -45,2 +46,88 @@ | ||
| ## Available errors | ||
| * Continue | ||
| * SwitchingProtocols | ||
| * Processing | ||
| * Ok | ||
| * Created | ||
| * Accepted | ||
| * NonAuthoritativeInformation | ||
| * NoContent | ||
| * ResetContent | ||
| * PartialContent | ||
| * MultiStatus | ||
| * AlreadyReported | ||
| * ImUsed | ||
| * MultipleChoices | ||
| * MovedPermanently | ||
| * Found | ||
| * SeeOther | ||
| * NotModified | ||
| * UseProxy | ||
| * SwitchProxy | ||
| * TemporaryRedirect | ||
| * PermanentRedirect | ||
| * ResumeIncomplete | ||
| * BadRequest | ||
| * Unauthorized | ||
| * PaymentRequired | ||
| * Forbidden | ||
| * NotFound | ||
| * MethodNotAllowed | ||
| * NotAcceptable | ||
| * ProxyAuthenticationRequired | ||
| * RequestTimeout | ||
| * Conflict | ||
| * Gone | ||
| * LengthRequired | ||
| * PreconditionFailed | ||
| * PayloadTooLarge | ||
| * UriTooLong | ||
| * UnsupportedMediaType | ||
| * RangeNotSatisfiable | ||
| * ExpectationFailed | ||
| * ImATeapot | ||
| * AuthenticationTimeout | ||
| * MethodFailure | ||
| * EnhanceYourCalm | ||
| * MisdirectedRequest | ||
| * UnprocessableEntity | ||
| * Locked | ||
| * FailedDependency | ||
| * UpgradeRequired | ||
| * PreconditionRequired | ||
| * TooManyRequests | ||
| * RequestHeaderFieldsTooLarge | ||
| * LoginTimeout | ||
| * NoResponse | ||
| * RetryWith | ||
| * BlockedByWindowsParentalControls | ||
| * UnavailableForLegalReasons | ||
| * Redirect | ||
| * RequestHeaderTooLarge | ||
| * CertError | ||
| * NoCert | ||
| * HttpToHttps | ||
| * TokenExpiredInvalid | ||
| * ClientClosedRequest | ||
| * TokenRequired | ||
| * InternalServerError | ||
| * NotImplemented | ||
| * BadGateway | ||
| * ServiceUnavailable | ||
| * GatewayTimeout | ||
| * HttpVersionNotSupported | ||
| * VariantAlsoNegotiates | ||
| * InsufficientStorage | ||
| * LoopDetected | ||
| * BandwidthLimitExceeded | ||
| * NotExtended | ||
| * NetworkAuthenticationRequired | ||
| * UnknownError | ||
| * OriginConnectionTimeout | ||
| * NetworkReadTimeout | ||
| * NetworkConnectTimeoutError | ||
| * JsonErrorResponse | ||
| * CustomError | ||
| ## Tests | ||
@@ -63,2 +150,3 @@ | ||
| [how_is_it_used]: #how-is-it-used | ||
| [available_errors]: #available-errors | ||
| [tests]: #tests |
+12
-49
@@ -7,57 +7,20 @@ 'use strict'; | ||
| describe('@comodinx/errors', () => { | ||
| describe('InternalServerError', () => { | ||
| it(`should return code/status ${http.codes.INTERNAL_SERVER_ERROR}`, done => { | ||
| const result = new errors.InternalServerError(); | ||
| Object.keys(errors).forEach(errorName => { | ||
| const ErrorClass = errors[errorName]; | ||
| expect(result).to.have.property('code').to.be.a('number').equal(http.codes.INTERNAL_SERVER_ERROR); | ||
| expect(result).to.have.property('message').to.be.a('string').equal('Internal Server Error'); | ||
| if (!ErrorClass.code) { | ||
| return; | ||
| } | ||
| done(); | ||
| }); | ||
| }); | ||
| describe(errorName, () => { | ||
| it(`should return code/status ${ErrorClass.code}`, done => { | ||
| const result = new ErrorClass(errorName); | ||
| describe('NotFound', () => { | ||
| it(`should return code/status ${http.codes.NOT_FOUND}`, done => { | ||
| const result = new errors.NotFound(); | ||
| expect(result).to.have.property('code').to.be.a('number').equal(http.codes.NOT_FOUND); | ||
| expect(result).to.have.property('message').to.be.a('string').equal('Not Found'); | ||
| done(); | ||
| expect(result).to.have.property('code').to.be.a('number').equal(ErrorClass.code); | ||
| expect(result).to.have.property('message').to.be.a('string').equal(errorName); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| describe('Conflict', () => { | ||
| it(`should return code/status ${http.codes.CONFLICT}`, done => { | ||
| const result = new errors.Conflict(); | ||
| expect(result).to.have.property('code').to.be.a('number').equal(http.codes.CONFLICT); | ||
| expect(result).to.have.property('message').to.be.a('string').equal('Conflict'); | ||
| done(); | ||
| }); | ||
| }); | ||
| describe('Unauthorized', () => { | ||
| it(`should return code/status ${http.codes.UNAUTHORIZED}`, done => { | ||
| const result = new errors.Unauthorized(); | ||
| expect(result).to.have.property('code').to.be.a('number').equal(http.codes.UNAUTHORIZED); | ||
| expect(result).to.have.property('message').to.be.a('string').equal('Unauthorized'); | ||
| done(); | ||
| }); | ||
| }); | ||
| describe('BadRequest', () => { | ||
| it(`should return code/status ${http.codes.BAD_REQUEST}`, done => { | ||
| const result = new errors.BadRequest(); | ||
| expect(result).to.have.property('code').to.be.a('number').equal(http.codes.BAD_REQUEST); | ||
| expect(result).to.have.property('message').to.be.a('string').equal('Bad Request'); | ||
| done(); | ||
| }); | ||
| }); | ||
| describe('JsonErrorResponse', () => { | ||
@@ -64,0 +27,0 @@ it(`should return code/status ${http.codes.INTERNAL_SERVER_ERROR}`, done => { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
29158
28.25%823
36.48%150
141.94%