---
title: Total.js
project: Flow
version: 11.1
section: components
language: en
license: MIT
url: https://totaljs.es/docs/flow/11-1/components/totaljs/
updated: 2026-11-20T06:50:57.962Z
---

# Total.js

> Components that use the Total.js framework: HTTP routes, responses, actions, schemas and SQL.

Components that use the Total.js framework: HTTP routes, responses, actions, schemas and SQL. This page holds the catalogue group **Total.js**.

Each entry lists the inputs and outputs of the component, its main settings and the text of its readme. To add a component to a FlowStream, see [Download components](/flow/11-1/guides/download-components/).

## API

### taction.html · version 2

Type: `component`

Runs a Total.js action: it validates the incoming data with a schema and processes it with your code.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `partial` | `Boolean` | no | `false` | Allow partial data. |
| `name` | `String` | no | `Unknown` | Action name. |
| `input` | `String` | no |  | Payload schema. |
| `query` | `String` | no |  | Query arguments schema. |
| `color` | `String` | no | `#68B25B` | Color. |
| `params` | `String` | no |  | Params schema. |
| `permissions` | `String` | no |  | Permissions. |
| `code` | `String` | no |  | The JavaScript code of the action. |
| `strerr` | `Boolean` | no | `false` | Convert errors to a string. |
| `path` | `String` | no | `response` | Path for storing a response. |
| `autoresponse` | `Boolean` | no | `false` | Auto HTTP response. |

**Inputs:** `input` (Payload).  
**Outputs:** `output` (Response), `error` (Error).

This component creates similar functionality as Total.js Actions.

**Payload**

```js
{
	ip: String, // optional, IP address
	url: String, // optional
	language: String, // optional
	ua: String, // optional, parsed user-agent
	user: Object, // optional
	headers: { key: String }, // optional, request headers
	cookies: { key: String }, // optional, cookies
	payload: {}, // optional, request payload
	query: { key: String }, // optional
	params: { key: String }, // optional
	files: [{ type: String, filename: String, path: String, ext: String, size: Number, width: Number, height: Number }] // optional
}
```

**Custom scripting**

- supports `await`
- supports Total.js global functions

__Properties__:

- `$.model {Object}` or `model` parsed payload
- `$.query {Object}` parsed URL query arguments
- `$.params {Object}` parsed URL params
- `$.cookies {Object}` parsed cookies
- `$.files [Object]` uploaded files
- `$.user {Object}` user session (optional)
- `$.headers {Object}` request headers
- `$.ip {String}` IP address (optional)
- `$.language {String}` optional
- `$.ua {String}` parsed user agent (optional)
- `$.url {String}` URL endpoint
- `$.message {Object}` Flow message instance
- `$.request {Object}` Flow message payload data

__Methods__:

- `$.invalid(error)` responds with an error and ends the action
- `$.success([value])` responds with `{ success: true, value }` object and ends the action
- `$.callback(value)` responds with `value` object and ends the action
- `$.cancel()` ends the action without response
- `$.audit(message, [type])` writes audit

**Supported types**

- `string`
- `number`
- `boolean`
- `date`
- `object`
- `email`
- `phone`
- `zip`
- `base64`
- `url`
- `datauri`
- `json`
- `lower`
- `upper`
- `capitalize` all words
- `capitalize2` only first word
- `name` makes a name (capitalizes words and remove special characters)
- `zip`
- `uid`
- `guid`
- `color`
- `icon`
- `search` prepares string to a search string
- `safestring` checks XSS and SQL Injections
- `smallint`
- `tinyint`
- `{A|B|C}` enum type
- `[type]` means array
- `{ name:String, age:Number }` means nested object
- `[ name:String, age:Number ]` means array with an object
- `*something:type` is `required` field

### tapicreator.html · version 1

Type: `component`

Creates a Total.js API payload from the incoming data.

**Inputs:** `input` (Payload).  
**Outputs:** `output` (Output).

This component creates Total.js API payload.

Output data__:

```js
{
	schema: 'input_name',
	data: input_data
}
```

### tapirouter.html · version 3

Type: `component`

Routes incoming Total.js API data to an output for each operation of the API schema.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `payload` | `Boolean` | no | `false` | Send next only payload without schema. |

**Inputs:** `input` (Payload).  
**Outputs:** they come from the settings of the node.

This component routes incoming Total.js API data according to the defined API schema. The component extends input data (query, payload and params) with parsed data.

__Input & Output data__:

```js
{
	// REQUIRED payload:
	payload: {
		schema: 'schema_name/{param_1}/{param_2}?query=arguments',
		data: {} // optional, request payload
	},
	ip: String, // optional, IP address
	url: String, // optional
	language: String, // optional
	ua: String, // optional, parsed UA
	user: Object, // optional
	headers: { key: String }, // optional, request headers
	cookies: { key: String }, // optional, cookies
	query: { key: String }, // optional
	params: { key: String }, // optional
	files: [{ type: String, filename: String, path: String, ext: String, size: Number, width: Number, height: Number }] // optional
}
```

In the case of  `error`, the input data is extended by the `response` property with an error.

### tauthtoken.html · version 1

Type: `component`

Compares a token from the request header with the token in its configuration.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `token` | `String` | no |  | Token. |
| `code` | `Number` | no | `401` | Status code. |
| `header` | `String` | no | `x-token` | Header. |
| `error` | `String` | no | `Unauthorized` | Error message. |
| `ddos` | `Number` | no | `0` | DDOS protection. |

**Inputs:** `input` (Request).  
**Outputs:** `output` (Request).

This component must be used only with REST Route component. It reads a token from the request header and compares it with the token declared in the configuration.

### tcors.html · version 3

Type: `component`

Enables Cross-Origin Resource Sharing (CORS) for the routes of the FlowStream.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `hostnames` | `Array` | no | `[]` | Hostnames with a protocol. |

**Inputs:** none.  
**Outputs:** none.

A FlowStream can hold only one node of this component.

The component enables Cross-Origin Resource Sharing `CORS`, so the web browser will be able to communicate directly with the REST API. The functionality will work only with a defined Proxy endpoint for this Flow.

### tschema.html · version 2

Type: `component`

Checks incoming data against a data schema.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `String` | no | `*name:String, *email:Email` | Schema. |
| `partial` | `Boolean` | no | `false` | Allow partial data. |
| `strerr` | `Boolean` | no | `false` | Convert errors to a string. |

**Inputs:** `input` (Payload).  
**Outputs:** `output` (Response), `error` (Error).

This component is in the repository, but not in the catalogue that the **Download components** window shows.

The component `Schema` can very quickly check incoming data according to the defined schema.

__Supported types__:
- `string`
- `number`
- `boolean`
- `date`
- `object`
- `email`
- `phone`
- `zip`
- `base64`
- `url`
- `datauri`
- `json`
- `lower`
- `upper`
- `capitalize` all words
- `capitalize2` only first word
- `name` makes a name (capitalizes words and remove special characters)
- `zip`
- `uid`
- `guid`
- `color`
- `icon`
- `search` prepares string to a search string
- `safestring` checks XSS and SQL Injections
- `smallint`
- `tinyint`
- `{A|B|C}` enum type
- `[type]` means array
- `*something:type` is `required` field

### error.html · version 1

Type: `component`

Turns incoming data into the Total.js error structure.

**Inputs:** `input` (Input).  
**Outputs:** `output` (Output).

This component transforms incoming data to the Total.js Error structure.

### insecuressl.html · version 1

Type: `component`

Disables SSL certificate verification.

**Inputs:** none.  
**Outputs:** none.

A FlowStream can hold only one node of this component.

Disables SSL verification.

### querybuilderpg.html · version 1

Type: `component`

Opens QueryBuilder connections to PostgreSQL databases for other components.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `String` | no | `default` | Alias. |
| `name` | `String` | no | `API PostgreSQL` | Name. |
| `url` | `String` | no |  | Connection string. |
| `pooling` | `Number` | no | `2` | Pooling. |

**Inputs:** none.  
**Outputs:** `error` (Error).

Flow installs the npm package `querybuilderpg` when you add the component.

The component initializes QueryBuilder for the PostgreSQL database. So you can use the 'API Database` component. Each connection must be separated by an alias.

__Usage in API Database__:

- `tbl_user` is targeted to the `default/tbl_user` alias connection
- `anotherserver/tbl_user` will use `anotherserver` alias connection

### tredirect.html · version 2

Type: `component`

Redirects an HTTP request to another address.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `url` | `String` | no |  | Redirect URL. |
| `permanent` | `Boolean` | no | `false` | Permanent redirect. |

**Inputs:** `input` (Input).  
**Outputs:** none.

**Input**

Incomming data have higher priority than the values set in the Configuration form. Both the `url` and `permanent` are optional.

```js
{
	url: 'https://example.com',
	permanent: true|false
}
```

### tremember.html · version 1

Type: `component`

Remembers data and returns it on request.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `path` | `String` | no |  | Set remembered data to the specific property/field. |

**Inputs:** `remember` (Remember), `request` (Request).  
**Outputs:** `response` (Response).

The primary goal of this component is to remember the data. The component contains two inputs:

