Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Latest commit

 

History

History
36 lines (26 loc) · 614 Bytes

README.md

File metadata and controls

36 lines (26 loc) · 614 Bytes

middleware

Simple middleware pattern engine

npm install --save @pawelgalazka/middleware
import { middleware, Middleware } from '@pawelgalazka/middleware'

interface IMiddlewareArguments {
  arg1: string
  arg2: string
}

type CustomMiddleware = Middleware<IMiddlewareArguments>


const middleware1: CustomMiddleware = next => ({arg1, arg2}) => {
  next({
    arg1: arg1 + 'e'
    arg2: arg2 + 'f'
  })

}

const middleware2: CustomMiddleware = next => ({arg1, arg2}) => {
  console.log('ARGS', arg1, arg2)
}

middleware([middleware1, middleware2])({arg1: 'a', arg2: 'b'})
ARGS ae bf