1.0.13 • Published 4 years ago

plugdo-node v1.0.13

Weekly downloads
37
License
MIT
Repository
-
Last release
4 years ago

plugdo-node

A module that implements plugdo-platform web software architecture. It help you focus in the implementation of integration oriented programming for: integration, data transformation, in-memory solutions and realtime solutions. you must purchase the connectors available in ower website.

Compatibility: Node.js version 6+ and Express version 4+

Install with npm:

npm install plugdo-node

Integrations

The integration core platform creates a global message in JSON format. The message is passed from the plugdo-server platform to the integration component implemented by you. An example:

plugdo.integration("get-customer", (message, send) => {

    send({});

});

This example shows the following details:

1- message: the message parameter is a global object that includes the following information in JSON format (the example is in XML format for better understanding).

<Integration>
    <url>
        <protocol>http</protocol>
        <path>api/get-customer/xml</path>
        <host>localhost:3000</host>
        <fullPath>http://localhost:3000/api/get-customer/xml</fullPath>
    </url>
    <node>api</node>
    <integration>get-customer</integration>
    <responseType>xml</responseType>
    <querystring/>
    <post/>
    <ip>127.0.0.1</ip>
    <header>
        <host>localhost:3000</host>
        <connection>keep-alive</connection>
        <upgrade-insecure-requests>1</upgrade-insecure-requests>
        <user-agent>
        Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
        </user-agent>
        <accept>
        text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
        </accept>
        <accept-encoding>gzip, deflate, br</accept-encoding>
        <accept-language>en-US,en;q=0.9,es;q=0.8</accept-language>
        <cookie>io=Kli44tnwwnR7jIbJAAAB</cookie>
    </header>
    <device>
        <type>desktop</type>
        <name/>
    </device>
</Integration>

2- send: the send parameter is a function, it must be used to end a process of the integration implemented. You can pass the function throught the different callbacks, unless you execute it, the request will stay pending. Take care with the error handling logic, because if a try/catch is in place, you must execute the send({}, error) to exit the current request.

3- The "get-customer" is the name for the integration access point used in the URL.

The expected URL will be: http://domain.com/api/gwt-customer/xml

or http://domain.com/api/gwt-customer/json

the following example shows a complex logic with multiple collectors:

plugdo.integration("get-customer", (message, send) => {

    let response = {};

    // Collect from a file collector
    response.fromXML = plugdo.collect("customerFiles").get();

    // Collect from a sql server
    plugdo.collect("sqlserverGetBalanceByCustomerID").get(message, (data1, err) => {
        if(err !== undefined) {
            // End the current request if a error exists
            send({}, err);
        }
        else {
            response.Balance = data1;

            // Collect from sql server
            plugdo.collect("sqlserverGetGlobalInfo").get(message, (data2, err) => {
                if(err !== undefined) {
                    // End the current request if a error exists
                    send({}, err);
                }
                else {

                    // Collect from mysql server
                    response.GlobalInformation = data2;
                    plugdo.collect("mysqlGetAuditIntegrations").get(message, (data3, err) => {
                        if(err !== undefined) {
                            send({}, err);
                        }
                        else {
                            response.AuditIntegration = data3;
                
                            // End the current request
                            send(response);
                        }
                    });
               }
            });
        }
    });
});

Collectors

We are not including connectors, you must purchase the connectors in ower website or create it.

// Without callback
const myConnector = {
    callback: false,
    options: { 
        setting1: "",
        setting2: ""
    },
    get: function (message) {
        
    }
};

// With callback
const myConnector = {
    callback: true,
    options: { 
        setting1: "",
        setting2: ""
    },
    get: function (message, callback) {
        // Error
        callback({}, error);

        // Success
        callback(responseModel);
    }
};

// How to register a connector to be used in the framework
// plugdo.registerConnector("type", "action", myConnector);

// Add databases
plugdo.registerConnector("db", "mysql", mysqlConnector);
plugdo.registerConnector("db", "sqlserver", sqlserverConnector);
plugdo.registerConnector("db", "postgresql", postgresqlConnector);

How to use it?

Create a index.js or main.js file. The file simple example is:

const plugdo = require("plugdo-node").node();
const path = require("path");

// Register the connectors here!
const myDatabaseConnector = require("./connectors/myConnector.js");
plugdo.registerConnector("db", "mysql", myDatabaseConnector.mysql());

plugdo.start(80, path.resolve(__dirname));

Now you can follow the plugdo™ MVC and Server documentation https://docs.plugdo.com/#plugdo-node-mvc

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago