Message Handlers (mh)
The Message Handler Artifact (mh)
Filetype:{filename}.mh.lua
This artifact is used to create an endpoint in the backend. It usually holds the business logic of your application. Message Handlers are never loaded into the browser and are always executed as part of your backend.
TENUM® Usage Sample**
Sample App: **TENUM®** ToDo App
Sample Message Handler: createToDo.mh.lua
Best Practices
Validate Incoming Requests
Always use validators to ensure incoming HTTP requests meet expected criteria before processing.
Keep Handlers Small
Design each message handler with a single responsibility to maintain clarity and simplicity.
Delegate Business Logic
Avoid embedding complex logic directly in the handler; instead, delegate to entities for state management or trigger events when necessary.
Implement Robust Error Handling
Include proper error handling to return clear, meaningful feedback to the caller, improving reliability and debugging.
Leverage the TENUM® Ecosystem
Use shared modules for common operations, decorators for cross-cutting concerns (e.g., logging, authentication), and rely on TENUM® ’s built-in scalability for handling high-concurrency workloads.