@cc12703m/reed-json-api
v1.0.3
Published
koa middleware for josn-mock rest api
Downloads
3
Maintainers
Readme
Reed Json API
KOA middleware for Json Rest API
Sample
const app = new Koa(),
filePath = path.join(process.cwd(), 'json-api.hbs'),
options = { urlPrefix: '/api', filePath}
app.use(koaBody())
app.use(api(options))
app.use(ctx => {
ctx.status = 404
ctx.body = { error: 'not found' }
})
return app.listen(8000)
Options
urlPrefix: Optional Set the URL path prefix
filePath: Required file path to the json template The json is generated by dummy json.
dummyOptions: Optional options when parsing dummy json. see here for more detail.