sample-node-api

A sample node js api for finding cars and accounts for a dealership,its used here to demonstrate the steps to extend API/ML with your own rest api.

Manual Installation

Steps

Note
Only rest api with https support can be deployed behind API/ML, make sure to enable https support in your rest api.

Note
Replace /u/zowe/ibmuser/1.0.0/ with your zowe installation folder
Replace ibmuser@my.mainframe.com with your username and mainframe-ip

This sample express app, has https enabled already.

1) Clone the repository, install node packages and verify routes locally

//on local
git clone https://github.com/zowe/sample-node-api
cd sample-node-api
npm install
npm start

Open your local browser and try accessing
https://localhost:4000/accounts/
https://localhost:4000/accounts/1
https://localhost:4000/accounts/1/cars/

2) Transfer project files from local to remote host

Note
Don't transfer node_moules folder, we can do install npm install later on remote server itself to pull down required node packages

// on remote - Create placeholder directory for your node app
ssh ibmuser@my.mainframe.com
cd /u/zowe/ibmuser/1.0.0/
mkdir sample-node-api

//on local - use scp to transfer project files
scp data.js ibmuser@my.mainframe.com:/u/zowe/ibmuser/1.0.0/sample-node-api
scp package.json ibmuser@my.mainframe.com:/u/zowe/ibmuser/1.0.0/sample-node-api
scp package-lock.json ibmuser@my.mainframe.com:/u/zowe/ibmuser/1.0.0/sample-node-api
scp sample-node-api.yml ibmuser@my.mainframe.com:/u/zowe/ibmuser/1.0.0/sample-node-api/sample-node-api.yml.1047

scp -r scripts ibmuser@my.mainframe.com:/u/zowe/ibmuser/1.0.0/sample-node-api/scripts
scp -r server ibmuser@my.mainframe.com:/u/zowe/ibmuser/1.0.0/sample-node-api/server
scp -r sslcert ibmuser@my.mainframe.com:/u/zowe/ibmuser/1.0.0/sample-node-api/sslcert

3) Install node packages required by API

// on remote
cd /u/zowe/ibmuser/1.0.0/sample-node-api
npm install

4) Register a plugin API/ML layer using yml file

Note
Require encoding for sample-node-api.yml is IBM-850, use iconv utility to convert it to correct format

Yaml config file needs to be present in api-defs folder along-with other statically discovered API example jobs.yml, uss.yml etc

// on remote
cd /u/zowe/ibmuser/1.0.0/sample-node-api
iconv -t IBM-850 -f IBM-1047 sample-node-api.yml.1047 > sample-node-api.yml
mv sample-node-api.yml ../api-mediation/api-defs/

5) Edit run-zowe.sh on remote append node app startup script

// on remote
cd /u/zowe/ibmuser/1.0.0/scripts/internal/
vi run-zowe.sh

Append following start command for sample-node-api, among similar command from another services

`dirname $0`/../../sample-node-api/scripts/start-sample-node-api.sh

6) Restart Zowe

7) Access newly deployed webservice behind api/v1

https://my.mainframe.com:7554/api/v1/node-sample-api/accounts/
https://my.mainframe.com:7554/api/v1/node-sample-api/accounts/1/
https://my.mainframe.com:7554/api/v1/node-sample-api/accounts/1/cars/

Description
No description provided
Readme EPL-2.0 924 KiB
Languages
JavaScript 62.4%
Shell 32.7%
Dockerfile 4.9%