Gathering detailed insights and metrics for @elunic/express-async-error-wrapper
Gathering detailed insights and metrics for @elunic/express-async-error-wrapper
Gathering detailed insights and metrics for @elunic/express-async-error-wrapper
Gathering detailed insights and metrics for @elunic/express-async-error-wrapper
A simple, minimalistic wrapper for Express middlewares that ensures errors from middleware promises are handled properly; correctly wraps non-async functions
npm install @elunic/express-async-error-wrapper
Typescript
Module System
Node Version
NPM Version
TypeScript (99.27%)
JavaScript (0.73%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
14 Commits
1 Watchers
8 Branches
2 Contributors
Updated on Nov 19, 2019
Latest Version
0.0.10
Package Id
@elunic/express-async-error-wrapper@0.0.10
Unpacked Size
7.84 kB
Size
2.77 kB
File Count
5
NPM Version
6.11.3
Node Version
10.17.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A simple, minimalistic wrapper for Express middlewares that ensures errors from middleware promises are handled properly; correctly wraps non-async functions
Ensures errors in promises from async route handlers/middlewares do not float around an crash your server.
Does not expect wrapper middlewares to return a promise, so you don't have to worry about changing your middleware functions from sync to async.
Does not call next()
for you. If you have an async route/middleware and forget to call next()
or res.send()
, you're on your own.
1$ npm install @elunic/express-async-error-wrapper
Examples:
1const app = require('express')(); 2const asyncErrorWrapper = require('@elunic/express-async-error-wrapper'); 3// In TypeScript: 4// import { asyncErrorWrapper } from '@elunic/express-async-error-wrapper'; 5 6app.get('/get1', asyncErrorWrapper(async (req, res) => { 7 await new Promise(resolve => setTimeout(resolve, 1)); 8 throw new Error('Error 1'); 9})); 10 11app.get('/get2', async (req, res) => { 12 throw new Error('Error 2'); 13}); 14 15app.use(function(err, req, res, next) { 16 // Will catch Error 1, but not Error 2 17}); 18 19app.listen(80);
1const app = require('express')(); 2const asyncErrorWrapper = require('@elunic/express-async-error-wrapper'); 3 4app.get('/get1', asyncErrorWrapper(async (req, res) => { 5 await new Promise(resolve => setTimeout(resolve, 1)); 6 throw new Error('Error 1'); 7})); 8 9app.get(asyncErrorWrapper(async (err, req, res, next) => { 10 await new Promise(resolve => setTimeout(resolve, 1)); 11 throw new Error('Error handler error: ' + err.toString()); 12})); 13 14app.use(function(err, req, res, next) { 15 // Will get called with the error handler's error 16}); 17 18app.listen(80);
(The MIT License)
Copyright (c) 2018 elunic <wh@elunic.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/10 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
42 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More