- Remember input for remembering data.
- Request input as a trigger for obtaining data, then remembered data would extend the request message (its data), and the component would send it to the response output.

### tresponse.html · version 2

Type: `component`

Responds to an HTTP request received by the Route component.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `type` | `String` | no | `auto` | Type. One of: `auto` (Auto), `json` (JSON), `success` (Success), `error` (Error), `empty` (Empty response), `plain` (Plain text), `html` (HTML), `xml` (XML), `buffer` (Buffer). |
| `code` | `Number` | no | `200` | Status code. |
| `path` | `String` | no | `response` | Path for reading value. |
| `ctype` | `String` | no |  | Content type. |

**Inputs:** `input` (Response).  
**Outputs:** `output` (Log).

This component can respond to an HTTP request.

### trestart.html · version 1

Type: `component`

Restarts the current FlowStream.

**Inputs:** `input` (Restart).  
**Outputs:** none.

This component is in the repository, but not in the catalogue that the **Download components** window shows.

This component restarts the current FlowStream.

### troute.html · version 3

Type: `component`

Registers an HTTP route and sends the request data to its output.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `url` | `String` | no | `/` | Relative URL address. |
| `method` | `String` | no | `GET` | Method. One of: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `API`. |
| `timeout` | `Number` | no | `5000` | Timeout. |
| `limit` | `Number` | no | `5120` | Request limit (kB). |
| `upload` | `Boolean` | no | `false` | Allow uploading files (form data). |
| `user` | `Number` | no | `0` | Who can call the route. One of: `1` (Authorized), `2` (Unauthorized), `0` (Both). |
| `send` | `String` | no | `all` | Send to output. One of: `all` (Everything), `payload` (Payload), `query` (Query arguments), `files` (Files), `params` (Dynamic params), `headers` (Headers), `cookies` (Cookies), `user` (User). |
| `reader` | `String` | no | `-` | Read files to. One of: `-` (Keep as files), `buffer` (Buffer), `utf8` (UTF-8), `ascii` (ASCII), `datauri` (Data URI), `base64` (Base64), `hex` (Hex). |
| `autoreply` | `String` | no |  | Auto-reply. One of: `success` (Success), `empty` (Empty response). |
| `action` | `String` | no |  | API Action. |

**Inputs:** none.  
**Outputs:** `output` (Request).

This component registers an HTTP Route and sends request data next. It stores `controller` instance in the `message.refs.controller` property. You must respond to the REST response component.

__Output data__:

```js
{
	ip: String, // optional, IP address
	url: String, // optional
	language: String, // optional
	ua: String, // optional, parsed user-agent
	user: Object, // optional
	headers: { key: String }, // optional, request headers
	cookies: { key: String }, // optional, cookies
	payload: {}, // optional, request payload
	query: { key: String }, // optional
	params: { key: String }, // optional
	files: [{ type: String, filename: String, path: String, ext: String, size: Number, width: Number, height: Number, data:Buffer|String }] // optional
}
```

### tsql.html · version 1

Type: `component`

Runs an SQL command on a PostgreSQL connection.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `String` | no | `default` | Connection. |
| `sql` | `String` | no | `SELECT 1` | The SQL command. |
| `first` | `Boolean` | no | `false` | Return only the first row. |
| `path` | `String` | no |  | Assign data according to the path. |

**Inputs:** `input` (Payload).  
**Outputs:** `output` (Output), `error` (Error).

The component executes SQL command on the specifi connection. This component depends on the `API PostgreSQL` component.

### tuploadedfiles.html · version 1

Type: `component`

Processes the files uploaded through the Route component.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `action` | `String` | no | `read` | Action. One of: `read` (Read), `move` (Move). |
| `path` | `String` | no | `/www/{name}{index}.{extension}` | Absolute path. |
| `type` | `String` | no | `utf8` | Type. One of: `buffer` (Buffer), `utf8` (UTF-8), `base64` (BASE64), `hex` (Hex). |

**Inputs:** `input` (Request).  
**Outputs:** `file` (File), `done` (Done).

The component processes files from the Total.js Route component.

### twebsocketroute.html · version 1

Type: `component`

Creates a WebSocket endpoint.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `endpoint` | `String` | no | `/realtime/` | Endpoint. |
| `type` | `String` | no | `json` | Communication. One of: `json` (JSON), `text` (Text), `binary` (Binary). |

**Inputs:** `send` (Send), `init` (Initial message).  
**Outputs:** `message` (Message).

This component creates a WebSocket endpoint. Initial message data is stored in the memory of new clients.

- `message.data {Object}` data from a WebSocket message
- `message.refs.client {Object}` contains a client controller
- `message.refs.controller {Object}` contains a WebSocket controller
