Skip to main content
Contracts are the shared definitions that we define in-order to get the type-safety from the Rest API. Example of a contract:

Adding a contract

You can add a contract by simply creating another file in the /packages/contract folder. Then import it in the index.ts file of the folder and add it to the super contract like this:

Contract Implementation

Now we need to implement this contract in the backend. By default we have an express apps, so we will navigate to: apps/backend/src/api/routes and create a new route. We now will have to implement all the functions in the contract that we specified in the shared package in the previous step. Example of contract implementation:
You can break out all the functionalities related to an entity in the services folder.
Learn more about contracts on the TS-Rest express adapter documentation.