TramwayJS

Setup

From the base installation of Tramway, an additional dependency needs to be installed. Unfortunately it is not yet supported with tramway install but setup should be minimal.

Install

  1. Install tramway-formatter-hateaos
npm i tramway-formatter-hateaos

Declare and Configure

  1. Add a new hateoas.js configuration file under src/config/services with the following contents:
import HATEAOSFormatter, { HATEAOSEntityFactory } from 'tramway-formatter-hateaos';
export default {
"service.formatter": {
"class": HATEAOSFormatter,
"constructor": [
{ "type": "service", "key": "factory.hateaos" }
]
},
"factory.hateaos": {
"class": HATEAOSEntityFactory,
},
}

Register

  1. Register the hateoas services by adding the hateoas.js file contents to the configuration's root config in src/config/services/index.js:
import hateaos from './hateaos';
export default {
...hateaos,
}

Result

Your application should now look like this:

image