{"_id":"express-async-errors","_rev":"2956446","name":"express-async-errors","description":"Async/await error handling support for expressjs","dist-tags":{"assume-promise":"2.1.1","latest":"3.1.1"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"time":{"modified":"2023-04-27T07:38:22.000Z","created":"2016-12-07T05:05:09.483Z","3.1.1":"2018-10-12T05:11:57.544Z","3.1.0":"2018-10-12T05:05:38.283Z","3.0.0":"2018-06-03T23:39:40.507Z","2.1.2":"2018-02-15T22:59:51.545Z","2.1.1":"2017-11-01T00:21:54.482Z","2.1.0":"2017-11-01T00:02:00.773Z","2.0.0":"2016-12-07T05:05:09.483Z"},"users":{},"author":{"name":"david@banham.id.au"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"versions":{"3.1.1":{"name":"express-async-errors","version":"3.1.1","description":"Async/await error handling support for expressjs","main":"index.js","scripts":{"coverage":"nyc mocha test.js","report":"nyc report --reporter=html","test":"mocha test.js","lint":"eslint .","precommit":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"keywords":["expressjs","async/await","async","await","es6"],"author":{"name":"david@banham.id.au"},"license":"ISC","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"homepage":"https://github.com/davidbanham/express-async-errors#readme","peerDependencies":{"express":"^4.16.2"},"devDependencies":{"eslint":"^5.6.1","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","express":"^4.16.2","husky":"^0.14.3","mocha":"^4.0.1","nyc":"^13.0.1","supertest":"^3.0.0"},"gitHead":"478ebf7330a20b14b6c589c3d6f7fc3107d78dd9","_id":"express-async-errors@3.1.1","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"davidbanham","email":"david@banham.id.au"},"dist":{"shasum":"6053236d61d21ddef4892d6bd1d736889fc9da41","size":18014,"noattachment":false,"key":"/express-async-errors/-/express-async-errors-3.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-async-errors/download/express-async-errors-3.1.1.tgz"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-async-errors_3.1.1_1539321117397_0.5607541270549143"},"_hasShrinkwrap":false,"publish_time":1539321117544,"_cnpm_publish_time":1539321117544,"_cnpmcore_publish_time":"2021-12-16T17:30:34.661Z"},"3.1.0":{"name":"express-async-errors","version":"3.1.0","description":"Async/await error handling support for expressjs","main":"index.js","scripts":{"coverage":"nyc mocha test.js","report":"nyc report --reporter=html","test":"mocha test.js","lint":"eslint .","precommit":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"keywords":["expressjs","async/await","async","await","es6"],"author":{"name":"david@banham.id.au"},"license":"ISC","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"homepage":"https://github.com/davidbanham/express-async-errors#readme","peerDependencies":{"express":"^4.16.2"},"devDependencies":{"eslint":"^4.10.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","express":"^4.16.2","husky":"^0.14.3","mocha":"^4.0.1","nyc":"^13.0.1","supertest":"^3.0.0"},"gitHead":"573c516ef650a37db1f03277e4161437c6d5819d","_id":"express-async-errors@3.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"davidbanham","email":"david@banham.id.au"},"dist":{"shasum":"f2701e4bd8b7281c4fd684a40345c0268990dcde","size":18020,"noattachment":false,"key":"/express-async-errors/-/express-async-errors-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-async-errors/download/express-async-errors-3.1.0.tgz"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-async-errors_3.1.0_1539320738149_0.765378590930631"},"_hasShrinkwrap":false,"publish_time":1539320738283,"_cnpm_publish_time":1539320738283,"_cnpmcore_publish_time":"2021-12-16T17:30:34.877Z"},"3.0.0":{"name":"express-async-errors","version":"3.0.0","description":"Async/await error handling support for expressjs","main":"index.js","scripts":{"test":"mocha test.js","lint":"eslint .","precommit":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"keywords":["expressjs","async/await","async","await","es6"],"author":{"name":"david@banham.id.au"},"license":"ISC","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"homepage":"https://github.com/davidbanham/express-async-errors#readme","peerDependencies":{"express":"^4.16.2"},"devDependencies":{"eslint":"^4.10.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","express":"^4.16.2","husky":"^0.14.3","mocha":"^4.0.1","supertest":"^3.0.0"},"gitHead":"c878b17de25909b0e01b6d0f374a06892b868d5d","_id":"express-async-errors@3.0.0","_npmVersion":"6.0.1","_nodeVersion":"10.1.0","_npmUser":{"name":"davidbanham","email":"david@banham.id.au"},"dist":{"shasum":"457d06952504718276697cebf9c332bccf2944dd","size":17823,"noattachment":false,"key":"/express-async-errors/-/express-async-errors-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-async-errors/download/express-async-errors-3.0.0.tgz"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-async-errors_3.0.0_1528069180302_0.9789578814020514"},"_hasShrinkwrap":false,"publish_time":1528069180507,"_cnpm_publish_time":1528069180507,"_cnpmcore_publish_time":"2021-12-16T17:30:35.081Z"},"2.1.2":{"name":"express-async-errors","version":"2.1.2","description":"Async/await error handling support for expressjs","main":"index.js","scripts":{"test":"mocha test.js","lint":"eslint .","precommit":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"keywords":["expressjs","async/await","async","await","es6"],"author":{"name":"david@banham.id.au"},"license":"ISC","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"homepage":"https://github.com/davidbanham/express-async-errors#readme","peerDependencies":{"express":"^4.16.2"},"devDependencies":{"eslint":"^4.10.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","express":"^4.16.2","husky":"^0.14.3","mocha":"^4.0.1","supertest":"^3.0.0"},"gitHead":"6a5e7bc50640399c0944aaba5baf79738bfd802d","_id":"express-async-errors@2.1.2","_npmVersion":"5.4.2","_nodeVersion":"8.9.4","_npmUser":{"name":"davidbanham","email":"david@banham.id.au"},"dist":{"shasum":"a5692a0763904109f27d9649b4f827cf89100f53","size":17367,"noattachment":false,"key":"/express-async-errors/-/express-async-errors-2.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-async-errors/download/express-async-errors-2.1.2.tgz"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-async-errors_2.1.2_1518735591399_0.46574146163681673"},"_hasShrinkwrap":false,"publish_time":1518735591545,"_cnpm_publish_time":1518735591545,"_cnpmcore_publish_time":"2021-12-16T17:30:35.263Z"},"2.1.1":{"name":"express-async-errors","version":"2.1.1","description":"Async/await error handling support for expressjs","main":"index.js","scripts":{"test":"mocha test.js","lint":"eslint .","precommit":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"keywords":["expressjs","async/await","async","await","es6"],"author":{"name":"david@banham.id.au"},"license":"ISC","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"homepage":"https://github.com/davidbanham/express-async-errors#readme","dependencies":{"express":"^4.16.2"},"devDependencies":{"eslint":"^4.10.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","husky":"^0.14.3","mocha":"^4.0.1","supertest":"^3.0.0"},"gitHead":"99d4dad39f848094b0ebd30d716c55b55a117763","_id":"express-async-errors@2.1.1","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"davidbanham","email":"david@banham.id.au"},"dist":{"shasum":"0d3ba5a5af8747ec6e45093f8bf064364b3c37a1","size":16520,"noattachment":false,"key":"/express-async-errors/-/express-async-errors-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-async-errors/download/express-async-errors-2.1.1.tgz"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-async-errors-2.1.1.tgz_1509495714403_0.8182796374894679"},"directories":{},"publish_time":1509495714482,"_hasShrinkwrap":false,"_cnpm_publish_time":1509495714482,"_cnpmcore_publish_time":"2021-12-16T17:30:35.474Z"},"2.1.0":{"name":"express-async-errors","version":"2.1.0","description":"Async/await error handling support for expressjs","main":"index.js","scripts":{"test":"mocha test.js","lint":"eslint .","precommit":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"keywords":["expressjs","async/await","async","await","es6"],"author":{"name":"david@banham.id.au"},"license":"ISC","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"homepage":"https://github.com/davidbanham/express-async-errors#readme","dependencies":{"express":"^4.16.2"},"devDependencies":{"eslint":"^4.10.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","husky":"^0.14.3","mocha":"^4.0.1","supertest":"^3.0.0"},"gitHead":"6f32ffdf6eb5d5fa08ff9454140790fb3f333352","_id":"express-async-errors@2.1.0","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"davidbanham","email":"david@banham.id.au"},"dist":{"shasum":"67b536db21c20668d5cf637a8aa4a4868e54b06a","size":16560,"noattachment":false,"key":"/express-async-errors/-/express-async-errors-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-async-errors/download/express-async-errors-2.1.0.tgz"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-async-errors-2.1.0.tgz_1509494520709_0.5764178249519318"},"directories":{},"publish_time":1509494520773,"_hasShrinkwrap":false,"_cnpm_publish_time":1509494520773,"_cnpmcore_publish_time":"2021-12-16T17:30:35.674Z"},"2.0.0":{"name":"express-async-errors","version":"2.0.0","description":"Async/await error handling support for expressjs","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/davidbanham/express-async-errors.git"},"keywords":["expressjs","async/await","async","await","es6"],"author":{"name":"david@banham.id.au"},"license":"ISC","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"homepage":"https://github.com/davidbanham/express-async-errors#readme","gitHead":"db4ad1387e2327301eba8cc9b055baff71c87f28","_id":"express-async-errors@2.0.0","_shasum":"29a434cd44af22aaf8cc632b81ad4001d97b2e48","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.2.0","_npmUser":{"name":"davidbanham","email":"david@banham.id.au"},"dist":{"shasum":"29a434cd44af22aaf8cc632b81ad4001d97b2e48","size":1690,"noattachment":false,"key":"/express-async-errors/-/express-async-errors-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/express-async-errors/download/express-async-errors-2.0.0.tgz"},"maintainers":[{"name":"davidbanham","email":"david@banham.id.au"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/express-async-errors-2.0.0.tgz_1481087107625_0.10034122643992305"},"directories":{},"publish_time":1481087109483,"_hasShrinkwrap":false,"_cnpm_publish_time":1481087109483,"_cnpmcore_publish_time":"2021-12-16T17:30:35.934Z"}},"readme":"# ExpressJS Async Errors\n\n[![Build Status](https://travis-ci.org/davidbanham/express-async-errors.svg?branch=master)](https://travis-ci.org/davidbanham/express-async-errors)\n\nA dead simple ES6 async/await support hack for [ExpressJS](http://expressjs.com)\n\nShamelessly copied from [express-yields](https://github.com/MadRabbit/express-yields)\n\nThis has been lightly reworked to handle async rather than generators.\n\n## Usage\n\n```\nnpm install express-async-errors --save\n```\n\nThen require this script somewhere __before__ you start using it:\n\nAsync functions already work fine in Express.\n\n```js\nconst express = require('express');\nrequire('express-async-errors');\nconst User = require('./models/user');\nconst app = express();\n\napp.get('/users', async (req, res) => {\n  const users = await User.findAll();\n  res.send(users);\n});\n```\n\nThis library is about what happens when you hit an error.\n\n## A Notice About Calling `next`\n\nAs we all know express sends a function called `next` into the middleware, which\nthen needs to be called with or without error to make it move the request handling\nto the next middleware. It still works, but in case of an async function, you\ndon't need to do that. If you want to pass an error, just throw a normal exception:\n\n```js\napp.use(async (req, res) => {\n  const user = await User.findByToken(req.get('authorization'));\n\n  if (!user) throw Error(\"access denied\");\n});\n\napp.use((err, req, res, next) => {\n  if (err.message === 'access denied') {\n    res.status(403);\n    res.json({ error: err.message });\n  }\n\n  next(err);\n});\n```\n\n## How Does This Work?\n\nThis is a very minimalistic and unintrusive hack. Instead of patching all methods\non an express `Router`, it wraps the `Layer#handle` property in one place, leaving\nall the rest of the express guts intact.\n\nThe idea is that you require the patch once and then use the `'express'` lib the\nusual way in the rest of your application.\n\n## License\n\nAll code in this repository is released under the terms of the ISC license.\n","_attachments":{},"homepage":"https://github.com/davidbanham/express-async-errors#readme","bugs":{"url":"https://github.com/davidbanham/express-async-errors/issues"},"license":"ISC"}