koa-2-error-handler
Advanced tools
Comparing version 0.0.1 to 0.0.2
22
index.js
@@ -1,19 +0,3 @@ | ||
const debug = require('debug')('error:handler'); | ||
const httpStatus = require('http-status-codes'); | ||
exports.error = callback => async (ctx, next) => { | ||
try { | ||
await next(); | ||
return ctx.response.status === httpStatus.NOT_FOUND ? ctx.throw(httpStatus.NOT_FOUND) : true; | ||
} catch (err) { | ||
debug(err); | ||
ctx.status = err.statusCode || err.status || httpStatus.INTERNAL_SERVER_ERROR; | ||
if (callback) { | ||
callback(err, ctx); | ||
} else { | ||
ctx.body = { | ||
message: err.message | ||
}; | ||
} | ||
} | ||
}; | ||
exports.error = require('./lib/error'); | ||
exports.helper = require('./lib/helper'); | ||
exports.server = require('./lib/server'); |
{ | ||
"name": "koa-2-error-handler", | ||
"description": "Error reponses for koa 2", | ||
"description": "Error handler for Koa 2 application.", | ||
"repository": "evheniy/koa-2-error-handler", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"scripts": { | ||
"start": "node --harmony ./bin/www", | ||
"test": "npm run security && npm run clear && npm run lint && npm run coverage", | ||
"lint": "./node_modules/.bin/eslint index.js tests", | ||
"lint": "./node_modules/.bin/eslint index.js tests lib", | ||
"coverage": "node --harmony ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- tests --recursive", | ||
"report-coverage": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls", | ||
"clear": "./node_modules/.bin/rimraf coverage", | ||
@@ -27,5 +28,3 @@ "security": "./node_modules/.bin/nsp check" | ||
"dependencies": { | ||
"http-status-codes": "^1.1.6", | ||
"koa": "^2.0.0-alpha.7", | ||
"koa-router": "^7.0.1" | ||
"http-status-codes": "^1.1.6" | ||
}, | ||
@@ -35,6 +34,10 @@ "devDependencies": { | ||
"chai-http": "^3.0.0", | ||
"coveralls": "^2.11.15", | ||
"debug": "^2.6.0", | ||
"eslint": "^3.14.1", | ||
"istanbul": "^1.1.0-alpha.1", | ||
"koa": "^2.0.0-alpha.7", | ||
"koa-router": "^7.0.1", | ||
"mocha": "^3.2.0", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"nsp": "^2.6.2", | ||
@@ -41,0 +44,0 @@ "rimraf": "^2.5.4", |
@@ -6,2 +6,3 @@ Koa.js 2 error handler | ||
[![Build Status](https://travis-ci.org/evheniy/koa-2-error-handler.svg?branch=master)](https://travis-ci.org/evheniy/koa-2-error-handler) | ||
[![Coverage Status](https://coveralls.io/repos/github/evheniy/koa-2-error-handler/badge.svg?branch=master)](https://coveralls.io/github/evheniy/koa-2-error-handler?branch=master) | ||
@@ -12,3 +13,3 @@ | ||
Error response middleware for koa 2 supporting. | ||
Error handler for Koa 2 application. | ||
@@ -15,0 +16,0 @@ |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
1
30
2235
14
2
- Removedkoa@^2.0.0-alpha.7
- Removedkoa-router@^7.0.1
- Removedaccepts@1.3.8(transitive)
- Removedany-promise@1.3.0(transitive)
- Removedcache-content-type@1.0.1(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedco@4.6.0(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookies@0.9.1(transitive)
- Removeddebug@3.2.74.4.0(transitive)
- Removeddeep-equal@1.0.1(transitive)
- Removeddelegates@1.0.0(transitive)
- Removeddepd@1.1.22.0.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.2(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-assert@1.5.0(transitive)
- Removedhttp-errors@1.8.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-generator-function@1.1.0(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedisarray@0.0.1(transitive)
- Removedkeygrip@1.1.0(transitive)
- Removedkoa@2.15.3(transitive)
- Removedkoa-compose@3.2.14.2.0(transitive)
- Removedkoa-convert@2.0.0(transitive)
- Removedkoa-router@7.4.0(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedms@2.1.3(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedonly@0.0.2(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@1.9.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafe-regex-test@1.1.0(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedstatuses@1.5.0(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtsscmp@1.0.6(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedurijs@1.19.11(transitive)
- Removedvary@1.1.2(transitive)
- Removedylru@1.4.0(transitive)