Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idiocc/compose
Compose a single middleware function for Goa out of many.
https://github.com/idiocc/compose
compose goa idio middleware
Last synced: about 2 months ago
JSON representation
Compose a single middleware function for Goa out of many.
- Host: GitHub
- URL: https://github.com/idiocc/compose
- Owner: idiocc
- License: agpl-3.0
- Created: 2019-12-12T23:32:57.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-12T23:48:40.000Z (about 5 years ago)
- Last Synced: 2024-11-01T02:48:53.270Z (about 2 months ago)
- Topics: compose, goa, idio, middleware
- Language: JavaScript
- Homepage: https://www.idio.cc
- Size: 59.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @goa/compose
[![npm version](https://badge.fury.io/js/%40goa%2Fcompose.svg)](https://www.npmjs.com/package/@goa/compose)
`@goa/compose` is Compose a single middleware function for Goa out of many.
```sh
yarn add @goa/compose
```## Table Of Contents
- [Table Of Contents](#table-of-contents)
- [API](#api)
- [`compose(middleware: !Array): !Function`](#composemiddleware-arrayfunction-function)
- [Copyright & License](#copyright--license)## API
The package is available by importing its default function:
```js
import compose from '@goa/compose'
```##
compose(
`middleware: !Array,`): !Function
Compose a single middleware function for Goa out of many.- middleware*
!Array<!Function>
: The array with the middleware.```js
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](https://www.npmjs.com/package/koa-compose) by dead-horse under MIT license. Copy of the license is not included as not found in the original package.
© Art Deco™ 2019