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
- Install
tramway-formatter-hateaos
npm i tramway-formatter-hateaos
Declare and Configure
- Add a new
hateoas.jsconfiguration file undersrc/config/serviceswith 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
- Register the
hateoasservices by adding thehateoas.jsfile contents to the configuration's root config insrc/config/services/index.js:
import hateaos from './hateaos';export default {...hateaos,}
Result
Your application should now look like this: