npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dellasera/plugdo-server

v1.0.20

Published

plugdo server

Downloads

45

Readme

plugdo-server

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. The connectors includes: file system, MS sql server, MySql and Postgresql. (We will update the list as soon as we create more connectors)

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

Install with npm:

npm install @dellasera/plugdo-server

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

The collector logic reside in the plugdo-server core, you must configure and register the collector to be uswed for the integrations.

File Collector (Read)

plugdo.collector("customerFiles", {
    type: "file",
    action: "read",
    path: plugdo.PATH + "/source/plugdo/collector/customer.xml",
    json: false
});

This example shows the following details:

1- "customerFiles": is the name assigned by you to the collector, the name will be used in the integration in order to execute. 2- type: you define the current collector as a file system, database or any other available. 3- action: you define the current action of the collector for reading, the collector action define the behavior of its execution. 4- path: the path of the file to be read 5- json: if the file is not in JSON format, by default is true and you must change it.

Database Collector

Sql Server

plugdo.collector("sqlserverGetInfo", {
    type: "db",
    action: "sqlserver",
    server: {
        user: "synergy",
        password: "S7nerg7",
        server: "190.242.30.52",
        database: "ASIDb",
        port: 1433
    },
    queryType: "stored-procedure",
    query: "synergy.dbsp_GetInfo",
    parameter: []
});

Mysql

plugdo.collector("mysqlGetAuditIntegrationsByQuery", {
    type: "db",
    action: "mysql",
    server: {
        user: "loginName",
        password: "$loginName",
        host: "digitalprimeint.cpjwenmlj3sr.us-west-2.rds.amazonaws.com",
        database: "plugdo"
    },
    queryType: "text",
    query: "select * from audit_integrations",
    parameter: []
});

PostgreSQL

plugdo.collector("postgresqlGetUsers", {
    type: "db",
    action: "postgresql",
    server: {
        user: "loginName",
        password: "$loginName",
        host: "digitalprimeintps.cpjwenmlj3sr.us-west-2.rds.amazonaws.com",
        database: "plugdo",
        port: 5432
    },
    query: "select * from users",
    parameter: []
});

Passing parameters is simple as using the JSON reader format as follow:

plugdo.collector("postgresqlGetUser", {
    type: "db",
    action: "postgresql",
    server: {
        user: "loginName",
        password: "$loginName",
        host: "digitalprimeintps.cpjwenmlj3sr.us-west-2.rds.amazonaws.com",
        database: "plugdo",
        port: 5432
    },
    query: "select * from users where user_id = $1",
    parameter: ["json:querystring.user_id"]
});
plugdo.collector("mysqlGetAuditIntegrationsByStoreProcedure", {
    type: "db",
    action: "mysql",
    server: {
        user: "loginName",
        password: "$loginName",
        host: "digitalprimeint.cpjwenmlj3sr.us-west-2.rds.amazonaws.com",
        database: "plugdo"
    },
    queryType: "stored-procedure",
    query: "call get_integrations",
    parameter: ["json:integration"]
});