The example programs listed at https://www.ibm.com/developerworks/ibmi/library/i-native-js-app-ibmi-with-nodejs/ seemed to start of with "Hello World" and then from there continue on with very general, yet useful, examples.
Now, by "general" I mean just that. The example has an input to enter an SQL statement (which the results of are returned as JSON) as well as a input to run a system command (not sure how safe that is... yikes!)
First, I created a local IP address that I could use to run my node.js applications on (using CFGTCP option 1). This IP address will be used in the applications to come. The port number that is used is also specified in the node source so for this example I just chose to use a standard port of 80.
We also need a place that will hold the sample JS file and HTML file. I decided to create a directory on my system named /nodejs that would be for all my node.js applications. This of course should be easily changed if needed.
I then created a subdirectory with my userid to hold my node.js source. So, I had /nodejs/bvstone.
Next I created the first node.js application from the sample and started up the application using Pase (Pase is started using CALL QP2TERM. I actually created a command named SSH that calls this to make it easier to remember).
Server running at http://192.168.1.39:80
Once up and running I opened my browser and pointed it to http://192.168.1.39 and low and behold, I saw "Hello World."
I then continued on through the examples and even got the SQL example to work. But, when I started on the CL command example I started getting some errors. I did some searching and found I could turn on more debugging for my application using the following on my connection:
var conn = new xt.iConn(DBname); conn.debug(true);
I then saw that I was getting the following error when trying to run a CL command:
CL statement : wrksyssts
[Error: SQLSTATE=57017 SQLCODE=-332 Character conversion between CCSID 1208 and CCSID 65535 not valid.]
If I ran it again I received a different error:
CL statement : WRKSYSSTS
[Error: SQLSTATE=HY010 SQLCODE=-99999 Error occurred in SQL Call Level Interface]
I did a little digging and found that my user ID was set up to use *SYSVAL as the job CCSID. The system value for QCCSID was 65535. Well, that makes sense, I guess. So I changed the system value for QCCSID to 37, signed off, signed back on, started my node job again and things were working great.
Next I will need to make my own example that works with real data to see how things really work in the real world. That is what I'm most interested in. No matter how much we hate to start with "Hello World" and other simple examples they are a necessary evil.