Apeman middleware for HTTP endpoints
$ npm install apeman-middleware-endpoint --save
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}`
}
}
})
]
}
}
Create an middleware function
Name | Type | Default | Description |
---|---|---|---|
routes | Object | HTTP route handlers | |
options | Object | {} | Optional settings |
This software is released under the MIT License.