diff --git a/README.md b/README.md index 8f38d2f..6d82063 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# sample-node-api +# sample-cli-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. ## Steps @@ -9,8 +9,8 @@ A sample node js api for finding cars and accounts for a dealership,its used her ``` //on local -git clone https://github.com/zowe/sample-node-api -cd sample-node-api +git clone https://github.com/zowe/sample-cli-api +cd sample-cli-api npm install npm run dev ``` @@ -25,9 +25,9 @@ Open your local browser and try accessing ``` -cd sample-node-api +cd sample-cli-api npm run dist -scp -r dist ibmuser@my.mainframe.com:/sample-node-api +scp -r dist ibmuser@my.mainframe.com:/sample-cli-api ``` ## PART II: Deploy with Zowe on server @@ -39,7 +39,7 @@ ssh ibmuser@my.mainframe.com ### 2) install dependencies ``` -cd /sample-node-api +cd /sample-cli-api npm install --only=prod ``` @@ -52,20 +52,20 @@ Append it with your service lifecycle scripts. In our sample it is: ``` vi INSTANCE_DIR/instance.env - EXTERNAL_COMPONENTS=/sample-node-api/bin + EXTERNAL_COMPONENTS=/sample-cli-api/bin ``` We expect following in service folder `start.sh`, `configure.sh` and `validate.sh`. In our case its bin folder with relevant scripts. -`configure.sh` it adds static definition for sample-node-api to folder ${INSTANCE_DIR}/workspace/api-mediation/api-defs in IBM-850 encoding +`configure.sh` it adds static definition for sample-cli-api to folder ${INSTANCE_DIR}/workspace/api-mediation/api-defs in IBM-850 encoding `start.sh` starts node app on configured port `env.sh` its custom script use to configure port for our node app, feel free to use your desired way ### 4) Access newly deployed webservice -Please see static definition file `sample-node-api.yml` -It configures service endpoint as `sample-node-api` with property `serviceId` +Please see static definition file `sample-cli-api.yml` +It configures service endpoint as `sample-cli-api` with property `serviceId` We also provide api gateway base path `api\v1` with property `gatewayUrl` in same file. @@ -75,9 +75,9 @@ In effect, service can be accessed with following url: where `GATEWAY_PORT` is configured in $INSTANCE_DIR/instance.env Verify by accessing following: -`https://my.mainframe.com:7554/api/v1/sample-node-api/accounts/` -`https://my.mainframe.com:7554/api/v1/sample-node-api/accounts/1/` -`https://my.mainframe.com:7554/api/v1/sample-node-api/accounts/1/cars/` +`https://my.mainframe.com:7554/api/v1/sample-cli-api/accounts/` +`https://my.mainframe.com:7554/api/v1/sample-cli-api/accounts/1/` +`https://my.mainframe.com:7554/api/v1/sample-cli-api/accounts/1/cars/` ### 5) Registered With API Catalog diff --git a/package-lock.json b/package-lock.json index a921819..bc91656 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "sample-node-api", + "name": "sample-cli-api", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index b2fb061..e62a984 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "sample-node-api", + "name": "sample-cli-api", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/sample-cli-api.yml b/sample-cli-api.yml new file mode 100644 index 0000000..fc2d4b1 --- /dev/null +++ b/sample-cli-api.yml @@ -0,0 +1,23 @@ +# +services: + - serviceId: sample-cli-api + title: sample-cli-api + description: Sample CLI API + catalogUiTileId: sample-cli-api + instanceBaseUrls: + - http://localhost:17000/ + homePageRelativeUrl: # Home page is at the same URL + routedServices: + - gatewayUrl: api/v1 # [api/ui/ws]/v{majorVersion} + serviceRelativeUrl: + apiInfo: + - apiId: com.ibm.sample-cli-api + gatewayUrl: api/v1 + version: 1.0.0 + swaggerUrl: http://localhost:17000/api-docs + documentationUrl: http://localhost:17000/api-docs-ui + +catalogUiTiles: + sample-cli-api: + title: sample-cli-api + description: Sample CLI API \ No newline at end of file diff --git a/sample-node-api.yml b/sample-node-api.yml deleted file mode 100644 index 9b2a45d..0000000 --- a/sample-node-api.yml +++ /dev/null @@ -1,24 +0,0 @@ -# -services: - - serviceId: sample-node-api - title: Sample-Node-API - description: Sample Node API - catalogUiTileId: sample-node-api - instanceBaseUrls: - - http://localhost:18000/ - - http://localhost:19000/ - homePageRelativeUrl: # Home page is at the same URL - routedServices: - - gatewayUrl: api/v1 # [api/ui/ws]/v{majorVersion} - serviceRelativeUrl: - apiInfo: - - apiId: com.ibm.sample-node-api - gatewayUrl: api/v1 - version: 1.0.0 - swaggerUrl: http://localhost:18000/api-docs - documentationUrl: http://localhost:18000/api-docs-ui - -catalogUiTiles: - sample-node-api: - title: Sample-Node-API - description: Sample Node API \ No newline at end of file diff --git a/src/config.js b/src/config.js index 0123958..b3be655 100644 --- a/src/config.js +++ b/src/config.js @@ -65,7 +65,7 @@ function setUpParams() { .option('s', { alias: 'service', description: 'service-for path', - default: 'sample-node-api' + default: 'sample-cli-api' }) .option('p', { alias: 'port', diff --git a/src/routes/index.route.js b/src/routes/index.route.js index 8d5d842..da6182d 100644 --- a/src/routes/index.route.js +++ b/src/routes/index.route.js @@ -19,7 +19,7 @@ router.use('/cars', cars); router.use('/accounts', accounts); router.use('/', swagger); -router.get('/', (req, res) => res.send('Sample Node API')); +router.get('/', (req, res) => res.send('Sample CLI API')); router.get('/health', (req, res) => { const healthcheck = { uptime: process.uptime(), diff --git a/src/swagger.json b/src/swagger.json index 7385d6b..951168f 100644 --- a/src/swagger.json +++ b/src/swagger.json @@ -1,8 +1,8 @@ { "swagger":"2.0" - ,"info":{"description":"Sample Node API" + ,"info":{"description":"Sample CLI API" ,"version":"1.0" - ,"title":"Sample Node API"} + ,"title":"Sample CLI API"} ,"host":"localhost:18000" ,"basePath":"/" ,"tags":[{"name":"Accounts","description":"Accounts API"},{"name":"Cars","description":"Cars API"}] diff --git a/start-sample.sh b/start-sample.sh index 75c3bb6..06bea6c 100644 --- a/start-sample.sh +++ b/start-sample.sh @@ -1,16 +1,16 @@ ## start locally -node server/app.js --service sample-node-api --port 18000 --key sslcert/server.key --cert sslcert/server.cert -v +node server/app.js --service sample-cli-api --port 18000 --key sslcert/server.key --cert sslcert/server.cert -v -cd ~/zowe/extenders/sample-node-api +cd ~/zowe/extenders/sample-cli-api ## start on z/os uss KEYSTORE_DIRECTORY=~/zowe/keystore KEYSTORE_ALIAS=localhost KEYSTORE_PREFIX="${KEYSTORE_DIRECTORY}/${KEYSTORE_ALIAS}/${KEYSTORE_ALIAS}.keystore" KEYSTORE_KEY=${KEYSTORE_PREFIX}.key KEYSTORE_CERTIFICATE=${KEYSTORE_PREFIX}.cer-ebcdic -node server/app.js --service sample-node-api --port 18000 --key ${KEYSTORE_KEY} --cert ${KEYSTORE_CERTIFICATE} -v +node server/app.js --service sample-cli-api --port 18000 --key ${KEYSTORE_KEY} --cert ${KEYSTORE_CERTIFICATE} -v # register with API ML layer -cd ~/zowe/extenders/sample-node-api -iconv -f IBM-1047 -t IBM-850 sample-node-api.http.yml > bin/sample-node-api-http.yml -iconv -f IBM-1047 -t IBM-850 sample-node-api.http.yml > ~/zowe/instance/workspace/api-mediation/api-defs/sample-node-api.yml \ No newline at end of file +cd ~/zowe/extenders/sample-cli-api +iconv -f IBM-1047 -t IBM-850 sample-cli-api.http.yml > bin/sample-cli-api-http.yml +iconv -f IBM-1047 -t IBM-850 sample-cli-api.http.yml > ~/zowe/instance/workspace/api-mediation/api-defs/sample-cli-api.yml \ No newline at end of file