Skip to content

v0.3.3

Compare
Choose a tag to compare
@icebob icebob released this 07 Jun 09:40
· 615 commits to master since this release

New

Functions in aliases

There is available to use custom function in aliases. In this case you got req & res and you should return with the response. Use it for example file uploads. You can find example in the full example.

Usage

    ...
        aliases: {
            "add/:a/:b": "math.add",
            "GET sub": "math.sub",
            "POST upload"(route, req, res) {
                //Do something and call res.end()
            }
        }
    ...

New camelCaseNames route setting

There is a new camelCaseNames option in route setting. If it is true, the service will convert the received action name to camelCase name.

Usage

broker.createService(ApiGatewayService, {
    settings: {
        routes: [{
            camelCaseNames: true
        }]
    }
});

broker.createService({
    name: "test",
    actions: {
        sayHi(ctx) {
            return "Hi!"
        }
    }
});

// Start server
broker.start();

In the above example the sayHi action can be called with http://localhost:3000/test/say-hi as well.