1.0.1 • Published 7 years ago
express-async-error-handler v1.0.1
express-async-error-handler
I'm not sure why this doesn't exist already. Handles a
Usage
const asyncErrorHandler = require('express-async-error-handler')
const express = require('express')
const router = express.Router()
// Route
router.post('/hello', asyncErrorHandler(async function() {
await thisWillThrowAnError()
}))
// Error handler
router.use(function(err, req, res, next) {
res.status(err.status || 500)
})
1.0.1
7 years ago