KOA middleware for Json Rest API
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)
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.