项目作者: rimiti

项目描述 :
🦑 Async wrapper for express functions.
高级语言: TypeScript
项目地址: git://github.com/rimiti/express-async.git
创建时间: 2019-02-02T13:07:05Z
项目社区:https://github.com/rimiti/express-async

开源协议:MIT License

下载


express-async

Build Status
Dependencies
MIT License
PRs Welcome

Description

Async wrapper for express functions.

Install

  1. $ npm i @rimiti/express-async -S

How to use it?

Importation

From commonJS

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

or from ES6:

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

Example

  1. import express from 'express';
  2. import {wrapAsync} from '@rimiti/express-async';
  3. const app = express();
  4. app.get('/example-1', wrapAsync(async function example1(req, res, next) {
  5. res.status(200).send({example: 1});
  6. }));
  7. app.get('/example-2', wrapAsync(async function example2(req, res) {
  8. res.status(200).send({example: 2});
  9. }));

Scripts

Run using yarn run <script> command.

  1. clean - Remove temporarily folders.
  2. build - Compile source files.
  3. build:watch - Interactive watch mode, compile sources on change.
  4. lint - Lint source files.
  5. 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