https://github.com/rimiti/express-async
🦑 Async wrapper for express functions.
https://github.com/rimiti/express-async
async controller controllers express router
Last synced: 5 months ago
JSON representation
🦑 Async wrapper for express functions.
- Host: GitHub
- URL: https://github.com/rimiti/express-async
- Owner: rimiti
- License: mit
- Created: 2019-02-02T13:07:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-08T08:51:49.000Z (about 7 years ago)
- Last Synced: 2025-03-26T15:48:12.587Z (12 months ago)
- Topics: async, controller, controllers, express, router
- Language: TypeScript
- Homepage: https://dimsolution.com/blog/2019-02-12/how-to-use-async-await-functions-with-express/
- Size: 95.7 KB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-async
[![Build Status][travis-badge]][travis]
[![Dependencies][prod-dependencies-badge]][prod-dependencies]
[![MIT License][license-badge]][LICENSE]
[![PRs Welcome][prs-badge]][prs]
## Description
Async wrapper for express functions.
## Install
```bash
$ npm i @rimiti/express-async -S
```
## How to use it?
### Importation
From commonJS
```js
const {wrapAsync} = require('@rimiti/express-async');
```
or from ES6:
```js
import {wrapAsync} from '@rimiti/express-async';
```
### Example
```js
import express from 'express';
import {wrapAsync} from '@rimiti/express-async';
const app = express();
app.get('/example-1', wrapAsync(async function example1(req, res, next) {
res.status(200).send({example: 1});
}));
app.get('/example-2', wrapAsync(async function example2(req, res) {
res.status(200).send({example: 2});
}));
```
## Scripts
Run using yarn run `` command.
clean - Remove temporarily folders.
build - Compile source files.
build:watch - Interactive watch mode, compile sources on change.
lint - Lint source files.
lint:fix - Lint source files and auto-fix.
## Credits
This package has been inspired by [express-async-handler](https://github.com/Abazhenov/express-async-handler) but
it has been totally rewrited in TypeScript.
## License
MIT © [Dimitri DO BAIRRO](https://github.com/rimiti/express-async/blob/master/LICENSE)
[prod-dependencies-badge]: https://david-dm.org/rimiti/express-async/status.svg
[prod-dependencies]: https://david-dm.org/rimiti/express-async
[travis-badge]: https://travis-ci.org/rimiti/express-async.svg?branch=master
[travis]:https://travis-ci.org/rimiti/express-async
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
[license]: https://github.com/rimiti/express-async/blob/master/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com