httpexceptions
Advanced tools
Comparing version 1.2.4 to 1.3.0
38
index.js
"use strict"; | ||
var exception_1 = require("./lib/exception"); | ||
exports.Exception = exception_1.Exception; | ||
exports.HTTPException = exception_1.Exception; | ||
var badgateway_1 = require("./lib/badgateway"); | ||
exports.BadGateway = badgateway_1.BadGateway; | ||
var badrequest_1 = require("./lib/badrequest"); | ||
exports.BadRequest = badrequest_1.BadRequest; | ||
var forbidden_1 = require("./lib/forbidden"); | ||
exports.Forbidden = forbidden_1.Forbidden; | ||
var gatewaytimeout_1 = require("./lib/gatewaytimeout"); | ||
exports.GatewayTimeout = gatewaytimeout_1.GatewayTimeout; | ||
var internalservererror_1 = require("./lib/internalservererror"); | ||
exports.InternalServerError = internalservererror_1.InternalServerError; | ||
var methodnotallowed_1 = require("./lib/methodnotallowed"); | ||
exports.MethodNotAllowed = methodnotallowed_1.MethodNotAllowed; | ||
var notacceptable_1 = require("./lib/notacceptable"); | ||
exports.NotAcceptable = notacceptable_1.NotAcceptable; | ||
var notfound_1 = require("./lib/notfound"); | ||
exports.NotFound = notfound_1.NotFound; | ||
var notimplemented_1 = require("./lib/notimplemented"); | ||
exports.NotImplemented = notimplemented_1.NotImplemented; | ||
var paymentrequired_1 = require("./lib/paymentrequired"); | ||
exports.PaymentRequired = paymentrequired_1.PaymentRequired; | ||
var proxyerror_1 = require("./lib/proxyerror"); | ||
exports.ProxyError = proxyerror_1.ProxyError; | ||
var serviceunvailable_1 = require("./lib/serviceunvailable"); | ||
exports.ServiceUnvailable = serviceunvailable_1.ServiceUnvailable; | ||
var unauthorized_1 = require("./lib/unauthorized"); | ||
var paramsrequired_1 = require("./paramsrequired"); | ||
var mime_1 = require("./mime"); | ||
exports.HTTPException = exception_1.Exception; | ||
exports.Exception = exception_1.Exception; | ||
exports.BadGateway = badgateway_1.BadGateway; | ||
exports.BadRequest = badrequest_1.BadRequest; | ||
exports.Forbidden = forbidden_1.Forbidden; | ||
exports.GatewayTimeout = gatewaytimeout_1.GatewayTimeout; | ||
exports.InternalServerError = internalservererror_1.InternalServerError; | ||
exports.MethodNotAllowed = methodnotallowed_1.MethodNotAllowed; | ||
exports.NotAcceptable = notacceptable_1.NotAcceptable; | ||
exports.NotFound = notfound_1.NotFound; | ||
exports.NotImplemented = notimplemented_1.NotImplemented; | ||
exports.PaymentRequired = paymentrequired_1.PaymentRequired; | ||
exports.ProxyError = proxyerror_1.ProxyError; | ||
exports.ServiceUnvailable = serviceunvailable_1.ServiceUnvailable; | ||
exports.Unauthorized = unauthorized_1.Unauthorized; | ||
function paramsRequired() { | ||
return paramsrequired_1.paramsRequired(); | ||
} | ||
exports.paramsRequired = paramsRequired; | ||
function mime(list) { | ||
return mime_1.mime(list); | ||
} | ||
exports.mime = mime; | ||
//# sourceMappingURL=index.js.map |
71
index.ts
@@ -1,41 +0,32 @@ | ||
import {Exception as _Exception} from "./lib/exception"; | ||
import {BadGateway as _BadGateway} from "./lib/badgateway"; | ||
import {BadRequest as _BadRequest} from "./lib/badrequest"; | ||
import {Forbidden as _Forbidden} from "./lib/forbidden"; | ||
import {GatewayTimeout as _GatewayTimeout} from "./lib/gatewaytimeout"; | ||
import {InternalServerError as _InternalServerError} from "./lib/internalservererror"; | ||
import {MethodNotAllowed as _MethodNotAllowed} from "./lib/methodnotallowed"; | ||
import {NotAcceptable as _NotAcceptable} from "./lib/notacceptable"; | ||
import {NotFound as _NotFound} from "./lib/notfound"; | ||
import {NotImplemented as _NotImplemented} from "./lib/notimplemented"; | ||
import {PaymentRequired as _PaymentRequired} from "./lib/paymentrequired"; | ||
import {ProxyError as _ProxyError} from "./lib/proxyerror"; | ||
import {ServiceUnvailable as _ServiceUnvailable} from "./lib/serviceunvailable"; | ||
import {Unauthorized as _Unauthorized} from "./lib/unauthorized"; | ||
import {paramsRequired as _paramsRequired} from "./paramsrequired"; | ||
import {mime as _mime} from "./mime"; | ||
import {Exception} from "./lib/exception"; | ||
import {BadGateway} from "./lib/badgateway"; | ||
import {BadRequest} from "./lib/badrequest"; | ||
import {Forbidden} from "./lib/forbidden"; | ||
import {GatewayTimeout} from "./lib/gatewaytimeout"; | ||
import {InternalServerError} from "./lib/internalservererror"; | ||
import {MethodNotAllowed} from "./lib/methodnotallowed"; | ||
import {NotAcceptable} from "./lib/notacceptable"; | ||
import {NotFound} from "./lib/notfound"; | ||
import {NotImplemented} from "./lib/notimplemented"; | ||
import {PaymentRequired} from "./lib/paymentrequired"; | ||
import {ProxyError} from "./lib/proxyerror"; | ||
import {ServiceUnvailable} from "./lib/serviceunvailable"; | ||
import {Unauthorized} from "./lib/unauthorized"; | ||
export const HTTPException = _Exception; | ||
export const Exception = _Exception; | ||
export const BadGateway = _BadGateway; | ||
export const BadRequest = _BadRequest; | ||
export const Forbidden = _Forbidden; | ||
export const GatewayTimeout = _GatewayTimeout; | ||
export const InternalServerError = _InternalServerError; | ||
export const MethodNotAllowed = _MethodNotAllowed; | ||
export const NotAcceptable = _NotAcceptable; | ||
export const NotFound = _NotFound; | ||
export const NotImplemented = _NotImplemented; | ||
export const PaymentRequired = _PaymentRequired; | ||
export const ProxyError = _ProxyError; | ||
export const ServiceUnvailable = _ServiceUnvailable; | ||
export const Unauthorized = _Unauthorized; | ||
export function paramsRequired(){ | ||
return _paramsRequired(); | ||
} | ||
export function mime(list:Array<string>|string){ | ||
return _mime(list); | ||
} | ||
export { | ||
Exception, | ||
Exception as HTTPException, | ||
BadGateway, | ||
BadRequest, | ||
Forbidden, | ||
GatewayTimeout, | ||
InternalServerError, | ||
MethodNotAllowed, | ||
NotAcceptable, | ||
NotFound, | ||
NotImplemented, | ||
PaymentRequired, | ||
ProxyError, | ||
ServiceUnvailable, | ||
Unauthorized | ||
} |
{ | ||
"name": "httpexceptions", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "Provide exception for HTTP Rest API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,8 +42,2 @@ # httpexceptions | ||
httpExceptions.debug(true); | ||
app.use(httpExceptions.mime('application/json')); | ||
// OR | ||
// app.use(httpExceptions.mime(['application/json', 'text/xml'])); | ||
app.get('/my/route', function(req, res){ | ||
@@ -59,20 +53,13 @@ | ||
req.paramsRequired({ | ||
query:['id'] | ||
}); //throw a BadRequest exception if the parameters id isn't defined in queryParams | ||
if (req.params.id === undefined){ | ||
throw new httpExceptions.BadRequest(); | ||
} | ||
}); | ||
app.post('/my/route/params', function(req, res){ | ||
req.paramsRequired({ | ||
body:['id'] | ||
}); //throw a BadRequest exception if the parameters id isn't defined in bodyParams | ||
}); | ||
//GlobalHandler middleware catch exception and send response to the client | ||
app.use(function(err, request, response){ | ||
if(err instanceof HTTPExpcetions.HTTPException){ | ||
if(err instanceof HTTPExpcetions.Exception){ | ||
response.status(err.status).send(err.message); | ||
@@ -79,0 +66,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18538
22
393
89