express-asyncify

v3.1.0
Easy support async/await to express
express async await

express-asyncify

Easy support async/await to express.

🚨 Since v3:

  • Node.js >= 20
  • Only ESM modules

Installation

$ npm i express express-asyncify

Usage

Asyncify express application:

import express from 'express';
import asyncify from 'express-asyncify';

const app = asyncify(express());

// ...

app.get('/', async (req, res) => {
    const posts = await Post.findAll();
    res.render('index', { posts });
});

Asyncify express router:

import express from 'express';
import asyncify from 'express-asyncify';

const app = express();
const router = asyncify(express.Router());

// ...

router.get('/', async (req, res) => {
    const posts = await Post.findAll();
    res.render('index', { posts });
});

app.use('/blog', router);

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm ci
$ npm test

License

MIT

npm i express-asyncify

Metadata

  • MIT
  • >= 20
  • Pavel Koltyshev
  • released 6/18/2024

Downloads

Maintainers