# ut-api

> API generation tools for [hapi](https://hapi.dev/)

Latest version **8.1.17** (published 2024-07-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ut-api
pnpm add ut-api
yarn add ut-api
bun add ut-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.1.17 |
| Published | 2024-07-25 |
| First published | 2019-11-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 91.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | kalin.krustev |

## Links

- npm: https://www.npmjs.com/package/ut-api
- Repository: https://github.com/softwaregroup-bg/ut-api
- Homepage: https://github.com/softwaregroup-bg/ut-api#readme
- Issues: https://github.com/softwaregroup-bg/ut-api/issues
- npm.io page: https://npm.io/package/ut-api

## Dependencies (6)

- [ut-joi](https://npm.io/package/ut-joi.md) ^1.4.11
- [sort-keys](https://npm.io/package/sort-keys.md) 4.1.0
- [@hapi/boom](https://npm.io/package/@hapi/boom.md) 9.1.0
- [swagger-ui-dist](https://npm.io/package/swagger-ui-dist.md) ^4.14.0
- [ut-swagger2-validator](https://npm.io/package/ut-swagger2-validator.md) ^0.5.7
- [@apidevtools/swagger-parser](https://npm.io/package/@apidevtools/swagger-parser.md) 10.0.3

## Recent versions

- 8.1.17 (latest) — 2024-07-25
- 8.1.16 — 2024-07-24
- 8.1.15 — 2023-05-18
- 8.1.14 — 2023-03-13
- 8.1.13 — 2023-02-28
- 8.1.12 — 2023-02-27
- 8.1.11 — 2023-02-27
- 8.1.10 — 2023-02-01
- 8.1.9 — 2023-01-20
- 8.1.8 — 2022-11-16
- 8.1.7 — 2022-11-04
- 8.1.6 — 2022-10-21
- 8.1.5 — 2022-09-14
- 8.1.4 — 2022-08-25
- 8.1.3 — 2022-06-21
- … 56 more at https://npm.io/package/ut-api/versions

## README

# ut-api

API generation tools for [hapi](https://hapi.dev/)

## 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 API
  - `document` - 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 document
    - `string` - the string is parsed to create the API document
    - `object` - 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 ui
  - `rpcRoutes` - function, used to define RPC routes based on JOI validations
  - `restRoutes` - function, used to define attach handler for REST routes,
  based on the passed `config.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 tags
    - `app` - custom method properties
    - `timeout` - handler default timeout
    - `method` - method name
    - `description` - short method description
    - `notes` - long method description
    - `params` - joi validation of method params
    - `result` - joi validation of method result
    - `validate` - hapi route validate options
    - `handler` - hapi route handler
  - `result` - object containing hapi routes that handle the generated
  RPC routes
- `function restRoutesApi({namespace, fn, object})`
  - `namespace` - namespace of the handler function
  - `fn` - handler function
  - `object` - handler function binding for `this`
  - `result` - object containing hapi routes that handle the generated
  REST routes

---
_Source: https://npm.io/package/ut-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
