Neptunium, Promethium, Manganese

    @goa/compose

    1.0.0 • Public • Published

    @goa/compose

    npm version

    @goa/compose is Compose a single middleware function for Goa out of many.

    yarn add @goa/compose

    Table Of Contents

    API

    The package is available by importing its default function:

    import compose from '@goa/compose'

    compose(
      middleware: !Array<!Function>,
    ): !Function

    Compose a single middleware function for Goa out of many.

    • middleware* !Array<!Function>: The array with the middleware.
    import Goa from '@goa/koa'
    import rqt from 'rqt'
    import compose from '@goa/compose'
    
    const goa = new Goa()
    
    const composed = compose([
      async (ctx, next) => {
        ctx.body = 'hello'
        await next()
      },
      async (ctx) => {
        ctx.body += ' world'
      },
    ])
    
    goa.use(composed)
    
    goa.listen(async function() {
      const url = `http://127.0.0.1:${this.address().port}`
      const res = await rqt(url)
      console.log(res)
      this.close()
    })
    hello world
    

    Copyright & License

    GNU Affero General Public License v3.0

    Original work by dead-horse under MIT license. Copy of the license is not included as not found in the original package.

    idiocc © Art Deco™ 2019

    Install

    npm i @goa/compose

    Homepage

    www.idio.cc/

    DownloadsWeekly Downloads

    0

    Version

    1.0.0

    License

    AGPL-3.0

    Unpacked Size

    43.2 kB

    Total Files

    13

    Last publish

    Collaborators

    • zvr