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

db2sock-itoolkit

v0.0.1

Published

The DB2Sock iToolkit is a pure JavaScript wrapper over the JSON-based REST DB2 interface in DB2Sock

Downloads

8

Readme

db2sock-itoolkit - JS wrapper over DB2Sock's REST interface

Table of Contents

Usage

The underlying concept for the db2sock-itoolkit is to make the interface as easy to use as possible for end users. This means that very few functions should take in plain JavaScript objects, and in the future should return formatted objects back to the user as opposed to just dumping the db2sock response on them.

CMD Call

    // Setup the toolkit core
    var tk = require("../db2sock-itoolkit");
    var core = new tk.Core('http://<IP>/db2json.db2');

    // Create a command call, and add it to the core
    var cmd = core.command('CHGLIBL LIBL(DB2JSON QTEMP) CURLIB(DB2JSON)');
    core.add(cmd);

    // Run the core's current call list, and get the results
    var result = core.run(function (result) {
        console.log('Results:');
        console.log(result);
    });

QSH Call

    // Setup the toolkit core
    var tk = require("../db2sock-itoolkit");
    var core = new tk.Core('http://<IP>/db2json.db2');

    // Create a shell call, and add it to the core
    var sh = core.shell('ls -1 /QOpenSys');
    core.add(sh);

    // Run the core's current call list, and get the results
    var result = core.run(function (result) {
        console.log('Results:');
        console.log(result);
    });

PGM Call

    // Setup the toolkit core
    var tk = require("../db2sock-itoolkit");
    var core = new tk.Core('http://<IP>/db2json.db2');

    // Create a program call with parameters, and add it to the core
    var pgm = core.program('HELLO', 'DB2JSON');
    pgm.addParam('char', '128a', 'Hi there');
    core.add(pgm);

    // Run the core's current call list, and get the results
    var result = core.run(function (result) {
        console.log('Results:');
        console.log(result);
    });

Advanced CMD Call

It is possible to chain multiple calls under the same "session", this allows things like changing the library list prior to calling a command or program.

    // Setup the toolkit core
    var tk = require("../db2sock-itoolkit");
    var core = new tk.Core('http://<IP>/db2json.db2');

    // Create multiple command calls, and add them to the core
    var cmdChgLibl = core.command('CHGLIBL LIBL(DB2JSON QTEMP) CURLIB(DB2JSON)');
    var cmdGetLibl = core.command('RTVJOBA USRLIBL(?)');
    core.add(cmdChgLibl);
    core.add(cmdGetLibl);

    // Run the core's current call list, and get the results
    var result = core.run(function (result) {
        console.log('Results:');
        console.log(result);
    });

Building

This module has been built and tested with NodeJS v8.9. Compatibility with earlier versions of NodeJS is not guaranteed.

To set up the development environment, run npm install to install the required Node modules. The below commands will not work until the Node modules are installed.

Available NPM Commands

  • npm run build — Generate the JavaScript files
  • npm run clean — Clean any previously built JavaScript files
  • npm run rebuild — Clean and rebuild the JavaScript files
  • npm run test -- --db2sock=<url> — Run the current test suite against the built JavaScript files. See Testing for more information.

Testing

Most aspects of the db2sock-itoolkit should have tests written to cover their usage. Tests can be run with the npm run test -- --db2sock=<url> command, where <url> is the full URL to the DB2Sock CGI program. Note that the -- after "test" is required for the test suite to get the next parameter value.

Certain tests will expect specific programs to exist, these programs must exist in the "DB2JSON" library for all tests to pass:

  1. HELLO (*PGM)
  2. HAMELA01 (*PGM)
  3. HAMELA02 (*PGM)

This list may expand in the future to cover more use cases. Test programs will almost always be pulled from the DB2Sock repo: https://bitbucket.org/litmis/db2sock/src/master/tests/rpg/

License

MIT
This code is licensed under the MIT license. See LICENSE in project root for details.

Back to Top