Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

express-asyncify

1.0.0 • Public • Published

express-asyncify Build Status

Easy support async/await to express.

Installation

$ npm install express-asyncify --save

Usage

Asyncify express application:

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

Asyncify express router:

const express = require('express');
const asyncify = require('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 install
$ npm test

License

MIT

install

npm i express-asyncify

Downloadsweekly downloads

271

version

1.0.0

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar