> For the complete documentation index, see [llms.txt](https://julien-sarazin.gitbook.io/idylle/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://julien-sarazin.gitbook.io/idylle/api/action.md).

# Action

## Properties

### rules: Array\<function(context: [Context](/idylle/api/context.md))>

### execute: function(context: [Context](/idylle/api/context.md))

### criteriaBuilder: [CriteriaBuilder](/idylle/core/concepts/criteriabuilder.md)

### responseHandler: [ResponseHandler](/idylle/core/concepts/responsehandler.md)&#x20;

### errorHandler: [ErrorHandler](/idylle/core/concepts/errorhandler.md)

## 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](/idylle/core/concepts/eventhandler.md) Documentation.

```javascript
// 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](http://expressjs.com/en/guide/routing.html) Documentation.

```javascript
// 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);
```

�
