# express-async-wrap **Repository Path**: mirrors_felixfbecker/express-async-wrap ## Basic Information - **Project Name**: express-async-wrap - **Description**: Allows the use of ES2016 async functions as Express route handlers - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-03-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # express-async-wrap Allows the use of ES2016 async functions as Express route handlers. ## Install ```javascript npm i express-async-wrap ``` ## Usage To use in place of a normal route handler: ```javascript import wrap from 'express-async-wrap'; function makeResult(result) { return new Promise((resolve) => { setTimeout(() => resolve(result), 10); }); } app.get('/', wrap(async function(req, res) { const results = []; for(let i = 0; i < 5; i++) { results.push(makeResult(`test${i}`)); } res.send((await* results).join()); })); ``` To use as an error handler: ```javascript import wrap from 'express-async-wrap'; app.get('/', wrap(async function(req, res, next) { next(new Error('error')); })); app.use(wrap(async function(err, req, res, next) { res.status(500).send('error'); })); ```