This tutorial assumes you’ve already set up a monorepo for your project, for example:
TSConfig
Tempo utilizes decorators. As such, you’ll need to set experimentalDecorators and emitDecoratorMetadata to true in your tsconfig.json:
Code Generation
Tempo uses Bebop for generating client and service code. To install it, follow the commands below:
By default, bebopc produces client and server code in the same output. You’ll need to add the following dependencies to your project:
If your client and server code lives in the same project, you can install Tempo into it.
Now, you can create your first service. Create a ‘greeter.bop’ file in your shared project with the following contents:
Now, just run yarn bebopc build and it will generate all the shared code into index.ts.
Implementing a Service
The Bebop compiler produces concrete client implementations and abstract base service for you to implement. For example:
A service that you wish to expose to clients must be registered using the TempoServiceRegistry.register decorator as shown above. The parameter passed to TempoServiceRegistry.register is always the serviceName present on the base class of the service. Failure to register a service that was defined in a schema will result in a runtime error when initializing the server. At this time it is recommended that you reexport all services under a single export: