Skip to content

A lightweight promise based async middleware package with complete typings

Notifications You must be signed in to change notification settings

Pranit-Harekar/async-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircleCI TypeScript code style: prettier Packagist

Asynchronous Middleware Package

This package provides minimal implementation for promise based asynchronous middleware pattern with complete typings.

Installation

Using npm:

$ npm i async-middleware-ts

API

  • use(middleware: Middleware<Request, Response>)

  • go(request: Request, handler: Handler<Request, Response>): Promise<Response>

Usage Examples:

const mw = new MiddlewareStack<your-request-type, your-response-type>()

mw.use((request, handler) => {
  handler(request)
})

const result = await mw.go(your-request, async () => {
  // your-async-app-function
  return 'result'
})

About

A lightweight promise based async middleware package with complete typings

Topics

Resources

Stars

Watchers

Forks

Packages