-
Notifications
You must be signed in to change notification settings - Fork 0
Home
In a large-scale application where there's a lot of dependencies between each service, there is chances that we need to re-use some of the code from different services. To fix these issue, Blaze expose BlazeContext
API so you can have a communication between each service such as calling a function or triggering an event. But this kind of implementation will resulting on re-importing types such as the ReturnType
of the service that you call or even passing a wrong data types to BlazeContext.call
/BlazeContext.emit
/BlazeContext.event
'cause there is no such a type checking happens when passing the body, params, and headers.
Introducing Blaze Types, a TypeScript plugin that will eliminate the issues that being mentioned above. You just need to install @busy-hour/blaze-types
alongside with @busy-hour/blaze
and setup your typescript on your tsconfig.json
file and you good to go. You will have a better type safe to communicate between your services.
To get started using @busy-hour/blaze-types
you just need to do the following steps.
- Install both
@busy-hour/blaze
and@busy-hour/blaze-types
in your project by running the following command:
- NPM
npm i @busy-hour/blaze
- Yarn
yarn add @busy-hour/blaze
- PNPM
pnpm i @busy-hour/blaze
- Bun
bun add @busy-hour/blaze
- Add the plugin to your
tsconfig.json
files
"plugins": [
{
"name": "@busy-hour/blaze-types",
"servicePaths": ["./src/services"], /* Pass all the locations that will contains your services */
"outputPath": "./src/types" /* Pass the locations where the output of the type definition would be */
}
]
- Start creating your services on the location that you just add in your
tsconfig.json
file. You can read the details how to create your own services on blaze by reading our blaze wiki or by looking our example.