@yun-jie/middleware
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

middleware

Simple middleware pattern engine

npm install --save @yun-jie/middleware
import { middleware, Middleware } from '@yun-jie/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

Dependencies (0)

    Dev Dependencies (16)

    Package Sidebar

    Install

    npm i @yun-jie/middleware

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    8.6 kB

    Total Files

    13

    Last publish

    Collaborators

    • yunxiaochu