@tadashi/koa-base
v5.4.0
Published
A web server with sugar
Downloads
33
Readme
Koa Base
Basic setup with Koa
Install
$ npm i @tadashi/koa-base
Middleware
Middleware list pre installed
Usage
import app from '@tadashi/koa-base'
const options = {
error: true,
}
const ignore = ['cors']
app(options, ignore)
.use(ctx => {
ctx.throw(401)
})
.on('error', err => {
console.log(err.message) // Unauthorized
})
API
createApp( [opts] [, ignore ])
| Name | Type | Default | Description | | ------ | ------ | ---------- | ------------------ | | opts | object | See bellow | Middleware options | | ignore | array | [] | Ignored middleware |
opts
Default
{
"error": false,
"compress": {},
"cors": {}
}
See the options in the middleware itself
| Parameter | Middleware | | --------- | --------------------------------------------------------- | | error | @tadashi/koa-error | | compress | koa-compress | | cors | kcors |
License
MIT © Thiago Lagden