@travetto/rest-client

4.0.10 • Public • Published

RESTful Client Support

RESTful support for generating clients for controller endpoints

Install: @travetto/rest-client

npm install @travetto/rest-client

# or

yarn add @travetto/rest-client

This module allows for a highly focused scenario, of producing Typescript-based clients for use within a homogenous ecosystem. If a more general/robust solution is needed, OpenAPI Specification operates with the the full generative abilities provided by OpenAPI's client generation tools.

The primary benefit with this approach is faster code generation times, as well as no longer having a dependency on docker during generation. This results in far less system resources, along with a more responsive rendering process.

Code: Sample Configuration

---
rest.client:
  providers:
    - type: fetch
      output: api-client/sample
      moduleName: '@travetto-client/sample'

The code will only be generated during development (when TRV_DYNAMIC is true-ish). This is the same pattern the Data Modeling Support and RESTful API take for responding to code changes, in realtime.

By default the output is relative to the workspace root, which is helpful when generated clients are centralized within a monorepo. If the goal is to have the output relative to the module itself, then use @/relative/path as a convention.

CLI - rest:client

The library, in addition to generating client output at runtime, also allows for direct generation of clients, regardless of any configurations defined in the application's configuration files.

Terminal: Command Service

$ trv rest:client --help

Usage: rest:client [options] <type:angular|config|fetch|fetch-node|fetch-web> [output:string]

Options:
  -e, --env <string>     Application environment
  -m, --module <module>  Module to run for
  -h, --help             display help for command

Package Sidebar

Install

npm i @travetto/rest-client

Homepage

travetto.io

Weekly Downloads

18

Version

4.0.10

License

MIT

Unpacked Size

52.6 kB

Total Files

20

Last publish

Collaborators

  • arcsine