@rimiti/express-async

Async wrapper for express functions.

Usage no npm install needed!

<script type="module">
  import rimitiExpressAsync from 'https://cdn.skypack.dev/@rimiti/express-async';
</script>

README

express-async

Build Status Dependencies MIT License PRs Welcome

Description

Async wrapper for express functions.

How to use it?

Importation

From commonJS

const {wrapAsync} = require('@rimiti/express-async');

or from ES6:

import {wrapAsync} from '@rimiti/express-async';

Example

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});
}));

Install

$ npm i @rimiti/express-async -S

Scripts

Run using yarn run <script> 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 but it has been totally rewrited in TypeScript.

License

MIT © Dimitri DO BAIRRO