0.1.2 • Published 4 months ago

@xen-orchestra/rest-api v0.1.2

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
4 months ago

@xen-orchestra/rest-api

Package Version License PackagePhobia Node compatibility

REST API to manage your XOA

Install

Installation of the npm package:

npm install --save @xen-orchestra/rest-api

Usage

@xen-orchestra/rest-api

Rules

The REST API is based on the TSOA framework and therefore we use decorators a lot to define the behavior of a route or a group of routes. To keep things easily visible, it is best to always use the decorators in the same order.

Class decorator

@Routes('foo')
@Security('*')
@Response(401)
@provide(Foo)
class Foo extends Controller {}

Methods decorator

@Routes('foo')
...
class Foo extends Controller {


 /**
  * any jsdoc anotations
  * @example id 1234
  */
 @Example(['foo', 'bar'])
 @Get('{id}')
 @Security('*')
 @Response(404)
 getFoo(@Path() id: string) {
    return this.getFoo(id)
 }
}

Examples

In order not to pollute important decorators, all example structures should be in a separate file. src/open-api/examples/<resource>.example.mts

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

AGPL-3.0-or-later © Vates SAS