Hemera-web
Http route mapping for Hemera microservices. Based on Express 4
- Depends on minimalist and new web framework Express 4
- Respect
Body
andQuery
payload as pattern - Provide a REST like interface
/:topic/:cmd
to Hemera - Transport small binary or text data in pattern
- Returns correct Hemera errors without stack traces
Usage
const hemera = natshemera
How to execute a server method ?
You can transport the pattern in different ways:
- As Query parameters
- As Payload from type JSON
- As Payload from type x-www-form-urlencoded
topic
andcmd
can be declared in url parameters
Examples
- GET Request
http://localhost:3000?topic=math&cmd=add&a=1&b=2
http://localhost:3000/math/add?a=1&b=2
- POST Request
http://localhost:3000?topic=math&cmd=add
http://localhost:3000/math/add
Body:
{
"a": 1,
"b": 2
}
- application/x-www-form-urlencoded
http://localhost:3000?topic=math&cmd=add
http://localhost:3000/math/add
Payload: a=1&bd=2
Define default pattern
In Hemera:
const hemera = natshemera GET - http://localhost:3000?cmd=add&a=1&b=2
Error handling
In Hemera:
const CustomError = hemera hemera
Results in
Status Code: 404 - default (500)
Show error stack for debugging
In Hemera:
const hemera = natshemera
Access to express web framework
const hemera = natshemerahemera
Plugin decorators
- .express