Total.js
Components that use the Total.js framework: HTTP routes, responses, actions, schemas and SQL.
On this page
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.
API
component
taction.html · version 2
Runs a Total.js action: it validates the incoming data with a schema and processes it with your code.
taction.html · version 2| Parameter | Type | Description |
|---|---|---|
partial? |
Boolean |
Allow partial data. Default: false |
name? |
String |
Action name. Default: Unknown |
input? |
String |
Payload schema. |
query? |
String |
Query arguments schema. |
color? |
String |
Color. Default: #68B25B |
params? |
String |
Params schema. |
permissions? |
String |
Permissions. |
code? |
String |
The JavaScript code of the action. |
strerr? |
Boolean |
Convert errors to a string. Default: false |
path? |
String |
Path for storing a response. Default: response |
autoresponse? |
Boolean |
Auto HTTP response. Default: false |
Inputs: input (Payload).
Outputs: output (Response), error (Error).
This component creates similar functionality as Total.js Actions.
Payload
{
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}ormodelparsed 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 withvalueobject and ends the action$.cancel()ends the action without response$.audit(message, [type])writes audit
Supported types
stringnumberbooleandateobjectemailphonezipbase64urldataurijsonloweruppercapitalizeall wordscapitalize2only first wordnamemakes a name (capitalizes words and remove special characters)zipuidguidcoloriconsearchprepares string to a search stringsafestringchecks XSS and SQL Injectionssmallinttinyint{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:typeisrequiredfield
component
tapicreator.html · version 1
Creates a Total.js API payload from the incoming data.
tapicreator.html · version 1Inputs: input (Payload).
Outputs: output (Output).
This component creates Total.js API payload.
Output data__:
{
schema: 'input_name',
data: input_data
}
component
tapirouter.html · version 3
Routes incoming Total.js API data to an output for each operation of the API schema.
tapirouter.html · version 3| Parameter | Type | Description |
|---|---|---|
payload? |
Boolean |
Send next only payload without schema. Default: false |
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:
{
// 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.
component
tauthtoken.html · version 1
Compares a token from the request header with the token in its configuration.
tauthtoken.html · version 1| Parameter | Type | Description |
|---|---|---|
token? |
String |
Token. |
code? |
Number |
Status code. Default: 401 |
header? |
String |
Header. Default: x-token |
error? |
String |
Error message. Default: Unauthorized |
ddos? |
Number |
DDOS protection. Default: 0 |
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.
component
tcors.html · version 3
Enables Cross-Origin Resource Sharing (CORS) for the routes of the FlowStream.
tcors.html · version 3| Parameter | Type | Description |
|---|---|---|
hostnames? |
Array |
Hostnames with a protocol. Default: [] |
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.
component
tschema.html · version 2
Checks incoming data against a data schema.
tschema.html · version 2| Parameter | Type | Description |
|---|---|---|
schema? |
String |
Schema. Default: *name:String, *email:Email |
partial? |
Boolean |
Allow partial data. Default: false |
strerr? |
Boolean |
Convert errors to a string. Default: false |
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:
stringnumberbooleandateobjectemailphonezipbase64urldataurijsonloweruppercapitalizeall wordscapitalize2only first wordnamemakes a name (capitalizes words and remove special characters)zipuidguidcoloriconsearchprepares string to a search stringsafestringchecks XSS and SQL Injectionssmallinttinyint{A|B|C}enum type[type]means array*something:typeisrequiredfield
component
error.html · version 1
Turns incoming data into the Total.js error structure.
error.html · version 1Inputs: input (Input).
Outputs: output (Output).
This component transforms incoming data to the Total.js Error structure.
component
insecuressl.html · version 1
Disables SSL certificate verification.
insecuressl.html · version 1Inputs: none.
Outputs: none.
A FlowStream can hold only one node of this component.
Disables SSL verification.
component
querybuilderpg.html · version 1
Opens QueryBuilder connections to PostgreSQL databases for other components.
querybuilderpg.html · version 1| Parameter | Type | Description |
|---|---|---|
id? |
String |
Alias. Default: default |
name? |
String |
Name. Default: API PostgreSQL |
url? |
String |
Connection string. |
pooling? |
Number |
Pooling. Default: 2 |
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_useris targeted to thedefault/tbl_useralias connectionanotherserver/tbl_userwill useanotherserveralias connection
component
tredirect.html · version 2
Redirects an HTTP request to another address.
tredirect.html · version 2| Parameter | Type | Description |
|---|---|---|
url? |
String |
Redirect URL. |
permanent? |
Boolean |
Permanent redirect. Default: false |
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.
{
url: 'https://example.com',
permanent: true|false
}
component
tremember.html · version 1
Remembers data and returns it on request.
tremember.html · version 1| Parameter | Type | Description |
|---|---|---|
path? |
String |
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.
component
tresponse.html · version 2
Responds to an HTTP request received by the Route component.
tresponse.html · version 2| Parameter | Type | Description |
|---|---|---|
type? |
String |
Type. One of: auto (Auto), json (JSON), success (Success), error (Error), empty (Empty response), plain (Plain text), html (HTML), xml (XML), buffer (Buffer). Default: auto |
code? |
Number |
Status code. Default: 200 |
path? |
String |
Path for reading value. Default: response |
ctype? |
String |
Content type. |
Inputs: input (Response).
Outputs: output (Log).
This component can respond to an HTTP request.
component
trestart.html · version 1
Restarts the current FlowStream.
trestart.html · version 1Inputs: 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.
component
troute.html · version 3
Registers an HTTP route and sends the request data to its output.
troute.html · version 3| Parameter | Type | Description |
|---|---|---|
url? |
String |
Relative URL address. Default: / |
method? |
String |
Method. One of: GET, POST, PUT, PATCH, DELETE, API. Default: GET |
timeout? |
Number |
Timeout. Default: 5000 |
limit? |
Number |
Request limit (kB). Default: 5120 |
upload? |
Boolean |
Allow uploading files (form data). Default: false |
user? |
Number |
Who can call the route. One of: 1 (Authorized), 2 (Unauthorized), 0 (Both). Default: 0 |
send? |
String |
Send to output. One of: all (Everything), payload (Payload), query (Query arguments), files (Files), params (Dynamic params), headers (Headers), cookies (Cookies), user (User). Default: all |
reader? |
String |
Read files to. One of: - (Keep as files), buffer (Buffer), utf8 (UTF-8), ascii (ASCII), datauri (Data URI), base64 (Base64), hex (Hex). Default: - |
autoreply? |
String |
Auto-reply. One of: success (Success), empty (Empty response). |
action? |
String |
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:
{
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
}
component
tsql.html · version 1
Runs an SQL command on a PostgreSQL connection.
tsql.html · version 1| Parameter | Type | Description |
|---|---|---|
id? |
String |
Connection. Default: default |
sql? |
String |
The SQL command. Default: SELECT 1 |
first? |
Boolean |
Return only the first row. Default: false |
path? |
String |
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.
component
tuploadedfiles.html · version 1
Processes the files uploaded through the Route component.
tuploadedfiles.html · version 1| Parameter | Type | Description |
|---|---|---|
action? |
String |
Action. One of: read (Read), move (Move). Default: read |
path? |
String |
Absolute path. Default: /www/{name}{index}.{extension} |
type? |
String |
Type. One of: buffer (Buffer), utf8 (UTF-8), base64 (BASE64), hex (Hex). Default: utf8 |
Inputs: input (Request).
Outputs: file (File), done (Done).
The component processes files from the Total.js Route component.
component
twebsocketroute.html · version 1
Creates a WebSocket endpoint.
twebsocketroute.html · version 1| Parameter | Type | Description |
|---|---|---|
endpoint? |
String |
Endpoint. Default: /realtime/ |
type? |
String |
Communication. One of: json (JSON), text (Text), binary (Binary). Default: json |
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 messagemessage.refs.client {Object}contains a client controllermessage.refs.controller {Object}contains a WebSocket controller