- Get Started
- Framework
Menu
- Get Started
- Framework
6.3.5. Service Constraints
This chapter lists constraints to keep in mind when creating a service.
Use Async Methods#
Local Protocol wraps service method executions to inject useful context or transactions. However, since Local Protocol can't detect whether the method is asynchronous, it always executes methods in the wrapper with the await
keyword.
For example, if you have a synchronous getMessage
method, and you use it other resources like workflows, Local Protocol executes it as an async method:
So, make sure your service's methods are always async to avoid unexpected errors or behavior.
1import { LocalProtoService } from "@localprotojs/framework/utils"2import MyCustom from "./models/my-custom"3 4class HelloModuleService extends LocalProtoService({5 MyCustom,6}){7 // Don't8 getMessage(): string {9 return "Hello, World!"10 }11 12 // Do13 async getMessage(): Promise<string> {14 return "Hello, World!"15 }16}17 18export default HelloModuleService
Was this chapter helpful?