ut-api
v8.1.17
Published
API generation tools for [hapi](https://hapi.dev/)
Downloads
147
Readme
ut-api
API generation tools for hapi
API
Exposes a single initialization method:
async init(config, errors)
- initializes the module
config
- configuration object with the following properties:ui
- boolean, activates generation of UI for the APIdocument
- define custom endpoints based on Swagger 2.0 or OpenAPI 3.0 document. Possible values are:function
- the function is called and it must return parsed API documentstring
- the string is parsed to create the API documentobject
- must be valid API document- anything else will generate empty API document
result
- the function returns object with the following properties:uiRoutes
- object containing hapi routes that handle the API uirpcRoutes
- function, used to define RPC routes based on JOI validationsrestRoutes
- function, used to define attach handler for REST routes, based on the passedconfig.document
The functions in the result have the following signatures:
function rpcRoutes(definitions)
definitions
- array of objects with the following properties, used to describe each method:tags
- method tagsapp
- custom method propertiestimeout
- handler default timeoutmethod
- method namedescription
- short method descriptionnotes
- long method descriptionparams
- joi validation of method paramsresult
- joi validation of method resultvalidate
- hapi route validate optionshandler
- hapi route handler
result
- object containing hapi routes that handle the generated RPC routes
function restRoutesApi({namespace, fn, object})
namespace
- namespace of the handler functionfn
- handler functionobject
- handler function binding forthis
result
- object containing hapi routes that handle the generated REST routes