Firecomm allows the injection of middleware at the method-level and the service-level for layering functionality.
const { Server } = require('firecomm');
const server = new Server();
const package = require("./builtPackageDefinition")
server.addService(
package.ExampleService,
{
exampleMethod: [methodMiddleware1, methodMiddleware2, methodHandler]
},
[serviceMiddleware1, serviceMiddleware2],
(err, call) => {
call.throw(err)
}
);
The following diagram depicts the order that call objects are passed through each of the functions in the middleware stack.
Call Object |
---|
I |
I |
V |
Service Level Middleware 1 |
Service Level Middleware 2 |
Method-Level Middleware 1 |
Method-Level Middleware 2 |
Method Handler |