apeman-middleware-endpoint
v1.0.0
Published
Apeman middleware for HTTP endpoints
Downloads
1
Readme
apeman-middleware-endpoint
Apeman middleware for HTTP endpoints
Installation
$ npm install apeman-middleware-endpoint --save
Usage
create an middleware instance and attach to server settings like $api
of apeman projects.
Apemanfile.js
/** This is an example Apemanfile to use apeman-middleware-endpoint */
'use strict'
module.exports = {
$pkg: { /* ... */ },
$api: {
/* ... */
$middlewares: [
...require('apeman-middleware-endpoint')({
'/foo/bar/:id': {
GET: (ctx) => {
let { id } = ctx.params
ctx.body = `Hello from foo with id: ${id}`
}
}
})
]
}
}
Signature
apemanMiddlewareEndpoint(routes, options) -> function
Create an middleware function
Args
| Name | Type | Default | Description | | --- | ---- | --- | --- | | routes | Object | | HTTP route handlers | | options | Object | {} | Optional settings |
License
This software is released under the MIT License.