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.
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 |
The IBMi class is the main class of the library. It represents a remote IBMi system.
System options.
Type: Object
(required)
{
hostName: 'localhost',
...other IBMi options...
}
Type: String
(required)
The host name of the remote system.
Type: String
(required)
The user ID.
Type: String
(required)
The password.
Type: Number
(optional)
Default: 449
The port that the port mapper service runs on. You should probably never have a need to change this.
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.
Type: Boolean
(optional)
Default: false
Use TLS secure sockets.
const IBMi = require('ibmi');
let opts = {
opts.hostName: 'localhost',
opts.userId: 'USER',
opts.password: 'PASSWORD'
};
let ibmi = new IBMi(opts);
Signon on to the remote system.
ibmi.signon().then((res) => {
console.log(res);
}).catch((err) => {
console.log('Error! %s', err);
});
The DataQueue class allows you to perform operations on a data queue.
Remote system and data queue path.
Type: IBMi
(required)
An IBMi instance.
Type: String
(required)
The path of the data queue.
const DataQueue = require('ibmi').DataQueue;
let dq = new DataQueue(ibmi, '/QSYS.LIB/SOME.LIB/SOME.DTAQ');
Empty the data queue with optional key.
Type: Buffer
(optional)
The optional key.
dq.clear().then((res) => {
...
}).catch((err) => {
console.log('Error! %', err);
});
Type: Number
(required)
The maximum length for an entry in the data queue.
Type: Object
(optional)
Create options. If you specify this then all options must be set.
Type: String
Default *LIBCRTAUT
Authority level of the data queue.
Type: Boolean
Default false
Whether or not to save sender information.
Type: Boolean
Default true
Whether or not this should be a FIFO queue.
Type: Number
Default 0
The length of the key.
Type: Boolean
Default false
Whether or no this data queue should persist to storage.
Type: String
Default Queue
Description of the data queue.
dq.create(50).then((res) => {
...
}).catch((err) => {
console.log('Error! %', err);
});
Delete the data queue.
dq.delete().then((res) => {
...
}).catch((err) => {
console.log('Error! %', err);
});
Read the first entry in the data queue, but don't remove it.
Type: Number
(optional)
Time to wait in seconds for data to arrive in data queue. -1 indicates to wait indefinitely.
dq.peek().then((res) => {
if (res) {
console.log(res.data);
}
}).catch((err) => {
console.log('Error! %', err);
});
Read the first entry in the data queue.
Type: Number
(optional)
Time to wait in seconds for data to arrive in data queue. -1 indicates to wait indefinitely.
dq.read().then((res) => {
if (res) {
console.log(res.data);
}
}).catch((err) => {
console.log('Error! %', err);
});
Write data to the data queue with an optional key.
Type: Buffer
(required)
Tyhe data to write.
Type: Buffer
(optional)
The optional key.
let data = new Buffer('DATA');
dq.write(data).then((res) => {
...
}).catch((err) {
console.log('Error! %', err);
});