https://github.com/pkolt/express-asyncify
Easy support async/await to express
https://github.com/pkolt/express-asyncify
async express nodejs
Last synced: 6 months ago
JSON representation
Easy support async/await to express
- Host: GitHub
- URL: https://github.com/pkolt/express-asyncify
- Owner: pkolt
- License: mit
- Created: 2017-01-04T09:56:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-12-16T23:16:40.000Z (11 months ago)
- Last Synced: 2025-05-07T15:07:11.080Z (6 months ago)
- Topics: async, express, nodejs
- Language: JavaScript
- Homepage:
- Size: 300 KB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# express-asyncify 
Easy support `async/await` to [express](http://expressjs.com/).
🚨 Since v3:
- Node.js >= 20
- Only ESM modules
## Installation
```bash
$ npm i express express-asyncify
```
## Usage
Asyncify express application:
```javascript
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:
```javascript
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`:
```bash
$ npm ci
$ npm test
```
## License
[MIT](LICENSE.md)