Code Monkey home page Code Monkey logo

ibmi's Introduction

IBMi

Build Status Coverage Status Dependency Status

Description

This library is an IBM i (AS400) client for Node. It is intended for those of you who have the unfortunate requirement to interface with the IBM i. It is a port of the JTOpen for Java. There are other packages out there, but they only provide a fraction of the features and only wrap the Java code. This is in pure Javascript.

Implemented features

Service Feature Notes
Port Mapper Locate service port by name
Signon Signon to system
Data queue Create data queue
Data queue Delete data queue
Data queue Clear data queue
Data queue Write to data queue
Data queue Read from data queue
Data queue Peek into data queue

API

IBMi class

The IBMi class is the main class of the library. It represents a remote IBMi system.

Constructor(opts)

System options.

opts

Type: Object (required)

{
  hostName: 'localhost',
  ...other IBMi options...
}

opts.hostName

Type: String (required)

The host name of the remote system.

opts.userId

Type: String (required)

The user ID.

opts.password

Type: String (required)

The password.

opts.portMapperPort

Type: Number (optional) Default: 449

The port that the port mapper service runs on. You should probably never have a need to change this.

opts.useDefaultPorts

Type: Boolean (optional) Default: false

Use the default ports for services instead of looking them up via the port mapper. This can speed up connection times if the system you are connecting to uses the default ports.

opts.useTLS

Type: Boolean (optional) Default: false

Use TLS secure sockets.

Example

const IBMi = require('ibmi');

let opts = {
  opts.hostName: 'localhost',
  opts.userId: 'USER',
  opts.password: 'PASSWORD'
};

let ibmi = new IBMi(opts);

signon()

Signon on to the remote system.

Example

ibmi.signon().then((res) => {
  console.log(res);
}).catch((err) => {
  console.log('Error! %s', err);
});

DataQueue class

The DataQueue class allows you to perform operations on a data queue.

Constructor(system, path)

Remote system and data queue path.

system

Type: IBMi (required)

An IBMi instance.

path

Type: String (required)

The path of the data queue.

Example

const DataQueue = require('ibmi').DataQueue;

let dq = new DataQueue(ibmi, '/QSYS.LIB/SOME.LIB/SOME.DTAQ');

clear(key)

Empty the data queue with optional key.

key

Type: Buffer (optional)

The optional key.

Example

dq.clear().then((res) => {
  ...
}).catch((err) => {
  console.log('Error! %', err);
});

create(entryLength, opts)

entryLength

Type: Number (required)

The maximum length for an entry in the data queue.

opts

Type: Object (optional)

Create options. If you specify this then all options must be set.

opts.authority

Type: String Default *LIBCRTAUT

Authority level of the data queue.

opts.saveSenderInfo

Type: Boolean Default false

Whether or not to save sender information.

opts.fifo

Type: Boolean Default true

Whether or not this should be a FIFO queue.

opts.keyLength

Type: Number Default 0

The length of the key.

opts.forceStorage

Type: Boolean Default false

Whether or no this data queue should persist to storage.

opts.description

Type: String Default Queue

Description of the data queue.

Example

dq.create(50).then((res) => {
  ...
}).catch((err) => {
  console.log('Error! %', err);
});

delete()

Delete the data queue.

Example

dq.delete().then((res) => {
  ...
}).catch((err) => {
  console.log('Error! %', err);
});

peek(wait)

Read the first entry in the data queue, but don't remove it.

wait

Type: Number (optional)

Time to wait in seconds for data to arrive in data queue. -1 indicates to wait indefinitely.

Example

dq.peek().then((res) => {
  if (res) {
    console.log(res.data);
  }
}).catch((err) => {
  console.log('Error! %', err);
});

read(wait)

Read the first entry in the data queue.

wait

Type: Number (optional)

Time to wait in seconds for data to arrive in data queue. -1 indicates to wait indefinitely.

Example

dq.read().then((res) => {
  if (res) {
    console.log(res.data);
  }
}).catch((err) => {
  console.log('Error! %', err);
});

write(data, key)

Write data to the data queue with an optional key.

data

Type: Buffer (required)

Tyhe data to write.

key

Type: Buffer (optional)

The optional key.

Example

let data = new Buffer('DATA');

dq.write(data).then((res) => {
  ...
}).catch((err) {
  console.log('Error! %', err);  
});

ibmi's People

Contributors

smokerbag avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.