Skip to content

rimiti/express-async

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

express-async

Build Status Dependencies MIT License PRs Welcome

Description

Async wrapper for express functions.

Install

$ npm i @rimiti/express-async -S

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

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