Action

Descriptive full API of an Action.

Properties

rules: Array<function(context: Context)>

execute: function(context: Context)

criteriaBuilder: CriteriaBuilder

responseHandler: ResponseHandler

errorHandler: ErrorHandler

Methods

.io() -> function(socket, packet)

.io() -> function(socket, packet) is used to transform an action on a socket middleware. This way the action will be invoked if a client-socket emit on the proper route. To understand the process of event handling, you can refer to EventHandler Documentation.

// Socket.IO Routing
app.io.on('connection', socket => {
    const router = new app.routers.IO(socket, '/configurations');

    router
        .on('/subscribe',
            app.actions.configurations.subscribe.io())

        .on('/unsubscribe',
            app.actions.configurations.unsubscribe.io());
});

.expose() -> function(request, response, next)

.expose() -> function(request, response, next) is used to transform an action on an http middleware (aka express middleware). This way the action will be invoked if an HTTP request is sent on the proper route. To understand the process of HTTP Routing, you can refer to Express Routing Documentation.

// HTTP Routing
const router = app.routers.HTTP();
router
    .post('/',
        app.middlewares.bodyParser.json(),
        app.actions.configurations.create.expose())

    .put('/:platform/:version',
        app.middlewares.bodyParser.json(),
        app.actions.configurations.update.expose())

    .post('/subscribe',
        app.actions.configurations.subscribe.expose())


app.router.use('/configurations', router);

Last updated