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.js
configuration file undersrc/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
- Register the
hateoas
services by adding thehateoas.js
file 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: