# 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);
```

�


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julien-sarazin.gitbook.io/idylle/api/action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
