chav is a hapi plugin to create static routes from json files
npm install chavjson content as an API route.chav is a hapi.js plugin to serve a static json file as an API route. Per default the file under static/static.json is served as GET /statics
npm install --save chavstatic.json and is located in the static folder of your app./static route is not protected.servable or the path just provide your options on plugin registration.```
const defaults = {
servable: 'static/static.json',
path: '/statics',
tags: ['static', 'route'],
description: 'Renders static route defined in a file',
responses: {
statusCode: 400,
message: 'No static routes found'
},
auth: false
};
You can override servable, path, tags and description.
When you register your plugin with e.g. glue:
``
{
"plugin": {
"register": "chav",
"options": {
"servable" : "static/foobar.json"
}
}
}
file has more than one array (see example below), try to also offer the /statics/beers and /statics/snacks routes`
{
"beers" : [ ],
"snacks" : [
]
}
`- Check if the
servable is actually a file or a directory and if it's a directory` serve every file as an API route, e.g. file name is a route name.