Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pkolt/express-asyncify
Easy support async/await to express
https://github.com/pkolt/express-asyncify
Last synced: 22 days 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 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-28T16:30:36.000Z (8 months ago)
- Last Synced: 2024-03-28T17:45:33.221Z (8 months ago)
- Language: TypeScript
- Size: 956 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# express-asyncify ![](https://github.com/pkolt/express-asyncify/workflows/main/badge.svg)
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)