├── tests ├── tests │ └── dat ├── dat │ ├── sdk │ │ ├── hello.js │ │ ├── trigger.js │ │ ├── createTrigger.js │ │ ├── invoke.js │ │ └── createRule.js │ ├── getNodeVersion.js │ ├── db2 │ │ ├── setup.sql │ │ ├── testdb2read.js │ │ └── testdb2action.js │ ├── watson │ │ ├── testWatsonAction.js │ │ └── testWatsonAction2.js │ ├── cos │ │ └── testcosread.js │ └── cloudant │ │ ├── testCloudantActionNoCreds.js │ │ └── testCloudantAction.js ├── credentials.json.enc ├── src │ └── test │ │ ├── resources │ │ └── application.conf │ │ └── scala │ │ └── runtime │ │ ├── sdk │ │ ├── NodeJs10SDKTests.scala │ │ ├── NodeJs12SDKTests.scala │ │ ├── NodeJs16SDKTests.scala │ │ ├── NodeJs20SDKTests.scala │ │ └── NodeJsSDKTests.scala │ │ ├── actionContainers │ │ ├── IBMNodeJs10ActionDB2Tests.scala │ │ ├── IBMNodeJs12ActionDB2Tests.scala │ │ ├── IBMNodeJs16ActionDB2Tests.scala │ │ ├── IBMNodeJs20ActionDB2Tests.scala │ │ ├── IBMNodeJs10ActionWatsonTests.scala │ │ ├── IBMNodeJs12ActionWatsonTests.scala │ │ ├── IBMNodeJs16ActionWatsonTests.scala │ │ ├── IBMNodeJs20ActionWatsonTests.scala │ │ ├── IBMNodeJs10ActionCloudantTests.scala │ │ ├── IBMNodeJs12ActionCloudantTests.scala │ │ ├── IBMNodeJs16ActionCloudantTests.scala │ │ ├── IBMNodeJs20ActionCloudantTests.scala │ │ ├── IBMNodeJsActionContainerTests.scala │ │ ├── IBMNodeJs10ActionContainerTests.scala │ │ ├── IBMNodeJs12ActionContainerTests.scala │ │ ├── IBMNodeJs16ActionContainerTests.scala │ │ ├── IBMNodeJs20ActionContainerTests.scala │ │ ├── IBMNodeJsActionCloudantTests.scala │ │ ├── IBMNodeJsActionWatsonTests.scala │ │ └── IBMNodeJsActionDB2Tests.scala │ │ └── integration │ │ ├── CredentialsIBMNodeJs10COSTests.scala │ │ ├── CredentialsIBMNodeJs12COSTests.scala │ │ ├── CredentialsIBMNodeJs16COSTests.scala │ │ ├── CredentialsIBMNodeJs20COSTests.scala │ │ ├── CredentialsIBMNodeJs10Db2CloudTests.scala │ │ ├── CredentialsIBMNodeJs12Db2CloudTests.scala │ │ ├── CredentialsIBMNodeJs16Db2CloudTests.scala │ │ ├── CredentialsIBMNodeJs20Db2CloudTests.scala │ │ ├── CredentialsIBMNodeJs10ActionWatsonTests.scala │ │ ├── CredentialsIBMNodeJs12ActionWatsonTests.scala │ │ ├── CredentialsIBMNodeJs16ActionWatsonTests.scala │ │ ├── CredentialsIBMNodeJs20ActionWatsonTests.scala │ │ ├── CredentialsIBMNodeJs10ActionCloudantTests.scala │ │ ├── CredentialsIBMNodeJs12ActionCloudantTests.scala │ │ ├── CredentialsIBMNodeJs16ActionCloudantTests.scala │ │ ├── CredentialsIBMNodeJs20ActionCloudantTests.scala │ │ ├── CredentialsIBMNodeJsDb2CloudTests.scala │ │ ├── CredentialsIBMNodeJsActionCloudantTests.scala │ │ ├── CredentialsIBMNodeJsCOSTests.scala │ │ └── CredentialsIBMNodeJsActionWatsonTests.scala └── build.gradle ├── examples ├── packaging_npm │ ├── README.md │ ├── package.json │ └── my-action.js ├── structuring_js_code │ ├── example.js │ ├── README.md │ └── example_multi_funcs.js ├── apicall │ ├── README.md │ └── api_call.js ├── synchronous │ ├── README.md │ └── synchronous.js ├── asynchronous │ ├── README.md │ ├── asynchronous_reject.js │ └── asynchronous_resolve.js ├── sync_and_async │ ├── README.md │ └── sync_and_async.js ├── packaging_webpack │ ├── index.js │ ├── webpack.config.js │ └── package.json └── README.md ├── nodejs10 ├── .dockerignore ├── build.gradle ├── Dockerfile └── package.json ├── nodejs12 ├── .dockerignore ├── build.gradle ├── Dockerfile └── package.json ├── nodejs14 ├── .dockerignore ├── build.gradle ├── Dockerfile ├── package.json └── CHANGELOG.md ├── nodejs16 ├── .dockerignore ├── build.gradle ├── package.json ├── Dockerfile └── CHANGELOG.md ├── nodejs20 ├── .dockerignore ├── build.gradle ├── package.json ├── Dockerfile └── CHANGELOG.md ├── nodejs8 ├── .dockerignore ├── build.gradle ├── Dockerfile └── package.json ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md └── docker.gradle ├── .scalafmt.conf ├── .gitignore ├── LICENSE.txt ├── settings.gradle ├── ansible └── environments │ └── local │ ├── hosts │ └── group_vars │ └── all ├── tools └── travis │ ├── publish.sh │ ├── setup.sh │ ├── deploy.sh │ ├── test.sh │ └── build.sh ├── iam-client └── iam-openwhisk-main.js ├── .github └── workflows │ └── run-tests.yml ├── .travis.yml ├── gradlew └── README.md /tests/tests/dat: -------------------------------------------------------------------------------- 1 | ../dat -------------------------------------------------------------------------------- /examples/packaging_npm/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nodejs10/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | Dockerfile 4 | build.gradle -------------------------------------------------------------------------------- /nodejs12/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | Dockerfile 4 | build.gradle -------------------------------------------------------------------------------- /nodejs14/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | Dockerfile 4 | build.gradle -------------------------------------------------------------------------------- /nodejs16/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | Dockerfile 4 | build.gradle -------------------------------------------------------------------------------- /nodejs20/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | Dockerfile 4 | build.gradle -------------------------------------------------------------------------------- /nodejs8/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | Dockerfile 4 | build.gradle -------------------------------------------------------------------------------- /tests/dat/sdk/hello.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | return { msg: 'Hello world' }; 3 | } -------------------------------------------------------------------------------- /examples/structuring_js_code/example.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | return {payload: 'Hello world'}; 3 | } -------------------------------------------------------------------------------- /examples/apicall/README.md: -------------------------------------------------------------------------------- 1 | # Example: Calling an external API with JavaScript 2 | - [Example Calling API](api_call.js) -------------------------------------------------------------------------------- /tests/credentials.json.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-functions/runtime-nodejs/HEAD/tests/credentials.json.enc -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-functions/runtime-nodejs/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/synchronous/README.md: -------------------------------------------------------------------------------- 1 | # Structuring JavaScript code with synchronous behavior 2 | - [Example of synchronous code](synchronous.js) -------------------------------------------------------------------------------- /examples/structuring_js_code/README.md: -------------------------------------------------------------------------------- 1 | # Structuring JavaScript code 2 | - [Example](example.js) 3 | - [Example with multiple functions](example_multi_funcs.js) -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | style = intellij 2 | danglingParentheses = false 3 | maxColumn = 120 4 | docstrings = JavaDoc 5 | rewrite.rules = [SortImports] 6 | project.git = true -------------------------------------------------------------------------------- /tests/dat/getNodeVersion.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | console.log(`process.version= ${process.version}`); 3 | return { 4 | version: process.version 5 | }; 6 | } -------------------------------------------------------------------------------- /examples/structuring_js_code/example_multi_funcs.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | return { payload: helper() } 3 | } 4 | 5 | function helper() { 6 | return new Date(); 7 | } -------------------------------------------------------------------------------- /examples/packaging_npm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-action", 3 | "main": "my-action.js", 4 | "dependencies": { 5 | "left-pad": "^1.3.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/asynchronous/README.md: -------------------------------------------------------------------------------- 1 | # Structuring JavaScript code with asynchronous behavior 2 | - [Example Reslove](asynchronous_resolve.js) 3 | - [Example Reject](asynchronous_reject.js) -------------------------------------------------------------------------------- /examples/sync_and_async/README.md: -------------------------------------------------------------------------------- 1 | # Structuring JavaScript code with synchronous and asynchronous behavior 2 | - [Example with synchronous and asynchronous behavior](sync_and_async.js) -------------------------------------------------------------------------------- /examples/asynchronous/asynchronous_reject.js: -------------------------------------------------------------------------------- 1 | function main(args) { 2 | return new Promise(function(resolve, reject) { 3 | setTimeout(function() { 4 | reject({ done: true }); 5 | }, 2000); 6 | }) 7 | } -------------------------------------------------------------------------------- /examples/asynchronous/asynchronous_resolve.js: -------------------------------------------------------------------------------- 1 | function main(args) { 2 | return new Promise(function(resolve, reject) { 3 | setTimeout(function() { 4 | resolve({ done: true }); 5 | }, 2000); 6 | }) 7 | } -------------------------------------------------------------------------------- /examples/packaging_npm/my-action.js: -------------------------------------------------------------------------------- 1 | function myAction(args) { 2 | const leftPad = require("left-pad") 3 | const lines = args.lines || []; 4 | return { padded: lines.map(l => leftPad(l, 30, ".")) } 5 | } 6 | 7 | exports.main = myAction; -------------------------------------------------------------------------------- /examples/packaging_webpack/index.js: -------------------------------------------------------------------------------- 1 | function myAction(args) { 2 | const leftPad = require("left-pad") 3 | const lines = args.lines || []; 4 | return { padded: lines.map(l => leftPad(l, 30, ".")) } 5 | } 6 | 7 | global.main = myAction; 8 | -------------------------------------------------------------------------------- /examples/packaging_webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | module.exports = { 3 | entry: './index.js', 4 | output: { 5 | path: path.resolve(__dirname, 'dist'), 6 | filename: 'bundle.js' 7 | }, 8 | target: 'node' 9 | }; -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip 6 | -------------------------------------------------------------------------------- /tests/src/test/resources/application.conf: -------------------------------------------------------------------------------- 1 | 2 | # For the runtime tests we use the same application.conf that is used 3 | # in the tests for the openwhisk environment itself. 4 | 5 | include file("../../openwhisk/tests/src/test/resources/application.conf") 6 | -------------------------------------------------------------------------------- /tests/dat/db2/setup.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE TEST AUTOMATIC STORAGE YES USING CODESET UTF-8 TERRITORY US PAGESIZE 4096; 2 | CONNECT TO TEST; 3 | 4 | CREATE TABLE TESTTABLE ( 5 | NAME VARCHAR(20) NOT NULL, 6 | AGE INTEGER NOT NULL, 7 | LOCATION VARCHAR(20) 8 | ); 9 | -------------------------------------------------------------------------------- /tests/dat/sdk/trigger.js: -------------------------------------------------------------------------------- 1 | const openwhisk = require('openwhisk') 2 | function main(params){ 3 | let ow = openwhisk({ 4 | ignore_certs:params.ignore_certs 5 | }) 6 | return ow.triggers.invoke({ 7 | name: params.triggerName 8 | }) 9 | } -------------------------------------------------------------------------------- /tests/dat/sdk/createTrigger.js: -------------------------------------------------------------------------------- 1 | const openwhisk = require('openwhisk') 2 | function main(params){ 3 | let ow = openwhisk({ 4 | ignore_certs:params.ignore_certs 5 | }) 6 | return ow.triggers.create({ 7 | name: params.triggerName 8 | }) 9 | } -------------------------------------------------------------------------------- /tests/dat/sdk/invoke.js: -------------------------------------------------------------------------------- 1 | const openwhisk = require('openwhisk') 2 | function main(params){ 3 | let ow = openwhisk({ 4 | ignore_certs:params.ignore_certs 5 | }) 6 | return ow.actions.invoke({ 7 | name: '/whisk.system/utils/date', 8 | blocking: true 9 | }) 10 | } -------------------------------------------------------------------------------- /tests/dat/sdk/createRule.js: -------------------------------------------------------------------------------- 1 | const openwhisk = require('openwhisk') 2 | function main(params){ 3 | let ow = openwhisk({ 4 | ignore_certs:params.ignore_certs 5 | }) 6 | return ow.rules.create({ 7 | name: params.ruleName, 8 | action: params.actionName, 9 | trigger: params.triggerName 10 | }) 11 | } -------------------------------------------------------------------------------- /examples/apicall/api_call.js: -------------------------------------------------------------------------------- 1 | let rp = require('request-promise') 2 | 3 | function main(params) { 4 | const options = { 5 | uri: "https://api.nasa.gov/planetary/apod?api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo", 6 | json: true 7 | } 8 | return rp(options) 9 | .then(res => { 10 | return { response: res } 11 | }) 12 | } -------------------------------------------------------------------------------- /examples/synchronous/synchronous.js: -------------------------------------------------------------------------------- 1 | // each path results in a synchronous activation 2 | function main(params) { 3 | if (params.payload == 0) { 4 | return; 5 | } else if (params.payload == 1) { 6 | return {payload: 'Hello, World!'}; 7 | } else if (params.payload == 2) { 8 | return {error: 'payload must be 0 or 1'}; 9 | } 10 | } -------------------------------------------------------------------------------- /nodejs10/build.gradle: -------------------------------------------------------------------------------- 1 | ext.dockerImageName = 'action-nodejs-v10' 2 | apply from: '../gradle/docker.gradle' 3 | 4 | distDocker.dependsOn 'copyIAMClient' 5 | distDocker.finalizedBy('cleanup') 6 | 7 | task copyIAMClient(type: Copy) { 8 | from '../iam-client' 9 | into 'iam-client' 10 | } 11 | 12 | task cleanup(type: Delete) { 13 | delete 'iam-client' 14 | } -------------------------------------------------------------------------------- /nodejs8/build.gradle: -------------------------------------------------------------------------------- 1 | ext.dockerImageName = 'action-nodejs-v8' 2 | apply from: '../gradle/docker.gradle' 3 | 4 | distDocker.dependsOn 'copyIAMClient' 5 | distDocker.finalizedBy('cleanup') 6 | 7 | task copyIAMClient(type: Copy) { 8 | from '../iam-client' 9 | into 'iam-client' 10 | } 11 | 12 | task cleanup(type: Delete) { 13 | delete 'iam-client' 14 | } -------------------------------------------------------------------------------- /nodejs12/build.gradle: -------------------------------------------------------------------------------- 1 | ext.dockerImageName = 'action-nodejs-v12' 2 | apply from: '../gradle/docker.gradle' 3 | 4 | distDocker.dependsOn 'copyIAMClient' 5 | distDocker.finalizedBy('cleanup') 6 | 7 | task copyIAMClient(type: Copy) { 8 | from '../iam-client' 9 | into 'iam-client' 10 | } 11 | 12 | task cleanup(type: Delete) { 13 | delete 'iam-client' 14 | } 15 | -------------------------------------------------------------------------------- /nodejs14/build.gradle: -------------------------------------------------------------------------------- 1 | ext.dockerImageName = 'action-nodejs-v14' 2 | apply from: '../gradle/docker.gradle' 3 | 4 | distDocker.dependsOn 'copyIAMClient' 5 | distDocker.finalizedBy('cleanup') 6 | 7 | task copyIAMClient(type: Copy) { 8 | from '../iam-client' 9 | into 'iam-client' 10 | } 11 | 12 | task cleanup(type: Delete) { 13 | delete 'iam-client' 14 | } 15 | -------------------------------------------------------------------------------- /examples/sync_and_async/sync_and_async.js: -------------------------------------------------------------------------------- 1 | function main(params) { 2 | if (params.payload) { 3 | // asynchronous activation 4 | return new Promise(function(resolve, reject) { 5 | setTimeout(function() { 6 | resolve({ done: true }); 7 | }, 2000); 8 | }) 9 | } else { 10 | // synchronous activation 11 | return {done: true}; 12 | } 13 | } -------------------------------------------------------------------------------- /tests/dat/watson/testWatsonAction.js: -------------------------------------------------------------------------------- 1 | // This will error out if watson not available. 2 | // For the nodejs12 runtime (and later) we use the ibm-watson package. On the previous 3 | // runtime versions we use the watson-developer-cloud package. 4 | var DiscoveryV1 = process.version.startsWith('v10.') ? require("watson-developer-cloud/discovery/v1") 5 | : require("ibm-watson/discovery/v1") 6 | 7 | 8 | function main(args){ 9 | return {} 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Tests 2 | tests/.cache-main 3 | tests/.classpath 4 | tests/.gitignore 5 | tests/.project 6 | tests/.settings/ 7 | tests/credentials.json 8 | tests/vcap_services.json 9 | 10 | # Linux 11 | *~ 12 | 13 | # Mac 14 | .DS_Store 15 | 16 | # Gradle 17 | .gradle 18 | build/ 19 | !/tools/build/ 20 | 21 | # NodeJS 22 | node_modules 23 | package-lock.json 24 | 25 | # IntelliJ 26 | .idea 27 | *.class 28 | out/ 29 | *.iml 30 | target/ 31 | 32 | # Eclipse 33 | bin/ 34 | **/.project 35 | .settings/ 36 | .classpath 37 | .cache-main 38 | .cache-tests 39 | 40 | .vscode/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2017 IBM Corp. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /examples/packaging_webpack/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-action", 3 | "main": "dist/bundle.js", 4 | "scripts": { 5 | "prebuild": "NODE_ENV=development npm install", 6 | "build": "webpack --config webpack.config.js ", 7 | "deploy": "ibmcloud fn action update my-action dist/bundle.js --kind nodejs:16", 8 | "clean": "rm -rf node_modules package-lock.json dist" 9 | }, 10 | "dependencies": { 11 | "left-pad": "1.1.3" 12 | }, 13 | "devDependencies": { 14 | "webpack": "^5.72.0", 15 | "webpack-cli": "^4.9.2" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /nodejs16/build.gradle: -------------------------------------------------------------------------------- 1 | ext.dockerImageName = 'action-nodejs-v16' 2 | apply from: '../gradle/docker.gradle' 3 | 4 | distDocker.dependsOn 'copyIAMClient' 5 | distDocker.finalizedBy('cleanup') 6 | 7 | // To always get the latest vulnerability updates into the image, use --no-cache for building the image. 8 | // This is not needed for travis builds (the VM is always new), but for local development. 9 | dockerBuildArg = ['build','--no-cache'] 10 | 11 | task copyIAMClient(type: Copy) { 12 | from '../iam-client' 13 | into 'iam-client' 14 | } 15 | 16 | task cleanup(type: Delete) { 17 | delete 'iam-client' 18 | } 19 | -------------------------------------------------------------------------------- /nodejs20/build.gradle: -------------------------------------------------------------------------------- 1 | ext.dockerImageName = 'action-nodejs-v20' 2 | apply from: '../gradle/docker.gradle' 3 | 4 | distDocker.dependsOn 'copyIAMClient' 5 | distDocker.finalizedBy('cleanup') 6 | 7 | // To always get the latest vulnerability updates into the image, use --no-cache for building the image. 8 | // This is not needed for travis builds (the VM is always new), but for local development. 9 | dockerBuildArg = ['build','--no-cache'] 10 | 11 | task copyIAMClient(type: Copy) { 12 | from '../iam-client' 13 | into 'iam-client' 14 | } 15 | 16 | task cleanup(type: Delete) { 17 | delete 'iam-client' 18 | } 19 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'tests' 2 | 3 | include 'nodejs16' 4 | include 'nodejs20' 5 | 6 | rootProject.name = 'runtime-nodejs-ibm' 7 | 8 | gradle.ext.openwhisk = [ 9 | version: '1.0.0-SNAPSHOT' 10 | ] 11 | 12 | gradle.ext.scala = [ 13 | version: '2.12.7', 14 | depVersion : '2.12', 15 | compileFlags: ['-feature', '-unchecked', '-deprecation', '-Xfatal-warnings', '-Ywarn-unused-import'] 16 | ] 17 | 18 | gradle.ext.scalafmt = [ 19 | version: '1.5.0', 20 | config: new File(rootProject.projectDir, '.scalafmt.conf') 21 | ] 22 | 23 | gradle.ext.akka = [version : '2.5.32'] 24 | gradle.ext.akka_http = [version : '10.2.4'] 25 | -------------------------------------------------------------------------------- /nodejs8/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openwhisk/action-nodejs-v8:3e843c0 2 | COPY ./package.json / 3 | RUN apt-get update \ 4 | # Upgrade installed packages to get latest security fixes if the base image does not contain them already. 5 | && apt-get upgrade -y --no-install-recommends \ 6 | # Cleanup apt data, we do not need them later on. 7 | && rm -rf /var/lib/apt/lists/* \ 8 | # Start adding/updating npm packages. 9 | && cd / \ 10 | && npm install --production \ 11 | && npm cache clean --force 12 | 13 | COPY iam-client/iam-openwhisk-main.js /node_modules/openwhisk/lib/ 14 | RUN sed -i.bak 's/lib\/main.js/lib\/iam-openwhisk-main.js/' /node_modules/openwhisk/package.json 15 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/sdk/NodeJs10SDKTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package runtime.sdk 18 | 19 | import org.junit.runner.RunWith 20 | import org.scalatest.junit.JUnitRunner 21 | 22 | @RunWith(classOf[JUnitRunner]) 23 | class NodeJs10SDKTests extends NodeJsSDKTests { 24 | override lazy val actionKind = "nodejs:10" 25 | } 26 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/sdk/NodeJs12SDKTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package runtime.sdk 18 | 19 | import org.junit.runner.RunWith 20 | import org.scalatest.junit.JUnitRunner 21 | 22 | @RunWith(classOf[JUnitRunner]) 23 | class NodeJs12SDKTests extends NodeJsSDKTests { 24 | override lazy val actionKind = "nodejs:12" 25 | } 26 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/sdk/NodeJs16SDKTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package runtime.sdk 18 | 19 | import org.junit.runner.RunWith 20 | import org.scalatest.junit.JUnitRunner 21 | 22 | @RunWith(classOf[JUnitRunner]) 23 | class NodeJs16SDKTests extends NodeJsSDKTests { 24 | override lazy val actionKind = "nodejs:16" 25 | } 26 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/sdk/NodeJs20SDKTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package runtime.sdk 18 | 19 | import org.junit.runner.RunWith 20 | import org.scalatest.junit.JUnitRunner 21 | 22 | @RunWith(classOf[JUnitRunner]) 23 | class NodeJs20SDKTests extends NodeJsSDKTests { 24 | override lazy val actionKind = "nodejs:20" 25 | } 26 | -------------------------------------------------------------------------------- /tests/dat/cos/testcosread.js: -------------------------------------------------------------------------------- 1 | var AWS = require('ibm-cos-sdk'); 2 | const endpoint = 's3-api.us-geo.objectstorage.softlayer.net'; 3 | const ibmAuthEndpoint = 'https://iam.ng.bluemix.net/oidc/token'; 4 | var params = { 5 | Bucket: 'ibm-functions-devops-testing', 6 | Key: 'testdata.txt' 7 | } 8 | var cos; 9 | function main({ 10 | __bx_creds: { 11 | "cloud-object-storage": { apikey }, 12 | "cloud-object-storage": { resource_instance_id } 13 | } 14 | }) { 15 | cos = cos || new AWS.S3({ 16 | endpoint: endpoint, 17 | ibmAuthEndpoint: ibmAuthEndpoint, 18 | apiKeyId: apikey, 19 | serviceInstanceId: resource_instance_id 20 | }); 21 | return new Promise((resolve, reject) => { 22 | cos.getObject(params, (err, data) => { 23 | if (err) { 24 | console.error("something bad happened", err); 25 | reject({ Error: err }) 26 | } else { 27 | resolve({ data: data.Body.toString('utf-8') }) 28 | } 29 | }); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs10ActionDB2Tests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs10ActionDB2Tests extends IBMNodeJsActionDB2Tests { 23 | override lazy val defaultKind = "nodejs:10" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs12ActionDB2Tests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs12ActionDB2Tests extends IBMNodeJsActionDB2Tests { 23 | override lazy val defaultKind = "nodejs:12" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs16ActionDB2Tests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs16ActionDB2Tests extends IBMNodeJsActionDB2Tests { 23 | override lazy val defaultKind = "nodejs:16" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs20ActionDB2Tests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs20ActionDB2Tests extends IBMNodeJsActionDB2Tests { 23 | override lazy val defaultKind = "nodejs:20" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs10ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs10ActionWatsonTests extends IBMNodeJsActionWatsonTests { 23 | override lazy val defaultKind = "nodejs:10" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs12ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs12ActionWatsonTests extends IBMNodeJsActionWatsonTests { 23 | override lazy val defaultKind = "nodejs:12" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs16ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs16ActionWatsonTests extends IBMNodeJsActionWatsonTests { 23 | override lazy val defaultKind = "nodejs:16" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs20ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs20ActionWatsonTests extends IBMNodeJsActionWatsonTests { 23 | override lazy val defaultKind = "nodejs:20" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs10COSTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs10COSTests extends CredentialsIBMNodeJsCOSTests { 23 | override lazy val defaultKind = Some("nodejs:10") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs12COSTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs12COSTests extends CredentialsIBMNodeJsCOSTests { 23 | override lazy val defaultKind = Some("nodejs:12") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs16COSTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs16COSTests extends CredentialsIBMNodeJsCOSTests { 23 | override lazy val defaultKind = Some("nodejs:16") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs20COSTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs20COSTests extends CredentialsIBMNodeJsCOSTests { 23 | override lazy val defaultKind = Some("nodejs:20") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs10ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs10ActionCloudantTests extends IBMNodeJsActionCloudantTests { 23 | override lazy val defaultKind = "nodejs:10" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs12ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs12ActionCloudantTests extends IBMNodeJsActionCloudantTests { 23 | override lazy val defaultKind = "nodejs:12" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs16ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs16ActionCloudantTests extends IBMNodeJsActionCloudantTests { 23 | override lazy val defaultKind = "nodejs:16" 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs20ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs20ActionCloudantTests extends IBMNodeJsActionCloudantTests { 23 | override lazy val defaultKind = "nodejs:20" 24 | } 25 | -------------------------------------------------------------------------------- /ansible/environments/local/hosts: -------------------------------------------------------------------------------- 1 | ; the first parameter in a host is the inventory_hostname 2 | 3 | ; used for local actions only 4 | ansible ansible_connection=local 5 | 6 | [edge] 7 | 172.17.0.1 ansible_host=172.17.0.1 ansible_connection=local 8 | 9 | [controllers] 10 | controller0 ansible_host=172.17.0.1 ansible_connection=local 11 | 12 | [kafkas] 13 | kafka0 ansible_host=172.17.0.1 ansible_connection=local 14 | 15 | [zookeepers:children] 16 | kafkas 17 | 18 | [invokers] 19 | invoker0 ansible_host=172.17.0.1 ansible_connection=local 20 | 21 | ; db group is only used if db_provider is CouchDB 22 | [db] 23 | 172.17.0.1 ansible_host=172.17.0.1 ansible_connection=local 24 | 25 | [elasticsearch:children] 26 | db 27 | 28 | [redis] 29 | 172.17.0.1 ansible_host=172.17.0.1 ansible_connection=local 30 | 31 | [apigateway] 32 | 172.17.0.1 ansible_host=172.17.0.1 ansible_connection=local 33 | 34 | [etcd] 35 | etcd0 ansible_host=172.17.0.1 ansible_connection=local 36 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs10Db2CloudTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs10Db2CloudTests extends CredentialsIBMNodeJsDb2CloudTests { 23 | override lazy val defaultKind = Some("nodejs:10") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs12Db2CloudTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs12Db2CloudTests extends CredentialsIBMNodeJsDb2CloudTests { 23 | override lazy val defaultKind = Some("nodejs:12") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs16Db2CloudTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs16Db2CloudTests extends CredentialsIBMNodeJsDb2CloudTests { 23 | override lazy val defaultKind = Some("nodejs:16") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs20Db2CloudTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs20Db2CloudTests extends CredentialsIBMNodeJsDb2CloudTests { 23 | override lazy val defaultKind = Some("nodejs:20") 24 | } 25 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJsActionContainerTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJsActionContainerTests extends NodeJsActionContainerTests { 23 | 24 | override lazy val nodejsContainerImageName = "action-nodejs-v14" 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs10ActionContainerTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs10ActionContainerTests extends NodeJsActionContainerTests { 23 | 24 | override lazy val nodejsContainerImageName = "action-nodejs-v10" 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs12ActionContainerTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs12ActionContainerTests extends NodeJsActionContainerTests { 23 | 24 | override lazy val nodejsContainerImageName = "action-nodejs-v12" 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs16ActionContainerTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs16ActionContainerTests extends NodeJsActionContainerTests { 23 | 24 | override lazy val nodejsContainerImageName = "action-nodejs-v16" 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJs20ActionContainerTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class IBMNodeJs20ActionContainerTests extends NodeJsActionContainerTests { 23 | 24 | override lazy val nodejsContainerImageName = "action-nodejs-v20" 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs10ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs10ActionWatsonTests extends CredentialsIBMNodeJsActionWatsonTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:10") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs12ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs12ActionWatsonTests extends CredentialsIBMNodeJsActionWatsonTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:12") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs16ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs16ActionWatsonTests extends CredentialsIBMNodeJsActionWatsonTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:16") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs20ActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs20ActionWatsonTests extends CredentialsIBMNodeJsActionWatsonTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:20") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs10ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs10ActionCloudantTests extends CredentialsIBMNodeJsActionCloudantTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:10") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs12ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs12ActionCloudantTests extends CredentialsIBMNodeJsActionCloudantTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:12") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs16ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs16ActionCloudantTests extends CredentialsIBMNodeJsActionCloudantTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:16") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJs20ActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import org.junit.runner.RunWith 19 | import org.scalatest.junit.JUnitRunner 20 | 21 | @RunWith(classOf[JUnitRunner]) 22 | class CredentialsIBMNodeJs20ActionCloudantTests extends CredentialsIBMNodeJsActionCloudantTests { 23 | 24 | override lazy val defaultKind = Some("nodejs:20") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/dat/db2/testdb2read.js: -------------------------------------------------------------------------------- 1 | var ibmdb = require('ibm_db'); 2 | //ibmdb.debug(true); 3 | var connection; 4 | 5 | function main({ 6 | __bx_creds: { 7 | dashDB:{ssldsn} 8 | } 9 | }) { 10 | let result, rows; 11 | 12 | // For the free db2 database plan, the schema name 13 | // needs to be the same as the uid of the ssldsn. 14 | // Therefore we split the ssldsn at the ';' and read the 15 | // individual key value pairs into a map. 16 | // From the map we then can easily access the UID. 17 | var ssldsnMap = {}; 18 | ssldsn.split(';').forEach(function(x){ 19 | var arr = x.split('='); 20 | arr[1] && (ssldsnMap[arr[0]] = arr[1]); 21 | }); 22 | 23 | console.log("UID="+ssldsnMap["UID"]); 24 | 25 | try { 26 | if(!connection){ 27 | connection = ibmdb.openSync(ssldsn); 28 | } 29 | rows = connection.querySync(`SELECT HISP_DESC FROM ${ssldsnMap["UID"]}.HISPANIC_ORIGIN WHERE HISP_CODE='03'`); 30 | return rows[0]; 31 | } catch (err) { 32 | console.error('problems reading from db',err); 33 | return { Error: err }; 34 | } 35 | return result; 36 | }; 37 | -------------------------------------------------------------------------------- /tests/dat/cloudant/testCloudantActionNoCreds.js: -------------------------------------------------------------------------------- 1 | if (process.version.startsWith('v8.')) { 2 | var Cloudant = require("cloudant") 3 | } else if (process.version.startsWith('v16.') || process.version.startsWith('v20.')) { 4 | var { CloudantV1 } = require('@ibm-cloud/cloudant'); 5 | } else { 6 | var Cloudant = require("@cloudant/cloudant") 7 | } 8 | 9 | 10 | function main(args){ 11 | if (process.version.startsWith('v16.') || process.version.startsWith('v20.')) { 12 | try { 13 | var { CloudantV1 } = require('@ibm-cloud/cloudant'); 14 | var version = require('@ibm-cloud/cloudant').version 15 | } catch (er) { 16 | return {err: "url did not match expected"} 17 | } 18 | console.log(version) 19 | return {message: "cloudant url formed successfully"}; 20 | } else { 21 | var cloudant = Cloudant({account: "test", password: "test",plugin:'promises'}) 22 | if(cloudant.config.url == "https://test:test@test.cloudant.com") 23 | return {message: "cloudant url formed successfully"}; 24 | else 25 | return {err: "url did not match expected"} 26 | } 27 | 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /tools/travis/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eux 4 | 5 | # Build script for Travis-CI. 6 | 7 | SCRIPTDIR=$(cd $(dirname "$0") && pwd) 8 | ROOTDIR="$SCRIPTDIR/../.." 9 | WHISKDIR="$ROOTDIR/../openwhisk" 10 | 11 | export OPENWHISK_HOME=$WHISKDIR 12 | 13 | IMAGE_PREFIX=$1 14 | RUNTIME_VERSION=$2 15 | IMAGE_TAG=$3 16 | 17 | if [ ${RUNTIME_VERSION} == "10" ]; then 18 | RUNTIME="nodejs10" 19 | elif [ ${RUNTIME_VERSION} == "12" ]; then 20 | RUNTIME="nodejs12" 21 | elif [ ${RUNTIME_VERSION} == "14" ]; then 22 | RUNTIME="nodejs14" 23 | elif [ ${RUNTIME_VERSION} == "16" ]; then 24 | RUNTIME="nodejs16" 25 | elif [ ${RUNTIME_VERSION} == "20" ]; then 26 | RUNTIME="nodejs20" 27 | fi 28 | 29 | # run login in a subshell with disabled trace to avoid having credentials in the logs 30 | # when trace is on (set -x) 31 | ( 32 | set +x # disable trace in this subshell 33 | # Login to hub.docker.com to get user specific pull rate. 34 | if [ ! -z "${DOCKER_USER}" ] && [ ! -z "${DOCKER_PASSWORD}" ]; then 35 | echo "Run docker login..." 36 | echo ${DOCKER_PASSWORD} | docker login -u "${DOCKER_USER}" --password-stdin 37 | fi 38 | ) 39 | 40 | if [[ ! -z ${RUNTIME} ]]; then 41 | TERM=dumb ./gradlew \ 42 | ${RUNTIME}:pushImage \ 43 | -PdockerRegistry=docker.io \ 44 | -PdockerImagePrefix=${IMAGE_PREFIX} \ 45 | -PdockerImageTag=${IMAGE_TAG} 46 | fi 47 | -------------------------------------------------------------------------------- /tools/travis/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | set -e 20 | 21 | # Build script for Travis-CI. 22 | 23 | SCRIPTDIR=$(cd $(dirname "$0") && pwd) 24 | ROOTDIR="$SCRIPTDIR/../.." 25 | HOMEDIR="$SCRIPTDIR/../../../" 26 | 27 | # OpenWhisk stuff 28 | cd $HOMEDIR 29 | 30 | # Clone and setup openwhisk to have a local test environment. 31 | git clone https://github.com/ibm-functions/openwhisk.git openwhisk 32 | cd openwhisk 33 | 34 | git checkout e0bdc899b8bef4df4756159e0e512ed5528543be 35 | 36 | ./tools/travis/setup.sh 37 | 38 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Example Actions 2 | These are the code examples which as described in the IBM Cloud Functions Docs. 3 | ## Structuring JavaScript code 4 | - [Docs](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_js_struct) 5 | - [Code](examples/structuring_js_code/README.md) 6 | ## Structuring JavaScript code with synchronous behavior 7 | - [Docs](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_js_sync) 8 | - [Code](examples/synchronous/README.md) 9 | ## Structuring JavaScript code with asynchronous behavior 10 | - [Docs](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_js_async) 11 | - [Code](examples/asynchronous/README.md) 12 | ## Structuring JavaScript code with synchronous and asynchronous behavior 13 | - [Docs](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_js_both) 14 | - [Code](examples/sync_and_async/README.md) 15 | ## Example: Calling an external API with JavaScript 16 | - [Docs](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_js_api) 17 | - [Code](examples/apicall/README.md) 18 | ## Packaging JavaScript code with the webpack module 19 | - [Docs](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_js_pkg) 20 | - [Code](examples/packaging_webpack) 21 | ## Packaging JavaScript code as NPM files with native dependencies 22 | - [Docs](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_js_npm) 23 | - [Code](examples/packaging_npm/README.md) -------------------------------------------------------------------------------- /tools/travis/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | # Build script for Travis-CI. 5 | 6 | SCRIPTDIR=$(cd $(dirname "$0") && pwd) 7 | ROOTDIR="$SCRIPTDIR/../.." 8 | WHISKDIR="$ROOTDIR/../openwhisk" 9 | 10 | export OPENWHISK_HOME=$WHISKDIR 11 | 12 | IMAGE_PREFIX="testing" 13 | 14 | # Setup Ansible CMD 15 | cd $WHISKDIR/ansible 16 | ANSIBLE_CMD="ansible-playbook -i ${ROOTDIR}/ansible/environments/local -e docker_image_prefix=${IMAGE_PREFIX}" 17 | 18 | # Weird probem with Travis container names already taken, but we are suppose to get a clean VM 19 | $ANSIBLE_CMD teardown.yml 20 | 21 | # Deploy OpenWhisk 22 | $ANSIBLE_CMD setup.yml 23 | $ANSIBLE_CMD prereq.yml 24 | $ANSIBLE_CMD couchdb.yml 25 | $ANSIBLE_CMD initdb.yml 26 | $ANSIBLE_CMD wipe.yml 27 | $ANSIBLE_CMD openwhisk.yml -e cli_installation_mode=remote 28 | $ANSIBLE_CMD properties.yml 29 | $ANSIBLE_CMD postdeploy.yml 30 | 31 | docker images 32 | docker ps 33 | 34 | #update whisk.properties to add tests/credentials.json file to vcap.services.file, which is needed in tests 35 | VCAP_SERVICES_FILE="$(readlink -f ${ROOTDIR}/tests/credentials.json)" 36 | WHISKPROPS_FILE="$WHISKDIR/whisk.properties" 37 | sed -i 's:^[ \t]*vcap.services.file[ \t]*=\([ \t]*.*\)$:vcap.services.file='$VCAP_SERVICES_FILE':' $WHISKPROPS_FILE 38 | 39 | cat $WHISKPROPS_FILE 40 | 41 | curl -s -k https://172.17.0.1 | jq . 42 | curl -s -k https://172.17.0.1/api/v1 | jq . 43 | 44 | #Deployment 45 | WHISK_APIHOST="172.17.0.1" 46 | WHISK_AUTH=`cat ${WHISKDIR}/ansible/files/auth.guest` 47 | WHISK_CLI="${WHISKDIR}/bin/wsk -i" 48 | 49 | ${WHISK_CLI} property set --apihost ${WHISK_APIHOST} --auth ${WHISK_AUTH} 50 | ${WHISK_CLI} property get 51 | -------------------------------------------------------------------------------- /iam-client/iam-openwhisk-main.js: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more contributor 2 | // license agreements; and to You under the Apache License, Version 2.0. 3 | 4 | const Actions = require('./actions.js') 5 | const Activations = require('./activations.js') 6 | const Namespaces = require('./namespaces.js') 7 | const Packages = require('./packages.js') 8 | const Rules = require('./rules.js') 9 | const Triggers = require('./triggers.js') 10 | const Feeds = require('./feeds.js') 11 | const Routes = require('./routes.js') 12 | const Client = require('./client.js') 13 | const AuthHandler = require('@ibm-functions/iam-token-manager') 14 | const IAM_NAMESPACE_API_KEY = '__OW_IAM_NAMESPACE_API_KEY' 15 | const IAM_NAMESPACE_URL = '__OW_IAM_API_URL' 16 | const NAMESPACE = '__OW_NAMESPACE' 17 | const OpenWhisk = (options) => { 18 | options = options || {} 19 | if (process.env[IAM_NAMESPACE_API_KEY] && !options.api_key) { 20 | if (!options.auth_handler) { 21 | if(!options.iamApikey){ 22 | options.iamApikey = process.env[IAM_NAMESPACE_API_KEY] 23 | } 24 | if(process.env[IAM_NAMESPACE_URL] && !options.iamUrl){ 25 | options.iamUrl = process.env[IAM_NAMESPACE_URL] 26 | } 27 | options.auth_handler = new AuthHandler(options) 28 | } 29 | if (!options.namespace || options.namespace === '_') { 30 | options.namespace = process.env[NAMESPACE] 31 | } 32 | } 33 | const client = new Client(options) 34 | return { 35 | actions: new Actions(client), 36 | activations: new Activations(client), 37 | namespaces: new Namespaces(client), 38 | packages: new Packages(client), 39 | rules: new Rules(client), 40 | triggers: new Triggers(client), 41 | feeds: new Feeds(client), 42 | routes: new Routes(client) 43 | } 44 | } 45 | 46 | module.exports = OpenWhisk 47 | -------------------------------------------------------------------------------- /tools/travis/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | set -ex 20 | 21 | # Build script for Travis-CI. 22 | 23 | SCRIPTDIR=$(cd $(dirname "$0") && pwd) 24 | ROOTDIR="$SCRIPTDIR/../.." 25 | export OPENWHISK_HOME="$ROOTDIR/../openwhisk" 26 | 27 | # run scala tests 28 | cd ${ROOTDIR} 29 | TERM=dumb ./gradlew :tests:checkScalafmtAll 30 | if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_REPO_SLUG" = "ibm-functions/runtime-nodejs" ]; then 31 | TERM=dumb ./gradlew :tests:test 32 | else 33 | TERM=dumb ./gradlew :tests:testWithoutCredentials 34 | fi 35 | 36 | if [[ "$?" != "0" ]]; then 37 | # debugging notes 38 | # || true; set -x; docker ps -a; for i in $(docker ps -a --format="{{.Names}}"); do docker logs $i || true; done; ls -alhR /tmp/wsklogs; 39 | # || true; set -x; docker ps -a; ls -R /tmp/wsklogs ;cat /tmp/wsklogs/invoker0/invoker0_logs.log; cat /tmp/wsklogs/controller0/controller0_logs.log 40 | cat /tmp/wsklogs/invoker0/invoker0_logs.log 41 | cat /tmp/wsklogs/controller0/controller0_logs.log 42 | exit 1 43 | fi 44 | 45 | 46 | -------------------------------------------------------------------------------- /ansible/environments/local/group_vars/all: -------------------------------------------------------------------------------- 1 | whisk_version_name: local 2 | openwhisk_tmp_dir: "{{ lookup('env', 'OPENWHISK_TMP_DIR')|default('/tmp', true) }}" 3 | config_root_dir: "{{ openwhisk_tmp_dir }}/wskconf" 4 | whisk_logs_dir: "{{ openwhisk_tmp_dir }}/wsklogs" 5 | docker_registry: "" 6 | docker_dns: "" 7 | runtimes_bypass_pull_for_local_images: true 8 | invoker_use_runc: "{{ ansible_distribution != 'MacOSX' }}" 9 | 10 | db_prefix: whisk_local_ 11 | 12 | # Auto lookup to find the db credentials 13 | db_provider: "{{ lookup('ini', 'db_provider section=db_creds file={{ playbook_dir }}/db_local.ini') }}" 14 | db_username: "{{ lookup('ini', 'db_username section=db_creds file={{ playbook_dir }}/db_local.ini') }}" 15 | db_password: "{{ lookup('ini', 'db_password section=db_creds file={{ playbook_dir }}/db_local.ini') }}" 16 | db_protocol: "{{ lookup('ini', 'db_protocol section=db_creds file={{ playbook_dir }}/db_local.ini') }}" 17 | db_host: "{{ lookup('ini', 'db_host section=db_creds file={{ playbook_dir }}/db_local.ini') }}" 18 | db_port: "{{ lookup('ini', 'db_port section=db_creds file={{ playbook_dir }}/db_local.ini') }}" 19 | 20 | # API GW connection configuration 21 | apigw_auth_user: "" 22 | apigw_auth_pwd: "" 23 | apigw_host_v2: "http://{{ groups['apigateway']|first }}:{{apigateway.port.api}}/v2" 24 | 25 | invoker_allow_multiple_instances: true 26 | 27 | 28 | env_hosts_dir: "{{ playbook_dir }}/environments/local" 29 | 30 | skip_pull_runtimes: true 31 | runtimes_manifest: 32 | runtimes: 33 | nodejs: 34 | - kind: "nodejs:16" 35 | default: true 36 | image: 37 | name: "action-nodejs-v16" 38 | deprecated: false 39 | - kind: "nodejs:20" 40 | default: false 41 | image: 42 | name: "action-nodejs-v20" 43 | deprecated: false 44 | swift: 45 | - kind: "swift:4.2" 46 | default: true 47 | image: 48 | name: "action-swift-v4.2" 49 | prefix: "openwhisk" 50 | deprecated: false 51 | blackboxes: 52 | - name: "dockerskeleton" 53 | -------------------------------------------------------------------------------- /tools/travis/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | set -ex 20 | 21 | # Build script for Travis-CI. 22 | 23 | SCRIPTDIR=$(cd $(dirname "$0") && pwd) 24 | ROOTDIR="$SCRIPTDIR/../.." 25 | WHISKDIR="$ROOTDIR/../openwhisk" 26 | 27 | export OPENWHISK_HOME=$WHISKDIR 28 | 29 | IMAGE_PREFIX="testing" 30 | 31 | # run login in a subshell with disabled trace to avoid having credentials in the logs 32 | # when trace is on (set -x) 33 | ( 34 | set +x # disable trace in this subshell 35 | # Login to hub.docker.com to get user specific pull rate. 36 | if [ ! -z "${DOCKER_USER}" ] && [ ! -z "${DOCKER_PASSWORD}" ]; then 37 | echo "Run docker login..." 38 | echo ${DOCKER_PASSWORD} | docker login -u "${DOCKER_USER}" --password-stdin 39 | fi 40 | ) 41 | 42 | # Build OpenWhisk 43 | cd $WHISKDIR 44 | 45 | #pull down images 46 | docker pull ibmfunctions/controller:nightly 47 | docker tag ibmfunctions/controller:nightly ${IMAGE_PREFIX}/controller 48 | docker pull ibmfunctions/invoker:nightly 49 | docker tag ibmfunctions/invoker:nightly ${IMAGE_PREFIX}/invoker 50 | 51 | TERM=dumb ./gradlew install 52 | 53 | # Build runtime 54 | cd $ROOTDIR 55 | TERM=dumb ./gradlew distDocker -PdockerImagePrefix=${IMAGE_PREFIX} 56 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJsActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import common.{TestHelpers, WskActorSystem, WskProps, WskTestHelpers} 19 | import common.rest.WskRestOperations 20 | import org.junit.runner.RunWith 21 | import org.scalatest.junit.JUnitRunner 22 | import java.io.File 23 | import spray.json._ 24 | import org.scalatest.BeforeAndAfterAll 25 | 26 | @RunWith(classOf[JUnitRunner]) 27 | class IBMNodeJsActionCloudantTests extends TestHelpers with WskTestHelpers with BeforeAndAfterAll with WskActorSystem { 28 | 29 | implicit val wskprops: WskProps = WskProps() 30 | lazy val defaultKind = "nodejs:14" 31 | val wsk = new WskRestOperations 32 | val datdir = "tests/dat/" 33 | 34 | it should s"""Test whether or not cloudant package is accessible within a $defaultKind action""" in withAssetCleaner( 35 | wskprops) { (wp, assetHelper) => 36 | val file = Some(new File(datdir, "cloudant/testCloudantActionNoCreds.js").toString()) 37 | 38 | assetHelper.withCleaner(wsk.action, "testCloudantActionNoCreds") { (action, _) => 39 | action.create("testCloudantActionNoCreds", file, main = Some("main"), kind = Some(defaultKind)) 40 | } 41 | 42 | withActivation(wsk.activation, wsk.action.invoke("testCloudantActionNoCreds")) { activation => 43 | val response = activation.response 44 | response.result.get.fields.get("error") shouldBe empty 45 | response.result.get.fields.get("message") should be(Some(JsString("cloudant url formed successfully"))) 46 | } 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Test Pull request 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the "master" branch 8 | push: 9 | branches: [ "master" ] 10 | pull_request: 11 | branches: [ "master" ] 12 | schedule: 13 | - cron: "0 8 * * 1" # At 08:00 AM, only on Monday 14 | 15 | workflow_dispatch: 16 | 17 | jobs: 18 | 19 | build: 20 | 21 | runs-on: ubuntu-20.04 22 | 23 | steps: 24 | # Checkout just this repo 25 | - name: Checkout runtime repo 26 | uses: actions/checkout@v3 27 | 28 | # Setup Python to run the Scala Tests 29 | - name: Setup Python 30 | uses: actions/setup-python@v4 31 | with: 32 | python-version: '3.10' 33 | 34 | # Setup Java to run the Scala Tests 35 | - name: Setup Java 36 | uses: actions/setup-java@v3 37 | with: 38 | distribution: 'temurin' 39 | java-version: '11' 40 | 41 | - name: befor install -> install python3-pip 42 | run: sudo apt-get install -y python3-pip 43 | 44 | - name: befor install -> upgrade pip setuptools six 45 | run: | 46 | pip install --user --upgrade pip setuptools six 47 | pip3 install --user --upgrade pip setuptools six 48 | 49 | - name: Python verison 50 | run: | 51 | python --version 52 | python3 --version 53 | python3.10 --version 54 | pip --version 55 | pip3 --version 56 | pip3.10 --version 57 | 58 | - name: Docker Cleanup 59 | run: | 60 | docker image ls 61 | docker image rm $(docker image ls -q) -f 62 | 63 | - name: befor install -> setup.sh 64 | run: | 65 | ./tools/travis/setup.sh 66 | 67 | - name: script -> build 68 | run: | 69 | ./tools/travis/build.sh 70 | 71 | - name: script -> deploy 72 | run: | 73 | pip install --user jinja2==3.0.3 74 | ./tools/travis/deploy.sh 75 | 76 | - name: script-> test 77 | run: | 78 | ./tools/travis/test.sh -------------------------------------------------------------------------------- /nodejs10/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openwhisk/action-nodejs-v10:e46f620 2 | 3 | COPY ./package.json / 4 | 5 | RUN apt-get update \ 6 | # Upgrade installed packages to get latest security fixes if the base image does not contain them already. 7 | && apt-get upgrade -y --no-install-recommends \ 8 | # Cleanup apt data, we do not need them later on. 9 | && rm -rf /var/lib/apt/lists/* \ 10 | # We do not have mysql-server installed but mysql-common contains config files (/etc/mysql/my.cnf) for it. 11 | # We need to add some dummy entries to /etc/mysql/my.cnf to sattisfy vulnerability checking of it. 12 | && echo "\n[mysqld]\nssl-ca=/tmp/ca.pem\nssl-cert=/tmp/server-cert.pem\nssl-key=/tmp/server-key.pem\n" >> /etc/mysql/my.cnf \ 13 | # Start adding/updating npm packages. 14 | && cd / \ 15 | && npm install --production \ 16 | # Check if the base runtime packages required by /nodejsAction/package.json are still available. 17 | # In case this step fails, the package versions required by the /nodejsAction/package.json 18 | # do not match the versions in /package.json. The /package.json versions need to contain the same 19 | # versions as in /nodejsAction/package.json, otherwise the runtime can fail. Adjust the values in 20 | # /packages.json to the values in /nodejsAction/package.json. 21 | # To do the check, we try to install /nodejsAction/package.json with the --dry-run option (only check 22 | # what would happen, no real install). When the install tries to GET (install) packages, we know, 23 | # something is missing and that should not be the case! 24 | && echo "\nCheck if the packages required by the parent image provided '/nodejsAction/package.json' are installed...\n" \ 25 | && npm install ./nodejsAction/ --dry-run -verbose 2>&1 | ( ! grep "npm http fetch GET") \ 26 | && echo "Done, the packages required by '/nodejsAction/package.json' are installed.\n" \ 27 | # Do some cleanup of not used npm install artifacts. 28 | && npm cache clean --force \ 29 | && rm -rf /root/.cache/node-gyp \ 30 | # Replace default openwhisk main with an iam enabled version. 31 | && sed -i.bak 's/lib\/main.js/lib\/iam-openwhisk-main.js/' /node_modules/openwhisk/package.json 32 | 33 | COPY iam-client/iam-openwhisk-main.js /node_modules/openwhisk/lib/ 34 | -------------------------------------------------------------------------------- /nodejs12/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM openwhisk/action-nodejs-v12:8d4dfac 3 | 4 | COPY ./package.json / 5 | 6 | RUN apt-get update \ 7 | # Upgrade installed packages to get latest security fixes if the base image does not contain them already. 8 | && apt-get upgrade -y --no-install-recommends \ 9 | # Cleanup apt data, we do not need them later on. 10 | && rm -rf /var/lib/apt/lists/* \ 11 | # We do not have mysql-server installed but mysql-common contains config files (/etc/mysql/my.cnf) for it. 12 | # We need to add some dummy entries to /etc/mysql/my.cnf to sattisfy vulnerability checking of it. 13 | && echo "\n[mysqld]\nssl-ca=/tmp/ca.pem\nssl-cert=/tmp/server-cert.pem\nssl-key=/tmp/server-key.pem\n" >> /etc/mysql/my.cnf \ 14 | # Start adding/updating npm packages. 15 | && cd / \ 16 | && npm install --production \ 17 | # Check if the base runtime packages required by /nodejsAction/package.json are still available. 18 | # In case this step fails, the package versions required by the /nodejsAction/package.json 19 | # do not match the versions in /package.json. The /package.json versions need to contain the same 20 | # versions as in /nodejsAction/package.json, otherwise the runtime can fail. Adjust the values in 21 | # /packages.json to the values in /nodejsAction/package.json. 22 | # To do the check, we try to install /nodejsAction/package.json with the --dry-run option (only check 23 | # what would happen, no real install). When the install tries to GET (install) packages, we know, 24 | # something is missing and that should not be the case! 25 | && echo "\nCheck if the packages required by the parent image provided '/nodejsAction/package.json' are installed...\n" \ 26 | && npm install ./nodejsAction/ --dry-run -verbose 2>&1 | ( ! grep "npm http fetch GET") \ 27 | && echo "Done, the packages required by '/nodejsAction/package.json' are installed.\n" \ 28 | # Do some cleanup of not used npm install artifacts. 29 | && npm cache clean --force \ 30 | && rm -rf /root/.cache/node-gyp \ 31 | # Replace default openwhisk main with an iam enabled version. 32 | && sed -i.bak 's/lib\/main.js/lib\/iam-openwhisk-main.js/' /node_modules/openwhisk/package.json 33 | 34 | COPY iam-client/iam-openwhisk-main.js /node_modules/openwhisk/lib/ 35 | -------------------------------------------------------------------------------- /nodejs14/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM openwhisk/action-nodejs-v14:8d4dfac 3 | 4 | COPY ./package.json / 5 | 6 | RUN apt-get update \ 7 | # Upgrade installed packages to get latest security fixes if the base image does not contain them already. 8 | && apt-get upgrade -y --no-install-recommends \ 9 | # Cleanup apt data, we do not need them later on. 10 | && rm -rf /var/lib/apt/lists/* \ 11 | # We do not have mysql-server installed but mysql-common contains config files (/etc/mysql/my.cnf) for it. 12 | # We need to add some dummy entries to /etc/mysql/my.cnf to sattisfy vulnerability checking of it. 13 | && echo "\n[mysqld]\nssl-ca=/tmp/ca.pem\nssl-cert=/tmp/server-cert.pem\nssl-key=/tmp/server-key.pem\n" >> /etc/mysql/my.cnf \ 14 | # Start adding/updating npm packages. 15 | && cd / \ 16 | && npm install --production \ 17 | # Check if the base runtime packages required by /nodejsAction/package.json are still available. 18 | # In case this step fails, the package versions required by the /nodejsAction/package.json 19 | # do not match the versions in /package.json. The /package.json versions need to contain the same 20 | # versions as in /nodejsAction/package.json, otherwise the runtime can fail. Adjust the values in 21 | # /packages.json to the values in /nodejsAction/package.json. 22 | # To do the check, we try to install /nodejsAction/package.json with the --dry-run option (only check 23 | # what would happen, no real install). When the install tries to GET (install) packages, we know, 24 | # something is missing and that should not be the case! 25 | && echo "\nCheck if the packages required by the parent image provided '/nodejsAction/package.json' are installed...\n" \ 26 | && npm install ./nodejsAction/ --dry-run -verbose 2>&1 | ( ! grep "npm http fetch GET") \ 27 | && echo "Done, the packages required by '/nodejsAction/package.json' are installed.\n" \ 28 | # Do some cleanup of not used npm install artifacts. 29 | && npm cache clean --force \ 30 | && rm -rf /root/.cache/node-gyp \ 31 | # Replace default openwhisk main with an iam enabled version. 32 | && sed -i.bak 's/lib\/main.js/lib\/iam-openwhisk-main.js/' /node_modules/openwhisk/package.json 33 | 34 | COPY iam-client/iam-openwhisk-main.js /node_modules/openwhisk/lib/ 35 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJsActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import common.{TestHelpers, WskActorSystem, WskProps, WskTestHelpers} 19 | import common.rest.WskRestOperations 20 | import org.junit.runner.RunWith 21 | import org.scalatest.junit.JUnitRunner 22 | import java.io.File 23 | import spray.json._ 24 | import spray.json.DefaultJsonProtocol._ 25 | import org.scalatest.BeforeAndAfterAll 26 | 27 | @RunWith(classOf[JUnitRunner]) 28 | class IBMNodeJsActionWatsonTests extends TestHelpers with WskTestHelpers with BeforeAndAfterAll with WskActorSystem { 29 | 30 | implicit val wskprops: WskProps = WskProps() 31 | lazy val defaultKind = "nodejs:14" 32 | val wsk = new WskRestOperations 33 | val datdir = "tests/dat/" 34 | 35 | it should s"""Test whether or not watson package is useable within a $defaultKind action""" in withAssetCleaner( 36 | wskprops) { (wp, assetHelper) => 37 | /* 38 | Disclaimer : Does not Use / Connect to a watson service! Tests that the 39 | watson-developer-cloud npm package is useable by verifying creating a new 40 | discover object creates the expected object with the expected properties. 41 | */ 42 | 43 | val file = Some(new File(datdir, "watson/testWatsonAction.js").toString()) 44 | 45 | assetHelper.withCleaner(wsk.action, "testWatsonAction") { (action, _) => 46 | action.create( 47 | "testWatsonAction", 48 | file, 49 | main = Some("main"), 50 | kind = Some(defaultKind), 51 | parameters = Map("hostname" -> wskprops.apihost.toJson)) 52 | } 53 | 54 | withActivation(wsk.activation, wsk.action.invoke("testWatsonAction")) { activation => 55 | val response = activation.response 56 | response.result.get.fields.get("error") shouldBe empty 57 | } 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /nodejs8/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ibm-functions-runtime-nodejs-v8", 3 | "version": "1.42.0", 4 | "description": "IBM Functions", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/ibm-functions/runtime-nodejs.git" 8 | }, 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "@cloudant/cloudant": "2.4.1", 12 | "@ibm-functions/iam-token-manager": "1.0.3", 13 | "@sendgrid/mail": "6.3.1", 14 | "amqplib": "0.5.3", 15 | "apn": "2.2.0", 16 | "async": "2.6.2", 17 | "bent": "1.3.0", 18 | "body-parser": "1.18.3", 19 | "btoa": "1.2.1", 20 | "cassandra-driver": "3.6.0", 21 | "cloudant": "1.10.0-NOTICE", 22 | "commander": "2.20.0", 23 | "composeaddresstranslator": "1.0.4", 24 | "consul": "0.34.1", 25 | "cookie-parser": "1.4.4", 26 | "elasticsearch": "15.4.1", 27 | "errorhandler": "1.5.1", 28 | "etcd3": "0.2.11", 29 | "express": "4.16.4", 30 | "express-session": "1.15.6", 31 | "formidable": "1.2.1", 32 | "glob": "7.1.4", 33 | "gm": "1.23.1", 34 | "ibm-cos-sdk": "1.5.0", 35 | "ibm_db": "2.5.2", 36 | "ibmiotf": "0.2.41", 37 | "iconv-lite": "0.4.24", 38 | "jsdom": "13.2.0", 39 | "jsforce": "1.9.1", 40 | "jsonwebtoken": "8.4.0", 41 | "lodash": "4.17.19", 42 | "log4js": "3.0.6", 43 | "marked": "0.6.2", 44 | "merge": "1.2.1", 45 | "moment": "2.24.0", 46 | "mongodb": "3.1.13", 47 | "mustache": "3.0.1", 48 | "mysql": "2.16.0", 49 | "nano": "7.1.1", 50 | "nodemailer": "4.7.0", 51 | "oauth2-server": "3.0.1", 52 | "openwhisk": "3.19.0", 53 | "path-to-regexp": "2.4.0", 54 | "pg": "7.8.0", 55 | "process": "0.11.10", 56 | "pug": "2.0.4", 57 | "redis": "2.8.0", 58 | "request": "2.88.0", 59 | "request-promise": "4.2.4", 60 | "rimraf": "2.6.3", 61 | "semver": "5.6.0", 62 | "serialize-error": "3.0.0", 63 | "serve-favicon": "2.5.0", 64 | "socket.io": "2.2.0", 65 | "socket.io-client": "2.2.0", 66 | "superagent": "4.1.0", 67 | "swagger-tools": "0.10.4", 68 | "tmp": "0.0.33", 69 | "twilio": "3.28.0", 70 | "underscore": "1.9.1", 71 | "url-pattern": "1.0.3", 72 | "uuid": "3.3.2", 73 | "validator": "10.11.0", 74 | "vcap_services": "0.7.0", 75 | "watson-developer-cloud": "3.18.1", 76 | "when": "3.7.8", 77 | "winston": "3.2.1", 78 | "ws": "6.1.4", 79 | "xml2js": "0.4.19", 80 | "xmlhttprequest": "1.8.0", 81 | "yauzl": "2.10.0" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /tests/dat/db2/testdb2action.js: -------------------------------------------------------------------------------- 1 | var ibmdb = require('ibm_db'); 2 | //util.promisify is SPECIFIC to nodejs8 3 | 4 | //ibmdb.debug(true); 5 | 6 | function main(args){ 7 | 8 | if (process.version.startsWith('v16.') || process.version.startsWith('v20.')) { 9 | return ibmdb.open(`DATABASE=TEST;HOSTNAME=${args.hostname};UID=db2inst1;PWD=db2inst1-pwd;PORT=50000;PROTOCOL=TCPIP`).then((conn) => { 10 | connection = conn; 11 | return connection.query("INSERT INTO TESTTABLE (NAME, AGE, LOCATION) VALUES ('Angela', 27, 'Texas')"); 12 | }) 13 | .then(function(data){ 14 | return connection.query("SELECT * FROM TESTTABLE WHERE name='Angela'"); 15 | }) 16 | .then(function(data){ 17 | if(data[0].NAME != "Angela" || data[0].AGE != 27 || data[0].LOCATION != "Texas"){ 18 | throw "Either NAME, AGE, OR LOCATION failed to match expected values"; 19 | } 20 | return connection.query("DELETE FROM TESTTABLE WHERE name='Angela'"); 21 | }) 22 | .then(function(data){ 23 | return connection.close(); 24 | }) 25 | .then(function(){ 26 | return { 27 | message: "Tested db2 create, select, and delete of a table row." 28 | } 29 | }) 30 | .catch(function(err){ 31 | return {error: err} 32 | if(connection){connection.close();} 33 | }); 34 | } else { 35 | const promisify = require('util').promisify; 36 | var p_open = promisify(ibmdb.open); 37 | return p_open(`DATABASE=TEST;HOSTNAME=${args.hostname};UID=db2inst1;PWD=db2inst1-pwd;PORT=50000;PROTOCOL=TCPIP`) 38 | .then((conn) => { 39 | connection = conn; 40 | return connection.query("INSERT INTO TESTTABLE (NAME, AGE, LOCATION) VALUES ('Angela', 27, 'Texas')"); 41 | }) 42 | .then(function(data){ 43 | return connection.query("SELECT * FROM TESTTABLE WHERE name='Angela'"); 44 | }) 45 | .then(function(data){ 46 | if(data[0].NAME != "Angela" || data[0].AGE != 27 || data[0].LOCATION != "Texas"){ 47 | throw "Either NAME, AGE, OR LOCATION failed to match expected values"; 48 | } 49 | return connection.query("DELETE FROM TESTTABLE WHERE name='Angela'"); 50 | }) 51 | .then(function(data){ 52 | return connection.close(); 53 | }) 54 | .then(function(){ 55 | return { 56 | message: "Tested db2 create, select, and delete of a table row." 57 | } 58 | }) 59 | .catch(function(err){ 60 | return {error: err} 61 | if(connection){connection.close();} 62 | }); 63 | } 64 | }; 65 | -------------------------------------------------------------------------------- /tests/dat/watson/testWatsonAction2.js: -------------------------------------------------------------------------------- 1 | // get the runtime version we are running in 2 | const runtime_version=process.version; 3 | 4 | // For the nodejs12 runtime (and later) we use the ibm-watson package. On the earlier 5 | // runtime versions we use the watson-developer-cloud package. 6 | var LanguageTranslatorV3 = runtime_version.startsWith('v10.') ? require("watson-developer-cloud/language-translator/v3") 7 | : require("ibm-watson/language-translator/v3") 8 | 9 | /* 10 | Args in the form of: 11 | args.url; 12 | args.username; 13 | args.password; 14 | */ 15 | function main(args){ 16 | 17 | console.log("LanguageTranslatorV3 Test running on %s",runtime_version); 18 | 19 | // setup options for a language translator service 20 | var options={}; 21 | if (!runtime_version.startsWith('v10.')) { 22 | // the watson sdk 5+ in the nodejs12 runtime (and later) requires authenticators 23 | const { BasicAuthenticator } = require('ibm-watson/auth'); 24 | options= { 25 | authenticator: new BasicAuthenticator({ username: args.username, password: args.password }), 26 | url: args.url, 27 | version: args.version 28 | }; 29 | } else { 30 | // for watson sdk below 5.0 we just pass the arguments 31 | options= args; 32 | } 33 | 34 | // Create a language translator service 35 | var language_translator = new LanguageTranslatorV3(options); 36 | 37 | // setup translation parameters 38 | var params = { 39 | text: 'hello', 40 | source: 'en', 41 | target: 'es' 42 | }; 43 | 44 | // invoke the service to do the tranlation 45 | var promise = {}; 46 | if(runtime_version.startsWith('v8.')){ 47 | // watson sdk 3.x uses callback functions 48 | promise = new Promise(function (resolve, reject) { 49 | language_translator.translate(params, function(err, body){ 50 | if(err){ 51 | reject(err); 52 | } 53 | resolve(body); 54 | }); 55 | }); 56 | } else { 57 | // nodejs 10+ uses the watson sdk 4.x that supports promises 58 | promise = language_translator.translate(params) 59 | } 60 | 61 | // With watson sdk 5+ always the detailed response is returned. 62 | // In order not to make the test case SDK version dependent, we 63 | // return res.result from the detailed response when it is available. 64 | // Otherwise for the earlier versions we return the whole result (res). 65 | return promise 66 | .then((res) => { 67 | return (res.result) ? res.result : res; 68 | }); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /nodejs10/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ibm-functions-runtime-nodejs-v10", 3 | "version": "1.17.0", 4 | "description": "IBM Functions", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/ibm-functions/runtime-nodejs.git" 8 | }, 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "@cloudant/cloudant": "3.0.2", 12 | "@ibm-functions/iam-token-manager": "1.0.5", 13 | "@sendgrid/mail": "6.3.1", 14 | "@wiotp/sdk": "0.6.2", 15 | "amqplib": "0.5.6", 16 | "apn": "2.2.0", 17 | "async": "2.6.2", 18 | "bent": "1.3.0", 19 | "body-parser": "1.18.3", 20 | "btoa": "1.2.1", 21 | "cassandra-driver": "4.0.0", 22 | "commander": "2.19.0", 23 | "composeaddresstranslator": "1.0.4", 24 | "consul": "0.34.1", 25 | "cookie-parser": "1.4.5", 26 | "elasticsearch": "15.4.1", 27 | "errorhandler": "1.5.1", 28 | "etcd3": "0.2.13", 29 | "express": "4.16.4", 30 | "express-session": "1.15.6", 31 | "formidable": "1.2.2", 32 | "glob": "7.1.6", 33 | "gm": "1.23.1", 34 | "ibm-cos-sdk": "1.10.0", 35 | "ibm_db": "2.7.3", 36 | "ibmiotf": "0.2.41", 37 | "ibm-watson": "4.2.1", 38 | "iconv-lite": "0.4.24", 39 | "jsdom": "13.2.0", 40 | "jsforce": "1.9.3", 41 | "jsonwebtoken": "8.5.1", 42 | "lodash": "4.17.19", 43 | "log4js": "4.0.2", 44 | "marked": "0.8.0", 45 | "merge": "1.2.1", 46 | "moment": "2.24.0", 47 | "mongodb": "3.3.4", 48 | "mustache": "3.0.1", 49 | "mysql": "2.16.0", 50 | "nano": "8.0.0", 51 | "nodemailer": "5.1.1", 52 | "oauth2-server": "3.0.2", 53 | "openwhisk": "3.21.3", 54 | "path-to-regexp": "3.0.0", 55 | "pg": "7.11.0", 56 | "process": "0.11.10", 57 | "pug": "2.0.4", 58 | "redis": "2.8.0", 59 | "request": "2.88.0", 60 | "request-promise": "4.2.5", 61 | "rimraf": "2.6.3", 62 | "semver": "5.6.0", 63 | "serialize-error": "3.0.0", 64 | "serve-favicon": "2.5.0", 65 | "socket.io": "2.4.1", 66 | "socket.io-client": "2.4.0", 67 | "superagent": "4.1.0", 68 | "swagger-tools": "0.10.4", 69 | "tmp": "0.0.33", 70 | "twilio": "3.28.0", 71 | "underscore": "1.9.1", 72 | "url-pattern": "1.0.3", 73 | "uuid": "3.3.0", 74 | "validator": "10.11.0", 75 | "vcap_services": "0.7.1", 76 | "watson-developer-cloud": "4.0.0-rc2", 77 | "when": "3.7.8", 78 | "winston": "3.2.1", 79 | "ws": "6.1.4", 80 | "xlsx": "0.14.3", 81 | "xml2js": "0.4.23", 82 | "xmlhttprequest": "1.8.0", 83 | "yauzl": "2.10.0", 84 | "yazl": "2.5.1" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /nodejs20/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ibm-functions-runtime-nodejs-v20", 3 | "version": "1.0.0", 4 | "description": "IBM Functions", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/ibm-functions/runtime-nodejs.git" 8 | }, 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "@ibm-cloud/cloudant": "0.5.5", 12 | "@ibm-functions/iam-token-manager": "1.0.11", 13 | "@sendgrid/mail": "7.7.0", 14 | "@wiotp/sdk": "0.7.8", 15 | "amqplib": "0.10.3", 16 | "apn": "2.2.0", 17 | "async": "3.2.4", 18 | "axios": "1.6.1", 19 | "bent": "7.3.12", 20 | "body-parser": "1.20.2", 21 | "btoa": "1.2.1", 22 | "bufferutil": "4.0.7", 23 | "canvas": "2.11.2", 24 | "cassandra-driver": "4.6.4", 25 | "commander": "11.0.0", 26 | "composeaddresstranslator": "1.0.4", 27 | "consul": "1.2.0", 28 | "cookie-parser": "1.4.6", 29 | "core-js": "3.21.1", 30 | "@elastic/elasticsearch": "8.8.1", 31 | "errorhandler": "1.5.1", 32 | "etcd3": "1.1.0", 33 | "express": "4.17.3", 34 | "express-session": "1.17.3", 35 | "formidable": "3.5.0", 36 | "glob": "10.3.3", 37 | "gm": "1.25.0", 38 | "got": "13.0.0", 39 | "ibm-cos-sdk": "1.13.1", 40 | "ibm_db": "3.2.1", 41 | "ibm-watson": "8.0.0", 42 | "iconv-lite": "0.6.3", 43 | "jest": "29.6.1", 44 | "jsdom": "22.1.0", 45 | "jsforce": "1.11.1", 46 | "jsonwebtoken": "9.0.1", 47 | "lodash": "4.17.21", 48 | "log4js": "6.9.1", 49 | "marked": "5.1.1", 50 | "merge": "2.1.1", 51 | "moment": "2.29.4", 52 | "mongodb": "5.7.0", 53 | "mustache": "4.2.0", 54 | "mysql": "2.18.1", 55 | "nano": "10.1.2", 56 | "needle": "3.2.0", 57 | "nodemailer": "6.9.4", 58 | "oauth2-server": "3.1.1", 59 | "openwhisk": "3.21.8", 60 | "path-to-regexp": "6.2.1", 61 | "pg": "8.11.1", 62 | "process": "0.11.10", 63 | "pug": "3.0.2", 64 | "redis": "4.0.4", 65 | "rimraf": "5.0.1", 66 | "semver": "7.5.4", 67 | "serialize-error": "9.1.0", 68 | "serve-favicon": "2.5.0", 69 | "socket.io": "4.7.1", 70 | "socket.io-client": "4.7.1", 71 | "superagent": "8.0.9", 72 | "swagger-tools": "0.10.4", 73 | "tmp": "0.2.1", 74 | "ts-jest": "29.1.1", 75 | "twilio": "4.13.0", 76 | "underscore": "1.13.6", 77 | "url-pattern": "1.0.3", 78 | "utf-8-validate": "6.0.3", 79 | "uuid": "8.3.2", 80 | "validator": "13.9.0", 81 | "vcap_services": "0.7.1", 82 | "when": "3.7.8", 83 | "winston": "3.10.0", 84 | "ws": "8.13.0", 85 | "xlsx": "0.18.5", 86 | "xml2js": "0.6.0", 87 | "xmlhttprequest": "1.8.0", 88 | "yauzl": "2.10.0", 89 | "yazl": "2.5.1" 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJsDb2CloudTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import common._ 19 | import common.rest.WskRestOperations 20 | import org.junit.runner.RunWith 21 | import org.scalatest.junit.JUnitRunner 22 | import java.io.File 23 | import spray.json._ 24 | import scala.io.Source 25 | import org.scalatest.BeforeAndAfterAll 26 | 27 | @RunWith(classOf[JUnitRunner]) 28 | class CredentialsIBMNodeJsDb2CloudTests 29 | extends TestHelpers 30 | with WskTestHelpers 31 | with BeforeAndAfterAll 32 | with WskActorSystem { 33 | 34 | implicit val wskprops: WskProps = WskProps() 35 | lazy val defaultKind = Some("nodejs:14") 36 | val wsk = new WskRestOperations 37 | val datdir = "tests/dat/" 38 | 39 | // read credentials from from vcap_services.json 40 | val vcapFile = WhiskProperties.getProperty("vcap.services.file") 41 | val vcapString = Source.fromFile(vcapFile).getLines.mkString 42 | val vcapInfo = 43 | JsonParser(ParserInput(vcapString)).asJsObject.fields("dashDB").asInstanceOf[JsArray].elements(0) 44 | val creds = vcapInfo.asJsObject.fields("credentials").asJsObject 45 | 46 | val ssldsn = creds.fields("ssldsn") 47 | val __bx_creds = JsObject("dashDB" -> JsObject("ssldsn" -> ssldsn)) 48 | 49 | it should "Test connection to DB2 on IBM Cloud" in withAssetCleaner(wskprops) { (wp, assetHelper) => 50 | val file = Some(new File(datdir, "db2/testdb2read.js").toString()) 51 | 52 | assetHelper.withCleaner(wsk.action, "testDB2Cloud") { (action, _) => 53 | action.create( 54 | "testDB2Cloud", 55 | file, 56 | main = Some("main"), 57 | kind = defaultKind, 58 | parameters = Map("__bx_creds" -> __bx_creds)) 59 | } 60 | 61 | withActivation(wsk.activation, wsk.action.invoke("testDB2Cloud")) { activation => 62 | val response = activation.response 63 | response.result.get.fields.get("error") shouldBe empty 64 | response.result.get.fields.get("HISP_DESC") should be(Some(JsString("Puerto Rican"))) 65 | } 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /nodejs16/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ibm-functions-runtime-nodejs-v16", 3 | "version": "1.0.4", 4 | "description": "IBM Functions", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/ibm-functions/runtime-nodejs.git" 8 | }, 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "@ibm-cloud/cloudant": "0.1.1", 12 | "@ibm-functions/iam-token-manager": "1.0.11", 13 | "@sendgrid/mail": "7.6.2", 14 | "@wiotp/sdk": "0.7.8", 15 | "amqplib": "0.8.0", 16 | "apn": "2.2.0", 17 | "async": "3.2.3", 18 | "axios": "0.26.1", 19 | "bent": "7.3.12", 20 | "body-parser": "1.19.2", 21 | "btoa": "1.2.1", 22 | "bufferutil": "4.0.6", 23 | "canvas": "2.9.1", 24 | "cassandra-driver": "4.6.3", 25 | "commander": "9.1.0", 26 | "composeaddresstranslator": "1.0.4", 27 | "consul": "0.40.0", 28 | "cookie-parser": "1.4.6", 29 | "core-js": "3.21.1", 30 | "elasticsearch": "16.7.3", 31 | "errorhandler": "1.5.1", 32 | "etcd3": "1.1.0", 33 | "express": "4.17.3", 34 | "express-session": "1.17.2", 35 | "formidable": "2.0.1", 36 | "glob": "7.2.0", 37 | "gm": "1.23.1", 38 | "got": "12.0.3", 39 | "ibm-cos-sdk": "1.11.0", 40 | "ibm_db": "2.8.1", 41 | "ibm-watson": "7.0.0", 42 | "iconv-lite": "0.6.3", 43 | "jest": "27.5.1", 44 | "jsdom": "19.0.0", 45 | "jsforce": "1.11.0", 46 | "jsonwebtoken": "8.5.1", 47 | "lodash": "4.17.21", 48 | "log4js": "6.4.4", 49 | "marked": "4.0.12", 50 | "merge": "2.1.1", 51 | "moment": "2.29.1", 52 | "mongodb": "4.4.1", 53 | "mustache": "4.2.0", 54 | "mysql": "2.18.1", 55 | "nano": "10.0.0", 56 | "needle": "3.0.0", 57 | "nodemailer": "6.7.3", 58 | "oauth2-server": "3.1.1", 59 | "openwhisk": "3.21.7", 60 | "path-to-regexp": "6.2.0", 61 | "pg": "8.7.3", 62 | "process": "0.11.10", 63 | "pug": "3.0.2", 64 | "redis": "4.0.4", 65 | "request-promise": "4.2.6", 66 | "rimraf": "3.0.2", 67 | "semver": "7.3.5", 68 | "serialize-error": "9.1.0", 69 | "serve-favicon": "2.5.0", 70 | "socket.io": "4.4.1", 71 | "socket.io-client": "4.4.1", 72 | "superagent": "7.1.2", 73 | "swagger-tools": "0.10.4", 74 | "tmp": "0.2.1", 75 | "ts-jest": "27.1.4", 76 | "twilio": "3.76.0", 77 | "underscore": "1.13.2", 78 | "url-pattern": "1.0.3", 79 | "utf-8-validate": "5.0.9", 80 | "uuid": "8.3.2", 81 | "validator": "13.7.0", 82 | "vcap_services": "0.7.1", 83 | "when": "3.7.8", 84 | "winston": "3.6.0", 85 | "ws": "8.5.0", 86 | "xlsx": "0.18.5", 87 | "xml2js": "0.4.23", 88 | "xmlhttprequest": "1.8.0", 89 | "yauzl": "2.10.0", 90 | "yazl": "2.5.1" 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /nodejs12/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ibm-functions-runtime-nodejs-v12", 3 | "version": "1.1.0", 4 | "description": "IBM Functions", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/ibm-functions/runtime-nodejs.git" 8 | }, 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "@cloudant/cloudant": "4.3.1", 12 | "@ibm-functions/iam-token-manager": "1.0.5", 13 | "@sendgrid/mail": "7.2.0", 14 | "@wiotp/sdk": "0.7.7", 15 | "amqplib": "0.5.6", 16 | "apn": "2.2.0", 17 | "async": "3.2.0", 18 | "axios": "0.19.2", 19 | "bent": "7.3.5", 20 | "body-parser": "1.18.3", 21 | "btoa": "1.2.1", 22 | "bufferutil": "4.0.1", 23 | "canvas": "2.6.1", 24 | "cassandra-driver": "4.5.2", 25 | "commander": "5.1.0", 26 | "composeaddresstranslator": "1.0.4", 27 | "consul": "0.37.0", 28 | "cookie-parser": "1.4.5", 29 | "core-js": "3.6.5", 30 | "elasticsearch": "16.7.1", 31 | "errorhandler": "1.5.1", 32 | "etcd3": "0.2.13", 33 | "express": "4.16.4", 34 | "express-session": "1.17.1", 35 | "formidable": "1.2.2", 36 | "glob": "7.1.6", 37 | "gm": "1.23.1", 38 | "got": "11.5.1", 39 | "ibm-cos-sdk": "1.10.0", 40 | "ibm_db": "2.7.3", 41 | "ibm-watson": "6.0.4", 42 | "iconv-lite": "0.4.23", 43 | "jest": "26.0.1", 44 | "jsdom": "16.2.2", 45 | "jsforce": "2.0.0-alpha.12", 46 | "jsonwebtoken": "8.5.1", 47 | "lodash": "4.17.19", 48 | "log4js": "6.3.0", 49 | "marked": "1.1.0", 50 | "merge": "1.2.1", 51 | "moment": "2.27.0", 52 | "mongodb": "3.5.9", 53 | "mustache": "4.0.1", 54 | "mysql": "2.18.1", 55 | "nano": "8.2.2", 56 | "needle": "2.5.0", 57 | "nodemailer": "6.4.10", 58 | "oauth2-server": "3.0.2", 59 | "openwhisk": "3.21.4", 60 | "path-to-regexp": "6.1.0", 61 | "pg": "8.2.1", 62 | "process": "0.11.10", 63 | "pug": "3.0.2", 64 | "redis": "2.8.0", 65 | "request-promise": "4.2.5", 66 | "rimraf": "3.0.2", 67 | "semver": "7.3.2", 68 | "serialize-error": "3.0.0", 69 | "serve-favicon": "2.5.0", 70 | "socket.io": "2.4.1", 71 | "socket.io-client": "2.4.0", 72 | "superagent": "5.2.2", 73 | "swagger-tools": "0.10.4", 74 | "tmp": "0.2.1", 75 | "ts-jest": "26.1.0", 76 | "twilio": "3.46.0", 77 | "underscore": "1.10.2", 78 | "url-pattern": "1.0.3", 79 | "utf-8-validate": "5.0.2", 80 | "uuid": "3.3.0", 81 | "validator": "13.1.1", 82 | "vcap_services": "0.7.1", 83 | "when": "3.7.8", 84 | "winston": "3.2.1", 85 | "ws": "7.3.0", 86 | "xlsx": "0.16.2", 87 | "xml2js": "0.4.23", 88 | "xmlhttprequest": "1.8.0", 89 | "yauzl": "2.10.0", 90 | "yazl": "2.5.1" 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /nodejs16/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM openwhisk/action-nodejs-v16:28ac4c0 3 | 4 | COPY ./package.json / 5 | 6 | #ENV NODE_ENV=production 7 | ARG NODE_ENV=production 8 | 9 | RUN apt-get update \ 10 | # Upgrade installed packages to get latest security fixes if the base image does not contain them already. 11 | && apt-get upgrade -y --no-install-recommends \ 12 | # Cleanup apt data, we do not need them later on. 13 | && rm -rf /var/lib/apt/lists/* \ 14 | # We do not have mysql-server installed but mysql-common contains config files (/etc/mysql/my.cnf) for it. 15 | # We need to add some dummy entries to /etc/mysql/my.cnf to sattisfy vulnerability checking of it. 16 | && echo "\n[mysqld]\nssl-ca=/tmp/ca.pem\nssl-cert=/tmp/server-cert.pem\nssl-key=/tmp/server-key.pem\n" >> /etc/mysql/my.cnf \ 17 | # Start adding/updating npm packages. 18 | && cd / \ 19 | && npm install --omit=dev \ 20 | # Check if the base runtime packages required by /nodejsAction/package.json are still available. 21 | # In case this step fails, the package versions required by the /nodejsAction/package.json 22 | # do not match the versions in /package.json. The /package.json versions need to contain the same 23 | # versions as in /nodejsAction/package.json, otherwise the runtime can fail. Adjust the values in 24 | # /packages.json to the values in /nodejsAction/package.json. 25 | # To do the check, we try to install /nodejsAction/package.json with the --dry-run option (only check 26 | # what would happen, no real install). When the install tries to GET (install) packages, we know, 27 | # something is missing and that should not be the case! 28 | && sed -i 's/devDependencies/ignoredDevDependencies/' /nodejsAction/package.json \ 29 | && echo "\nCheck if the packages required by the parent image provided '/nodejsAction/package.json' are installed...\n" \ 30 | && npm install ./nodejsAction/ --dry-run -verbose 2>&1 | ( ! grep "npm http fetch GET") \ 31 | && echo "Done, the packages required by '/nodejsAction/package.json' are installed.\n" \ 32 | # Do some cleanup of not used npm install artifacts. 33 | && npm cache clean --force \ 34 | && rm -rf /root/.cache/node-gyp \ 35 | # Replace default openwhisk main with an iam enabled version. 36 | && sed -i.bak 's/lib\/main.js/lib\/iam-openwhisk-main.js/' /node_modules/openwhisk/package.json \ 37 | # Show current nodejs version. 38 | && echo "node version: $(node --version)" \ 39 | # Show current npm version. 40 | && echo "npm version: $(npm --version)" \ 41 | # Show full list of installed modules. 42 | && echo "npm list:" && echo "$(cd / && npm list)" 43 | 44 | ENV OW_ENABLE_INIT_INSTALL=false 45 | 46 | COPY iam-client/iam-openwhisk-main.js /node_modules/openwhisk/lib/ 47 | -------------------------------------------------------------------------------- /nodejs20/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM openwhisk/action-nodejs-v20:110a0f4 3 | 4 | COPY ./package.json / 5 | 6 | #ENV NODE_ENV=production 7 | ARG NODE_ENV=production 8 | 9 | RUN apt-get update \ 10 | # Upgrade installed packages to get latest security fixes if the base image does not contain them already. 11 | && apt-get upgrade -y --no-install-recommends \ 12 | # Cleanup apt data, we do not need them later on. 13 | && rm -rf /var/lib/apt/lists/* \ 14 | # We do not have mysql-server installed but mysql-common contains config files (/etc/mysql/my.cnf) for it. 15 | # We need to add some dummy entries to /etc/mysql/my.cnf to sattisfy vulnerability checking of it. 16 | && echo "\n[mysqld]\nssl-ca=/tmp/ca.pem\nssl-cert=/tmp/server-cert.pem\nssl-key=/tmp/server-key.pem\n" >> /etc/mysql/my.cnf \ 17 | # Start adding/updating npm packages. 18 | && cd / \ 19 | && npm install --omit=dev \ 20 | # Check if the base runtime packages required by /nodejsAction/package.json are still available. 21 | # In case this step fails, the package versions required by the /nodejsAction/package.json 22 | # do not match the versions in /package.json. The /package.json versions need to contain the same 23 | # versions as in /nodejsAction/package.json, otherwise the runtime can fail. Adjust the values in 24 | # /packages.json to the values in /nodejsAction/package.json. 25 | # To do the check, we try to install /nodejsAction/package.json with the --dry-run option (only check 26 | # what would happen, no real install). When the install tries to GET (install) packages, we know, 27 | # something is missing and that should not be the case! 28 | && sed -i 's/devDependencies/ignoredDevDependencies/' /nodejsAction/package.json \ 29 | && echo "\nCheck if the packages required by the parent image provided '/nodejsAction/package.json' are installed...\n" \ 30 | && npm install ./nodejsAction/ --dry-run -verbose 2>&1 | ( ! grep "npm http fetch GET") \ 31 | && echo "Done, the packages required by '/nodejsAction/package.json' are installed.\n" \ 32 | # Do some cleanup of not used npm install artifacts. 33 | && npm cache clean --force \ 34 | && rm -rf /root/.cache/node-gyp \ 35 | # Replace default openwhisk main with an iam enabled version. 36 | && sed -i.bak 's/lib\/main.js/lib\/iam-openwhisk-main.js/' /node_modules/openwhisk/package.json \ 37 | # Show current nodejs version. 38 | && echo "node version: $(node --version)" \ 39 | # Show current npm version. 40 | && echo "npm version: $(npm --version)" \ 41 | # Show full list of installed modules. 42 | && echo "npm list:" && echo "$(cd / && npm list)" 43 | 44 | ENV OW_ENABLE_INIT_INSTALL=false 45 | 46 | COPY iam-client/iam-openwhisk-main.js /node_modules/openwhisk/lib/ 47 | -------------------------------------------------------------------------------- /nodejs14/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ibm-functions-runtime-nodejs-v14", 3 | "version": "1.0.0", 4 | "description": "IBM Functions", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/ibm-functions/runtime-nodejs.git" 8 | }, 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "@cloudant/cloudant": "4.3.1", 12 | "@ibm-functions/iam-token-manager": "1.0.5", 13 | "@sendgrid/mail": "7.4.6", 14 | "@wiotp/sdk": "0.7.8", 15 | "amqplib": "0.8.0", 16 | "apn": "2.2.0", 17 | "async": "3.2.0", 18 | "axios": "0.21.1", 19 | "bent": "7.3.5", 20 | "body-parser": "1.18.3", 21 | "btoa": "1.2.1", 22 | "bufferutil": "4.0.1", 23 | "canvas": "2.6.1", 24 | "cassandra-driver": "4.5.2", 25 | "commander": "5.1.0", 26 | "composeaddresstranslator": "1.0.4", 27 | "consul": "0.37.0", 28 | "cookie-parser": "1.4.5", 29 | "core-js": "3.16.4", 30 | "elasticsearch": "16.7.1", 31 | "errorhandler": "1.5.1", 32 | "etcd3": "0.2.13", 33 | "express": "4.16.4", 34 | "express-session": "1.17.1", 35 | "formidable": "1.2.2", 36 | "glob": "7.1.6", 37 | "gm": "1.23.1", 38 | "got": "11.5.1", 39 | "ibm-cos-sdk": "1.10.2", 40 | "ibm_db": "2.7.3", 41 | "@ibm-cloud/cloudant": "0.0.18", 42 | "ibm-watson": "6.0.4", 43 | "iconv-lite": "0.4.23", 44 | "jest": "27.1.0", 45 | "jsdom": "16.2.2", 46 | "jsforce": "2.0.0-alpha.12", 47 | "jsonwebtoken": "8.5.1", 48 | "lodash": "4.17.19", 49 | "log4js": "6.3.0", 50 | "marked": "1.1.0", 51 | "merge": "1.2.1", 52 | "moment": "2.27.0", 53 | "mongodb": "3.5.9", 54 | "mustache": "4.0.1", 55 | "mysql": "2.18.1", 56 | "nano": "8.2.2", 57 | "needle": "2.5.0", 58 | "nodemailer": "6.4.10", 59 | "oauth2-server": "3.0.2", 60 | "openwhisk": "3.21.4", 61 | "path-to-regexp": "6.1.0", 62 | "pg": "8.2.1", 63 | "process": "0.11.10", 64 | "pug": "3.0.2", 65 | "redis": "2.8.0", 66 | "rimraf": "3.0.2", 67 | "semver": "7.3.2", 68 | "serialize-error": "3.0.0", 69 | "serve-favicon": "2.5.0", 70 | "socket.io": "2.4.1", 71 | "socket.io-client": "2.4.0", 72 | "superagent": "5.2.2", 73 | "swagger-tools": "0.10.4", 74 | "tmp": "0.2.1", 75 | "ts-jest": "27.0.5", 76 | "twilio": "3.67.1", 77 | "typescript": "4.4.2", 78 | "underscore": "1.10.2", 79 | "url-pattern": "1.0.3", 80 | "utf-8-validate": "5.0.2", 81 | "uuid": "3.3.0", 82 | "validator": "13.1.1", 83 | "vcap_services": "0.7.1", 84 | "when": "3.7.8", 85 | "winston": "3.2.1", 86 | "ws": "7.3.0", 87 | "xlsx": "0.16.2", 88 | "xml2js": "0.4.23", 89 | "xmlhttprequest": "1.8.0", 90 | "yauzl": "2.10.0", 91 | "yazl": "2.5.1" 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJsActionCloudantTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import common.{TestHelpers, WhiskProperties, WskActorSystem, WskProps, WskTestHelpers} 19 | import common.rest.WskRestOperations 20 | import org.junit.runner.RunWith 21 | import org.scalatest.junit.JUnitRunner 22 | import java.io.File 23 | import spray.json._ 24 | import scala.io.Source 25 | 26 | @RunWith(classOf[JUnitRunner]) 27 | class CredentialsIBMNodeJsActionCloudantTests extends TestHelpers with WskTestHelpers with WskActorSystem { 28 | 29 | implicit val wskprops: WskProps = WskProps() 30 | lazy val defaultKind = Some("nodejs:20") 31 | val wsk = new WskRestOperations 32 | val datdir = "tests/dat/" 33 | 34 | // read credentials from from vcap_services.json 35 | val vcapFile = WhiskProperties.getProperty("vcap.services.file") 36 | val vcapString = Source.fromFile(vcapFile).getLines.mkString 37 | val vcapInfo = 38 | JsonParser(ParserInput(vcapString)).asJsObject.fields("cloudantNoSQLDB").asInstanceOf[JsArray].elements(0) 39 | val creds = vcapInfo.asJsObject.fields("credentials").asJsObject 40 | val username = creds.fields("username").asInstanceOf[JsString] 41 | val password = creds.fields("password").asInstanceOf[JsString] 42 | val url = creds.fields("url").asInstanceOf[JsString] 43 | 44 | it should "Test whether or not cloudant database is reachable using cloudant npm module" in withAssetCleaner(wskprops) { 45 | (wp, assetHelper) => 46 | val file = Some(new File(datdir, "cloudant/testCloudantAction.js").toString()) 47 | 48 | assetHelper.withCleaner(wsk.action, "testCloudantAction") { (action, _) => 49 | action.create( 50 | "testCloudantAction", 51 | file, 52 | main = Some("main"), 53 | kind = defaultKind, 54 | parameters = Map("username" -> username, "password" -> password, "url" -> url)) 55 | } 56 | 57 | withActivation(wsk.activation, wsk.action.invoke("testCloudantAction")) { activation => 58 | val response = activation.response 59 | response.result.get.fields.get("error") shouldBe empty 60 | response.result.get.fields.get("lastname") should be(Some(JsString("Queue"))) 61 | } 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJsCOSTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import common._ 19 | import common.rest.WskRestOperations 20 | import org.junit.runner.RunWith 21 | import org.scalatest.junit.JUnitRunner 22 | import java.io.File 23 | import spray.json._ 24 | import scala.io.Source 25 | import org.scalatest.BeforeAndAfterAll 26 | 27 | @RunWith(classOf[JUnitRunner]) 28 | class CredentialsIBMNodeJsCOSTests extends TestHelpers with WskTestHelpers with BeforeAndAfterAll with WskActorSystem { 29 | 30 | implicit val wskprops: WskProps = WskProps() 31 | lazy val defaultKind = Some("nodejs:14") 32 | val wsk = new WskRestOperations 33 | val datdir = "tests/dat/" 34 | 35 | // read credentials from from vcap_services.json 36 | val vcapFile = WhiskProperties.getProperty("vcap.services.file") 37 | val vcapString = Source.fromFile(vcapFile).getLines.mkString 38 | val vcapInfo = 39 | JsonParser(ParserInput(vcapString)).asJsObject.fields("cloud-object-storage").asInstanceOf[JsArray].elements(0) 40 | val creds = vcapInfo.asJsObject.fields("credentials").asJsObject 41 | 42 | val apikey = creds.fields("apikey").asInstanceOf[JsString] 43 | 44 | var resource_instance_id = creds.fields("resource_instance_id").asInstanceOf[JsString] 45 | 46 | val __bx_creds = JsObject( 47 | "cloud-object-storage" -> JsObject("apikey" -> apikey, "resource_instance_id" -> resource_instance_id)) 48 | 49 | it should "Test connection to Cloud Object Storage COS on IBM Cloud" in withAssetCleaner(wskprops) { 50 | (wp, assetHelper) => 51 | val file = Some(new File(datdir, "cos/testcosread.js").toString()) 52 | assetHelper.withCleaner(wsk.action, "testCOS") { (action, _) => 53 | action.create( 54 | "testCOS", 55 | file, 56 | main = Some("main"), 57 | kind = defaultKind, 58 | parameters = Map("__bx_creds" -> __bx_creds)) 59 | } 60 | withActivation(wsk.activation, wsk.action.invoke("testCOS")) { activation => 61 | val response = activation.response 62 | response.result.get.fields.get("error") shouldBe empty 63 | response.result.get.fields.get("data") should be( 64 | Some(JsString("This is a test file for IBM-Functions integration testing."))) 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/integration/CredentialsIBMNodeJsActionWatsonTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.integration 17 | 18 | import common.{TestHelpers, WhiskProperties, WskActorSystem, WskProps, WskTestHelpers} 19 | import common.rest.WskRestOperations 20 | import org.junit.runner.RunWith 21 | import org.scalatest.junit.JUnitRunner 22 | import java.io.File 23 | import spray.json._ 24 | import scala.io.Source 25 | import org.scalatest.BeforeAndAfterAll 26 | 27 | @RunWith(classOf[JUnitRunner]) 28 | class CredentialsIBMNodeJsActionWatsonTests 29 | extends TestHelpers 30 | with WskTestHelpers 31 | with BeforeAndAfterAll 32 | with WskActorSystem { 33 | 34 | implicit val wskprops: WskProps = WskProps() 35 | lazy val defaultKind = Some("nodejs:14") 36 | val wsk = new WskRestOperations 37 | val datdir = "tests/dat/" 38 | 39 | // read credentials from from vcap_services.json 40 | val vcapFile = WhiskProperties.getProperty("vcap.services.file") 41 | val vcapString = Source.fromFile(vcapFile).getLines.mkString 42 | val vcapInfo = 43 | JsonParser(ParserInput(vcapString)).asJsObject.fields("language_translator").asInstanceOf[JsArray].elements(0) 44 | val creds = vcapInfo.asJsObject.fields("credentials").asJsObject 45 | val url = creds.fields("url").asInstanceOf[JsString] 46 | val apikey = creds.fields("apikey").asInstanceOf[JsString] 47 | 48 | /* 49 | Uses Watson Translation Service to translate the word "Hello" in English, to "Hola" in Spanish. 50 | */ 51 | it should "Test whether watson translate service is reachable" in withAssetCleaner(wskprops) { (wp, assetHelper) => 52 | val file = Some(new File(datdir, "watson/testWatsonAction2.js").toString()) 53 | assetHelper.withCleaner(wsk.action, "testWatsonAction2") { (action, _) => 54 | action.create( 55 | "testWatsonAction2", 56 | file, 57 | main = Some("main"), 58 | kind = defaultKind, 59 | parameters = Map( 60 | "version" -> JsString("2018-05-01"), 61 | "url" -> url, 62 | "username" -> JsString("APIKey"), 63 | "password" -> apikey)) 64 | } 65 | 66 | withActivation(wsk.activation, wsk.action.invoke("testWatsonAction2")) { activation => 67 | val response = activation.response 68 | response.result.get.fields.get("error") shouldBe empty 69 | response.result.get.fields.get("translations") should be( 70 | Some(JsArray(JsObject("translation" -> JsString("hola"))))) 71 | } 72 | 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /tests/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'scala' 2 | apply plugin: 'eclipse' 3 | compileTestScala.options.encoding = 'UTF-8' 4 | 5 | repositories { 6 | mavenCentral() 7 | mavenLocal() 8 | } 9 | 10 | tasks.withType(Test) { 11 | systemProperties = System.getProperties() // Forward defined properties to the test JVM 12 | testLogging { 13 | events "passed", "skipped", "failed" 14 | showStandardStreams = true 15 | exceptionFormat = 'full' 16 | } 17 | outputs.upToDateWhen { false } // force tests to run every time 18 | 19 | // Exclude the nodejs:10 specific tests as this runtime is not supported anymore. 20 | exclude '**/*NodeJs10*' 21 | 22 | // Exclude the nodejs:12 specific tests as this runtime is not supported anymore. 23 | exclude '**/*NodeJs12*' 24 | 25 | // Exclude the nodejs:14 specific tests as this runtime is not supported anymore. 26 | exclude '**/*IBMNodeJsActionContainerTests*' 27 | exclude '**/*IBMNodeJsActionDB2Tests*' 28 | exclude '**/*IBMNodeJsActionCloudant*' 29 | exclude '**/*IBMNodeJsActionWatson*' 30 | exclude '**/*IBMNodeJsCOS*' 31 | exclude '**/*IBMNodeJsDb2Cloud*' 32 | exclude '**/*NodeJsSDK*' 33 | 34 | } 35 | 36 | task testWithoutCredentials(type: Test) { 37 | exclude '**/*Credentials*' 38 | } 39 | 40 | task testBlueCI(type: Test) { 41 | exclude '**/IBMNodeJsActionDB2Tests*' 42 | } 43 | 44 | task testBlueDeployment(type: Test) { 45 | include 'runtime/integration/**' 46 | include 'runtime/sdk/**' 47 | 48 | // To exlude tests from the BlueDeployment, place them here. See sample to exclude all NodeJs12 tests, below. 49 | // exclude '**/*NodeJs12*' 50 | 51 | // Exclude the nodejs:14 specific tests as this runtime is not available, yet. 52 | exclude '**/*IBMNodeJsActionCloudant*' 53 | exclude '**/*IBMNodeJsActionWatson*' 54 | exclude '**/*IBMNodeJsCOS*' 55 | exclude '**/*IBMNodeJsDb2Cloud*' 56 | exclude '**/*NodeJsSDK*' 57 | } 58 | 59 | dependencies { 60 | compile "org.scala-lang:scala-library:${gradle.scala.version}" 61 | compile "org.apache.openwhisk:openwhisk-tests:${gradle.openwhisk.version}:tests" 62 | compile "org.apache.openwhisk:openwhisk-tests:${gradle.openwhisk.version}:test-sources" 63 | implementation group: 'com.typesafe.akka', name: "akka-http2-support_${gradle.scala.depVersion}", version: "${gradle.akka_http.version}" 64 | implementation group: 'com.typesafe.akka', name: "akka-http-xml_${gradle.scala.depVersion}", version: "${gradle.akka_http.version}" 65 | implementation group: 'com.typesafe.akka', name: "akka-discovery_${gradle.scala.depVersion}", version: "${gradle.akka.version}" 66 | implementation group: 'com.typesafe.akka', name: "akka-protobuf_${gradle.scala.depVersion}", version: "${gradle.akka.version}" 67 | implementation group: 'com.typesafe.akka', name: "akka-remote_${gradle.scala.depVersion}", version: "${gradle.akka.version}" 68 | implementation group: 'com.typesafe.akka', name: "akka-cluster_${gradle.scala.depVersion}", version: "${gradle.akka.version}" 69 | } 70 | 71 | tasks.withType(ScalaCompile) { 72 | scalaCompileOptions.additionalParameters = gradle.scala.compileFlags 73 | } 74 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | os: linux 3 | dist: bionic 4 | 5 | services: 6 | - docker 7 | 8 | env: 9 | global: 10 | - secure: lQT7+rxOmzmbsvaNfcp1CzriB9i5DXcbN3kdEY5sLJpDG9wYJjTImzLK2tUpzV2M7Se8cXyrSc0oGr3HwfR7UR/4QZE8IjiZUrE4tFWjuRWehUPZ4Lx7o9QpesUfERohADnh1mxCsQ79wnvv+BZMwa7XrAhRYvqsx+mz/mz54Qfs99wGtc8tIlJBX2UI9+wIik03U4EyqG9QHcvHJtaBopeczv+tQ5pNSdM55LTbl3TUc1s0Q5Lmf0GUmQyPrRAVfZMx0rQVnAANScxByTBbiLrMvJrZkj5WOjfFn/9uCSt5Fg0iTdKX77CdXEInRfCQ34gcLvvbTBxlsm9kPbEpTkBdlWCC6M4HF6vVjqyrc6BIF/NQmh/c8yr1KC+46W2Tz2dKoz53bli+lU5SVPsgqjpQtzel4oUDLqaBRfRuQzruL5hzr6HQVuJo2zYrAC84aA+/4ezk3cGNbkFYxq71wrWf3HrCxUAlSwfTzZpwQKulVIL4ofgJxphC7/6Akmqze80D3ux3xqiB0CiCOArc40hWq/EdHCn86hDLfIZOjj8lLO26cVNZU3sbl1TMEMLKBidULodNnlppLvO0D2qXrPm2wEuKaGZz9qLcg4utSixPWKGNHjsN/0N0uOVNevtJC6x1AgfzWP4z+NVEA+/Dyo7esFr1XSnIFzks5pr2d3s= 11 | - secure: YnI0FRmhb4hvMECtezKWbjxHcEGWSMouvJwF9q4qzVAG0Oe1IuCRZE3qBYGW/NsW05I8GhaQeZwmfdqk+WeUzIaA/WT2TLqUzKv9FY44yPFCNYST6ahzJPM8Nc+z6S2SP9yMZfq4WB0pQQCIFB7lXlzkUYD+93m9d9GxlYo+tHXIO4GNA8Brf7RhPc4IgrHZaNREkNs64L77z9bD6wiAe4IHUgpiz9HtNV5i4n4kNUQUGAyXZQdtVwhxwQ1GwAK7GVdLxC+ViL6a8UKFkfF/uC/6szYvdm39CVvZTiUwX+SP1MjIue2ISEgtJyBpZX2tXLE7d45Snrr2kupBvgZsikGpRjFQDe3q7wuyxHhHfxg1R6UKWSi7G2VnAyk+UQZAR5ZH6nrPq4NxJL8DXKIY457ZzKRuvnZWZKcjM9AO3gLoX3ycIzAase7G45FxMrCd/I87eRX4+krNitOgrgeqgIcVF60Ku2QAzYxvN0F7TQZArTWUiYIy+O46SBXRNsakoYPbKOaypmuKYgjAf88CUtdxyLTMQX0u7vEctZ4AciKrDdjrhu9JXqq39J5fHmmcRNLXI9pYapd8c0aY3i35AUDWd08vMACtNaOb/tdrCVZvNHe2u49wDdW7w6GkSQ8F15vG8odCcY0NyeODZXGnFKVi0ykVEB26J2ENJ30zd18= 12 | 13 | notifications: 14 | email: false 15 | webhooks: 16 | urls: 17 | # travis2slack webhook to enable DMs on openwhisk-team.slack.com to PR authors with TravisCI results 18 | secure: kLdOkrKzqb3ihx6PTWV/CLunhdIVdayNEYIiFSh6X8fDLSuLyjJnYWYrb71c8qdYwDwrgOzulEDMouWjwg2sFBzsNJXLxGjYaMTXJtCtgWegFDK90VkrGNDoRzm4Emh+Ou8+8nM72k4Mnb02RFXkJACVPwrcYEHFtlXvm+ZEb9+bvUwu1UbrFWhFqCpjYzpyLrJaZRhhU3N3EJoGOLkOnNQRtC9x2hY2bkoFDSqCqji75tB/MvdEL70mT5fYgZ/iLIoJ9FjoPHzRZ4b4sP6isfrHk/SI9FAiqXO4p6Kg70RWPLAipN/MZrWz5qepSzdn2Njk3LxDH+XxsDaU0jKbK0c9F0g75CkKNLwHpHNxGDNEkWf7ELSJ2H2ekgIoq5OHEvyPBV+u8iJXVt3AS7jEcVIsL+CEnbbUF0mb4sC8auyUS4FQIHzgUxHQt3pzQffDBTqP9lhmWy9ceeHc6SlAdehzo8RQ5NkFUfSGWhlzCCP5xRuEY+BIaoeeTZNny1pPmeLd69pnYjIBnODtPDy4n3kFCZaS5rSHHcDZHY7hq+RLbhrAnoVtiw7sy1bAKNn+iJvnFTveKeBD/aD/nadBlSg+4mBXxvc0ggldt8niOH0oq1c42/s7XIsD9RY7WkJw4VCyMunGa0dhbtnyy4Te2uN3oXvGY+ObDhMwLA2ftsc= 19 | 20 | before_install: 21 | # Refresh built in certificates. 22 | - sudo update-ca-certificates --fresh 23 | # Decrypt only when building in original repository (not on forks). 24 | - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_REPO_SLUG" = "ibm-functions/runtime-nodejs" ]; then openssl aes-256-cbc -K "$encrypted_94FB9778302A_key" -iv "$encrypted_94FB9778302A_iv" -in tests/credentials.json.enc -out tests/credentials.json -d; fi' 25 | # Do the setup. 26 | - "./tools/travis/setup.sh" 27 | 28 | install: true 29 | script: 30 | - "./tools/travis/build.sh && ./tools/travis/deploy.sh && ./tools/travis/test.sh" 31 | deploy: 32 | - provider: script 33 | script: "./tools/travis/publish.sh ibmfunctions ${TRAVIS_TAG%@*} ${TRAVIS_TAG##*@}" 34 | on: 35 | tags: true 36 | all_branches: true 37 | repo: ibm-functions/runtime-nodejs 38 | - provider: script 39 | script: "./tools/travis/publish.sh ibmfunctions 10 master && ./tools/travis/publish.sh ibmfunctions 12 master && ./tools/travis/publish.sh ibmfunctions 14 master && ./tools/travis/publish.sh ibmfunctions 16 master" 40 | on: 41 | branch: master 42 | repo: ibm-functions/runtime-nodejs 43 | 44 | -------------------------------------------------------------------------------- /gradle/README.md: -------------------------------------------------------------------------------- 1 | # Gradle 2 | 3 | Gradle is used to build OpenWhisk. It does not need to be pre-installed as it installs itself using the [Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html). To use it without installing, simply invoke the `gradlew` command at the root of the repository. You can also install `gradle` via [`apt`](http://linuxg.net/how-to-install-gradle-2-1-on-ubuntu-14-10-ubuntu-14-04-ubuntu-12-04-and-derivatives/) on Ubuntu or [`brew`](http://www.brewformulas.org/Gradle) on Mac. In the following we use `gradle` and `gradlew` as synonymous. 4 | 5 | ## Usage 6 | 7 | In general, project level properties are set via `-P{propertyName}={propertyValue}`. A task is called via `gradle {taskName}` and a subproject task is called via `gradle :path:to:subproject:{taskName}`. To run tasks in parallel, use the `--parallel` flag (**Note:** It's an incubating feature and might break stuff). 8 | 9 | ### Build 10 | 11 | To build all Docker images use `gradle distDocker` at the top level project, to build a specific component use `gradle :core:controller:distDocker`. 12 | 13 | Project level options that can be used on `distDocker`: 14 | 15 | - `dockerImageName` (*required*): The name of the image to build (e.g. whisk/controller) 16 | - `dockerHost` (*optional*): The docker host to run commands on, default behaviour is docker's own `DOCKER_HOST` environment variable 17 | - `dockerRegistry` (*optional*): The registry to push to 18 | - `dockerImageTag` (*optional*, default 'latest'): The tag for the image 19 | - `dockerTimeout` (*optional*, default 240): Timeout for docker operations in seconds 20 | - `dockerRetries` (*optional*, default 3): How many times to retry docker operations 21 | - `dockerBinary` (*optional*, default `docker`): The binary to execute docker commands 22 | 23 | ### Test 24 | 25 | To run tests one uses the `test` task. OpenWhisk consolidates tests into a single `tests` project. Hence the command to run all tests is `gradle :tests:test`. 26 | 27 | It is possible to run specific tests using [Gradle testfilters](https://docs.gradle.org/current/userguide/java_plugin.html#test_filtering). For example `gradle :tests:test --tests "your.package.name.TestClass.evenMethodName"`. Wildcard `*` may be used anywhere. 28 | 29 | ## Build your own `build.gradle` 30 | In Gradle, most of the tasks we use are default tasks provided by plugins in Gradle. The [`scala` Plugin](https://docs.gradle.org/current/userguide/scala_plugin.html) for example includes tasks, that are needed to build Scala projects. Moreover, Gradle is aware of *Applications*. The [`application` Plugin](https://docs.gradle.org/current/userguide/application_plugin.html) provides tasks that are required to distribute a self-contained application. When `application` and `scala` are used in conjunction, they hook into each other and provide the tasks needed to distribute a Scala application. `distTar` for example compiles the Scala code, creates a jar containing the compiled classes and resources and creates a Tarball including that jar and all of its dependencies (defined in the dependencies section of `build.gradle`). It also creates a start-script which correctly sets the classpath for all those dependencies and starts the app. 31 | 32 | In OpenWhisk, we want to distribute our application via Docker images. Hence we wrote a "plugin" that creates the task `distDocker`. That task will build an image from the `Dockerfile` that is located next to the `build.gradle` it is called from, for example Controller's `Dockerfile` and `build.gradle` are both located at `core/controller`. 33 | 34 | If you want to create a new `build.gradle` for your component, simply put the `Dockerfile` right next to it and include `docker.gradle` by using 35 | 36 | ``` 37 | ext.dockerImageName = 'openwwhisk/{IMAGENAME}' 38 | apply from: 'path/to/docker.gradle' 39 | ``` 40 | 41 | If your component needs to be build before you can build the image, make `distDocker` depend on any task needed to run before it, for example: 42 | 43 | ``` 44 | distDocker.dependsOn ':common:scala:distDocker', 'distTar' 45 | ``` 46 | -------------------------------------------------------------------------------- /gradle/docker.gradle: -------------------------------------------------------------------------------- 1 | import groovy.time.* 2 | 3 | /** 4 | * Utility to build docker images based in gradle projects 5 | * 6 | * This extends gradle's 'application' plugin logic with a 'distDocker' task which builds 7 | * a docker image from the Dockerfile of the project that applies this file. The image 8 | * is automatically tagged and pushed if a tag and/or a registry is given. 9 | * 10 | * Parameters that can be set on project level: 11 | * - dockerImageName (required): The name of the image to build (e.g. controller) 12 | * - dockerRegistry (optional): The registry to push to 13 | * - dockerImageTag (optional, default 'latest'): The tag for the image 14 | * - dockerImagePrefix (optional, default 'whisk'): The prefix for the image, 15 | * 'controller' becomes 'whisk/controller' per default 16 | * - dockerTimeout (optional, default 840): Timeout for docker operations in seconds 17 | * - dockerRetries (optional, default 3): How many times to retry docker operations 18 | * - dockerBinary (optional, default 'docker'): The binary to execute docker commands 19 | * - dockerBuildArgs (options, default ''): Project specific custom docker build arguments 20 | * - dockerHost (optional): The docker host to run commands on, default behaviour is 21 | * docker's own DOCKER_HOST environment variable 22 | */ 23 | 24 | ext { 25 | dockerRegistry = project.hasProperty('dockerRegistry') ? dockerRegistry + '/' : '' 26 | dockerImageTag = project.hasProperty('dockerImageTag') ? dockerImageTag : 'latest' 27 | dockerImagePrefix = project.hasProperty('dockerImagePrefix') ? dockerImagePrefix : 'whisk' 28 | dockerTimeout = project.hasProperty('dockerTimeout') ? dockerTimeout.toInteger() : 840 29 | dockerRetries = project.hasProperty('dockerRetries') ? dockerRetries.toInteger() : 3 30 | dockerBinary = project.hasProperty('dockerBinary') ? [dockerBinary] : ['docker'] 31 | dockerBuildArg = ['build'] 32 | } 33 | ext.dockerTaggedImageName = dockerRegistry + dockerImagePrefix + '/' + dockerImageName + ':' + dockerImageTag 34 | 35 | if(project.hasProperty('dockerHost')) { 36 | dockerBinary += ['--host', project.dockerHost] 37 | } 38 | 39 | if(project.hasProperty('dockerBuildArgs')) { 40 | dockerBuildArgs.each { arg -> 41 | dockerBuildArg += ['--build-arg', arg] 42 | } 43 | } 44 | 45 | task distDocker { 46 | doLast { 47 | def start = new Date() 48 | def cmd = dockerBinary + dockerBuildArg + ['-t', dockerImageName, project.buildscript.sourceFile.getParentFile().getAbsolutePath()] 49 | retry(cmd, dockerRetries, dockerTimeout) 50 | println("Building '${dockerImageName}' took ${TimeCategory.minus(new Date(), start)}") 51 | } 52 | } 53 | task tagImage { 54 | doLast { 55 | def versionString = (dockerBinary + ['-v']).execute().text 56 | def matched = (versionString =~ /(\d+)\.(\d+)\.(\d+)/) 57 | 58 | def major = matched[0][1] as int 59 | def minor = matched[0][2] as int 60 | 61 | def dockerCmd = ['tag'] 62 | if(major == 1 && minor < 12) { 63 | dockerCmd += ['-f'] 64 | } 65 | retry(dockerBinary + dockerCmd + [dockerImageName, dockerTaggedImageName], dockerRetries, dockerTimeout) 66 | } 67 | } 68 | 69 | task pushImage { 70 | doLast { 71 | def cmd = dockerBinary + ['push', dockerTaggedImageName] 72 | retry(cmd, dockerRetries, dockerTimeout) 73 | } 74 | } 75 | pushImage.dependsOn tagImage 76 | pushImage.onlyIf { dockerRegistry != '' } 77 | distDocker.finalizedBy pushImage 78 | 79 | def retry(cmd, retries, timeout) { 80 | println("${new Date()}: Executing '${cmd.join(" ")}'") 81 | def proc = cmd.execute() 82 | proc.consumeProcessOutput(System.out, System.err) 83 | proc.waitForOrKill(timeout * 1000) 84 | if(proc.exitValue() != 0) { 85 | def message = "${new Date()}: Command '${cmd.join(" ")}' failed with exitCode ${proc.exitValue()}" 86 | if(proc.exitValue() == 143) { // 143 means the process was killed (SIGTERM signal) 87 | message = "${new Date()}: Command '${cmd.join(" ")}' was killed after ${timeout} seconds" 88 | } 89 | 90 | if(retries > 1) { 91 | println("${message}, ${retries-1} retries left, retrying...") 92 | retry(cmd, retries-1, timeout) 93 | } 94 | else { 95 | println("${message}, no more retries left, aborting...") 96 | throw new GradleException(message) 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/actionContainers/IBMNodeJsActionDB2Tests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package runtime.actionContainers 17 | 18 | import common.{TestHelpers, TestUtils, WskActorSystem, WskProps, WskTestHelpers} 19 | import common.rest.WskRestOperations 20 | import org.junit.runner.RunWith 21 | import org.scalatest.junit.JUnitRunner 22 | import java.io.File 23 | import spray.json._ 24 | import spray.json.DefaultJsonProtocol._ 25 | import org.scalatest.BeforeAndAfterAll 26 | 27 | @RunWith(classOf[JUnitRunner]) 28 | class IBMNodeJsActionDB2Tests extends TestHelpers with WskTestHelpers with BeforeAndAfterAll with WskActorSystem { 29 | 30 | implicit val wskprops: WskProps = WskProps() 31 | lazy val defaultKind = "nodejs:14" 32 | val wsk = new WskRestOperations 33 | val db2dir = "tests/dat/db2/" 34 | val db2containerName = "db2test" 35 | 36 | it should s"""Test creation, get, and delete of a $defaultKind action""" in withAssetCleaner(wskprops) { 37 | (wp, assetHelper) => 38 | val file = Some(new File(db2dir, "testdb2action.js").toString()) 39 | 40 | assetHelper.withCleaner(wsk.action, "testdb2action") { (action, _) => 41 | action.create( 42 | "testdb2action", 43 | file, 44 | main = Some("main"), 45 | kind = Some(defaultKind), 46 | parameters = Map("hostname" -> wskprops.apihost.toJson)) 47 | } 48 | 49 | withActivation(wsk.activation, wsk.action.invoke("testdb2action")) { activation => 50 | val response = activation.response 51 | response.result.get.fields.get("error") shouldBe empty 52 | response.result.get.fields.get("message") should be( 53 | Some(JsString("Tested db2 create, select, and delete of a table row."))) 54 | } 55 | 56 | } 57 | 58 | /* 59 | Need to wait till the db2 start command has completed. 60 | The following executes a `db2 list active databases` commands and if the start 61 | command wasn't completed, it will return an exitCode 4. 62 | Other exit codes are acceptable, for example 2 means that there was no active databases 63 | exitCode 4 = SQL1032N No start database manager command was issued. 64 | exitCode 2 = SQL1611W No data was returned by Database System Monitor. 65 | exitCode 8 = SQL10007N Message "-1390" could not be retrieved. Reason code: "3". 66 | exitCode 126 = stat /database/config/db2inst1/sqllib/bin/db2: no such file or directory. 67 | exitCode 127 = /database/config/db2inst1/sqllib/bin/db2: No such file or directory. 68 | */ 69 | def sleepUntilContainerRunning() { 70 | var counter = 48; // 48*10s=480s -> 8 minutes 71 | var running = false; 72 | do { 73 | counter = counter - 1 74 | val isdb2Running = TestUtils 75 | .runCmd( 76 | TestUtils.DONTCARE_EXIT, 77 | new File("."), 78 | "docker", 79 | "exec", 80 | "-t", 81 | "--user", 82 | "db2inst1", 83 | db2containerName, 84 | "bash", 85 | "-c", 86 | ". /database/config/db2inst1/.bashrc && db2 list active databases") 87 | 88 | if ((isdb2Running.exitCode != 0) && (isdb2Running.exitCode != 2)) { 89 | Thread.sleep(10000) 90 | println("Wait some more time...") 91 | } else { 92 | running = true; 93 | println("Database seems to be up, now.") 94 | } 95 | } while (counter > 0 && running == false); 96 | } 97 | 98 | override def beforeAll() { 99 | //setup db2 docker container 100 | 101 | TestUtils.runCmd(TestUtils.DONTCARE_EXIT, new File("."), "docker", "kill", db2containerName) 102 | TestUtils.runCmd(TestUtils.DONTCARE_EXIT, new File("."), "docker", "rm", db2containerName) 103 | println("Creating local db2 instance, might take up to 5 minutes...") 104 | TestUtils.runCmd( 105 | 0, 106 | new File("."), 107 | "docker", 108 | "run", 109 | "-d", 110 | "--cap-add", 111 | "IPC_LOCK", 112 | "--cap-add", 113 | "IPC_OWNER", 114 | "-p", 115 | "50000:50000", 116 | "-e", 117 | "DB2INSTANCE=db2inst1", 118 | "-e", 119 | "DB2INST1_PASSWORD=db2inst1-pwd", 120 | "-e", 121 | "LICENSE=accept", 122 | "--name", 123 | db2containerName, 124 | "ibmcom/db2:11.5.5.1") 125 | 126 | sleepUntilContainerRunning() 127 | 128 | //place setup sql script on docker container; then run it to initialize the initial database and tables 129 | TestUtils.runCmd( 130 | 0, 131 | new File("."), 132 | "docker", 133 | "cp", 134 | db2dir + "setup.sql", 135 | db2containerName + ":/database/config/db2inst1/setup.sql") 136 | println("Creating db2 database, might take up to 5 minutes.") 137 | TestUtils.runCmd( 138 | 0, 139 | new File("."), 140 | "docker", 141 | "exec", 142 | "-t", 143 | "--user", 144 | "db2inst1", 145 | db2containerName, 146 | "bash", 147 | "-c", 148 | ". /database/config/db2inst1/.bashrc && db2 -tvf /database/config/db2inst1/setup.sql") 149 | } 150 | 151 | override def afterAll() { 152 | TestUtils.runCmd(TestUtils.DONTCARE_EXIT, new File("."), "docker", "kill", db2containerName) 153 | TestUtils.runCmd(TestUtils.DONTCARE_EXIT, new File("."), "docker", "rm", db2containerName) 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This repository is no longer maintained. 2 | IBM Cloud Functions reached end of life and this repository is no longer active. 3 | 4 | For Apache OpenWhisk visit: [https://github.com/apache/openwhisk](https://github.com/apache/openwhisk). 5 | 6 | ---- 7 | 8 | # IBM Cloud Functions runtime for nodejs 9 | 10 | [![Build Status](https://travis-ci.org/ibm-functions/runtime-nodejs.svg?branch=master)](https://travis-ci.com/ibm-functions/runtime-nodejs) 11 | 12 | - The runtime provides [nodejs v16](nodejs16/) with a set of [npm packages](nodejs16/package.json) see [nodejs16/CHANGELOG.md](nodejs16/CHANGELOG.md) 13 | - The runtime provides [nodejs v20](nodejs20/) with a set of [npm packages](nodejs20/package.json) see [nodejs20/CHANGELOG.md](nodejs20/CHANGELOG.md) 14 | 15 | 16 | The runtime provides the following npm packages for [IBM Cloud](https://bluemix.net): 17 | - IBM DB2/DashDB and IBM Informix [ibm_db](https://www.npmjs.com/package/ibm_db) 18 | - IBM Cloudant [@cloudant/cloudant](https://www.npmjs.com/package/@cloudant/cloudant) 19 | - IBM Watson Cloud [watson-developer-cloud](https://www.npmjs.com/package/watson-developer-cloud) 20 | - IBM Cloud Object Storage [ibm-cos-sdk](https://www.npmjs.com/package/ibm-cos-sdk) 21 | 22 | 23 | ### How to use as a docker Action 24 | To use as a docker action 25 | ``` 26 | ibmcloud wsk action update myAction myAction.js --docker ibmfunctions/action-nodejs-ibm-v16 27 | ``` 28 | This works on any deployment of Apache OpenWhisk or IBM Cloud Functions 29 | 30 | ### Future: IBM Cloud Functions (based on Apache OpenWhisk) 31 | To use as a nodejs kind action 32 | ``` 33 | ibmcloud wsk action update myAction myAction --kind nodejs:16 34 | ``` 35 | Tip: Not available yet in the IBM Cloud 36 | 37 | ### Working with the local git repo 38 | Prerequisite: *Export* OPENWHISK_HOME to point to your incubator/openwhisk cloned directory. 39 | 40 | To build the `nodejs:16` runtime: 41 | ``` 42 | ./gradlew nodejs16:distDocker 43 | ``` 44 | This will produce the image `whisk/action-nodejs-ibm-v16` 45 | 46 | 47 | Build and Push image 48 | ``` 49 | docker login 50 | ./gradlew nodejs16:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io 51 | ``` 52 | 53 | Deploy OpenWhisk using ansible environment that adds the new king `nodejs:16` 54 | Assuming you have OpenWhisk already deploy localy and `OPENWHISK_HOME` pointing to root directory of OpenWhisk core repository. 55 | 56 | Set `ROOTDIR` to the root directory of this repository. 57 | 58 | Redeploy OpenWhisk 59 | ``` 60 | cd $OPENWHISK_HOME/ansible 61 | ANSIBLE_CMD="ansible-playbook -i ${ROOTDIR}/ansible/environments/local" 62 | $ANSIBLE_CMD setup.yml 63 | $ANSIBLE_CMD couchdb.yml 64 | $ANSIBLE_CMD initdb.yml 65 | $ANSIBLE_CMD wipe.yml 66 | $ANSIBLE_CMD openwhisk.yml 67 | ``` 68 | 69 | To use as docker action push to your own dockerhub account 70 | ``` 71 | docker tag whisk/action-nodejs-ibm-v16 $user_prefix/action-nodejs-ibm-v16 72 | docker push $user_prefix/action-nodejs-ibm-v16 73 | ``` 74 | Then create the action using your the image from dockerhub 75 | ``` 76 | wsk action update myAction myAction.js --docker $user_prefix/action-nodejs-ibm-v16 77 | ``` 78 | The `$user_prefix` is usually your dockerhub user id. 79 | 80 | ### Testing 81 | Install dependencies from the root directory on $OPENWHISK_HOME repository 82 | ``` 83 | ./gradlew install 84 | ``` 85 | 86 | #### Using IntelliJ: 87 | - Import project as gradle project. 88 | - Make sure working directory is root of the project/repo 89 | 90 | #### Using Gradle 91 | 92 | To run all tests: `./gradlew tests:test` this include tests depending on credentials 93 | 94 | To run all tests except those which do not rely on credentials `./gradlew tests:testWithoutCredentials` 95 | 96 | To run a single test-class: `./gradlew tests:test --tests ` 97 | 98 | For example, in order to execute the tests in /tests/src/test/scala/actionContainers/IBMNodeJSActionDB2Tests.scala, run: `./gradlew tests:test --tests *IBMNodeJsActionDB2Tests` 99 | 100 | Note: If you're running all tests locally with credentials like `./gradlew tests:test` or `./gradlew tests:test --tests *CredentialsIBMNodeJsActionWatsonTests` 101 | you need to set up a tests/credentials.json file containing Watson credentials in the format of: 102 | ``` 103 | { 104 | "language_translation":[ 105 | { 106 | "credentials": { 107 | "url": "", 108 | "apikey": "" 109 | } 110 | } 111 | ], 112 | "cloudantNoSQLDB":[ 113 | { 114 | "credentials": { 115 | "url": "", 116 | "host": "", 117 | "port": "" , 118 | "password": "", 119 | "username": "" 120 | } 121 | } 122 | ], 123 | "dashDB":[ 124 | { 125 | "credentials": { 126 | "ssldsn": "DATABASE=BLUDB;HOSTNAME=;PORT=50001;PROTOCOL=TCPIP;UID=;PWD=;Security=SSL;" 127 | } 128 | } 129 | ], 130 | "cloud-object-storage":[ 131 | { 132 | "credentials": { 133 | "resource_instance_id": "", 134 | "apikey": "" 135 | } 136 | } 137 | ], 138 | 139 | } 140 | ``` 141 | Then update the `whisk.properties` file located in the directory `$OPENWHISK_HOME`, using the variable `vcap.services.file` 142 | 143 | ## Maintenance Tasks 144 | 145 | ### Updating Node.js 16 runtime 146 | - Get the version of the latest tag ibm image 147 | ``` 148 | VERSION=$(git tag | grep 16@ | tail -2 | head -1 | awk -F"@" '{print $2 }') 149 | ``` 150 | - Check the version of nodejs on the latest ibm image released 151 | ``` 152 | docker run --rm -it ibmfunctions/action-nodejs-v16:$VERSION sh -c "node -v" 153 | ``` 154 | - Check if there is a new version of the [Node.js LTS 16](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V16.md). 155 | ``` 156 | nvm ls-remote | grep v16. 157 | ``` 158 | - If there is a new version update the [OpenWhisk Node.js 16 Dockerfile](https://github.com/apache/openwhisk-runtime-nodejs/blob/master/core/nodejs16Action/Dockerfile#L18) and submit PR. 159 | - After PR is merged wait for Travis CI to build and push a new tag image for [openwhisk/action-nodejs-v16](https://hub.docker.com/r/openwhisk/action-nodejs-v16/tags) 160 | - Update the ibm image [nodejs16/Dockerfile](nodejs16/Dockerfile) FROM usign the new upstream tag 161 | - Check if there are new npm packages available 162 | - Use the latest released image to check the outdated npm packages 163 | ``` 164 | docker run --rm -it ibmfunctions/action-nodejs-v16:$VERSION sh -c "cd / && npm outdated" 165 | ``` 166 | - Update [nodejs16/package.json](nodejs16/package.json) 167 | - Update [nodejs16/CHANGELOG.md](nodejs16/CHANGELOG.md) 168 | 169 | ### Pushing new versions for runtimes 170 | - After the PR is merged and the master pass Travis CI, checkout master. 171 | - Create tag for each runtime and push upstream 172 | ``` 173 | git tag 16@ 174 | git push upstream 16@ 175 | ``` 176 | - After the image is deployed to production update the `latest` tag for each runtime. 177 | ``` 178 | git tag 16@latest -f 179 | git push upstream 16@latest -f 180 | ``` 181 | 182 | 183 | # License 184 | [Apache 2.0](LICENSE.txt) 185 | -------------------------------------------------------------------------------- /tests/dat/cloudant/testCloudantAction.js: -------------------------------------------------------------------------------- 1 | // get the actual node version 2 | var nodeRuntime="unsupported"; 3 | switch (true) { 4 | case process.version.startsWith("v10."): nodeRuntime = "nodejs10"; break; 5 | case process.version.startsWith("v12."): nodeRuntime = "nodejs12"; break; 6 | case process.version.startsWith("v16."): nodeRuntime = "nodejs16"; break; 7 | case process.version.startsWith("v20."): nodeRuntime = "nodejs20"; break; 8 | } 9 | 10 | // load the cloudant package 11 | if (process.version.startsWith('v16.') || process.version.startsWith('v20.')) { 12 | console.log("------------------------- require @ibm-cloud/cloudant ----------------------"); 13 | var { CloudantV1 } = require('@ibm-cloud/cloudant'); 14 | } else { 15 | var Cloudant = require("@cloudant/cloudant") 16 | } 17 | 18 | // delete database 19 | async function deleteDatabase(client,databaseName) { 20 | try { 21 | console.log("Deleting possible existing database: "+databaseName); 22 | const response= await client.deleteDatabase({db: databaseName}); 23 | console.log("Returned from deleteDatabase response: %j",response); 24 | } catch (err) { 25 | if (err.status = 404) { 26 | // Database not found, we tolerate this for the delete. 27 | console.log("Database not found, ignored during deleteDatabase."); 28 | } else { 29 | // Other errors, progagte this to caller. 30 | throw new Error('Delete database failed!', { cause: err }); 31 | }; 32 | } 33 | return true; 34 | } 35 | 36 | // create database 37 | async function createDatabase(client,databaseName) { 38 | try { 39 | console.log("Creating database: "+databaseName); 40 | const response= await client.putDatabase({ db: databaseName }); 41 | console.log("Returned from putDatabase") 42 | if (response.result.ok) { 43 | console.log(`"${databaseName}" database created."`); 44 | } else { 45 | throw new Error('Error for client.putDatabase, response.result.ok=true expected!', {cause: response }); 46 | } 47 | } catch (err) { 48 | console.log("Error for client.putDatabase: %j",err); 49 | throw new Error('Error for client.putDatabase!', { cause: err }); 50 | } 51 | return true; 52 | } 53 | 54 | // post a document into the database 55 | async function postDocument(client,databaseName,doc) { 56 | try { 57 | console.log("writing document to database: "+databaseName); 58 | const response= await client.postDocument({db: databaseName, document: doc}) 59 | console.log("Returned from postDocument") 60 | if (response.result.ok) { 61 | console.log(`"${databaseName}" document written."`); 62 | } else { 63 | throw new Error('Error for client.postDocument, response.result.ok=true expected!', {cause: response }); 64 | } 65 | } catch (err) { 66 | console.log("Error for client.postDocument: %j",err); 67 | throw new Error('Error for client.putDatabase!', { cause: err }); 68 | } 69 | return true; 70 | } 71 | 72 | // get a document from database 73 | async function getDocument(client,databaseName,id) { 74 | var document={}; 75 | try { 76 | console.log("Get document from database: "+databaseName); 77 | const response= await client.getDocument({db: databaseName, docId: id}) 78 | console.log("Returned from getDocument, response: %j",response) 79 | if (response.statusText='OK') { 80 | console.log(`"${databaseName}" document "${id}" successfully read."`); 81 | document=response.result; 82 | } else { 83 | throw new Error('Error for client.getDocument, response.statusText=OK expected!', {cause: response }); 84 | } 85 | } catch (err) { 86 | console.log("Error for client.getDocument: %j",err); 87 | throw new Error('Error for client.getDocument!', { cause: err }); 88 | } 89 | return document; 90 | } 91 | 92 | // main action 93 | async function main(args) { 94 | var username = args.username; 95 | var password = args.password; 96 | var url = args.url; 97 | var dbName = `test_cloud_functions_nodejs_${nodeRuntime}_ibm_runtime` 98 | 99 | console.log("runtime: "+nodeRuntime) 100 | console.log("database name: "+dbName) 101 | console.log("username: "+username) 102 | 103 | if (process.version.startsWith('v16.') || process.version.startsWith('v20.')) { 104 | process.env['CLOUDANT_AUTH_TYPE'] = 'BASIC' 105 | process.env['CLOUDANT_URL'] = url 106 | process.env['CLOUDANT_USERNAME'] = username 107 | process.env['CLOUDANT_PASSWORD'] = password 108 | 109 | // Create a client with `CLOUDANT` default service name 110 | const client = CloudantV1.newInstance({}); 111 | 112 | // Delete a possible existing database from a previous run. 113 | const delDB= await deleteDatabase(client,dbName); 114 | 115 | // Create a database. 116 | const createDB= await createDatabase(client,dbName); 117 | console.log("createDatabase returned:"+createDB); 118 | 119 | // Post a document into the new database. 120 | const doc={ 121 | "_id" : 'friend1', 122 | "firstname": "Suzzy", 123 | "lastname": "Queue" 124 | } 125 | const postDoc= await postDocument(client,dbName,doc); 126 | console.log("postDocument returned:"+postDoc) 127 | 128 | // Read the document from the database. 129 | const getDoc= await getDocument(client,dbName,'friend1'); 130 | console.log("getDocument returned: %j",getDoc) 131 | 132 | // const delDB2= await deleteDatabase(client,dbName); 133 | 134 | // Return the document read from the database. 135 | return getDoc; 136 | 137 | } else { 138 | 139 | //Configuration to use Cloudant 140 | var config = {account:username, password:password, plugins:['promises']} 141 | var cloudant = Cloudant(config); 142 | 143 | var beforeAction = new Promise(function(resolve ,reject){ 144 | cloudant.db.destroy(dbName) 145 | .then(function(){ 146 | console.log("Previous database with name: "+dbName+"existed; it was cleaned up so that tests can run"); 147 | return resolve(); 148 | }) 149 | .catch(function(){ 150 | return resolve(); 151 | }) 152 | }); 153 | 154 | //Create the cloudant database 155 | return beforeAction.then(function(){ 156 | return cloudant.db.create(dbName) 157 | }) 158 | .then(function(data){ 159 | //Switch to use that newly created database. 160 | return cloudant.db.use(dbName); 161 | }) 162 | .then(function(db){ 163 | var friendinfo; 164 | //Inject a json document named friend1 into the database. 165 | return db.insert({firstname: "Suzzy", lastname: "Queue"}, 'friend1') 166 | .then(function(){ 167 | //fetch the newly injected document from the database 168 | return db.get('friend1'); 169 | }) 170 | .then(function(data){ 171 | friendinfo = data; 172 | //destroy the database 173 | return cloudant.db.destroy(dbName); 174 | }) 175 | .then(function(){ 176 | //return the document fetched from the db 177 | return friendinfo; 178 | }) 179 | }) 180 | .catch(function(err){ 181 | //If an error occurrs at any part in execution; return error 182 | return {err: err} 183 | }) 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /tests/src/test/scala/runtime/sdk/NodeJsSDKTests.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 IBM Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package runtime.sdk 18 | 19 | import java.io.File 20 | import scala.concurrent.duration.DurationInt 21 | import scala.language.postfixOps 22 | import common._ 23 | import org.apache.openwhisk.core.entity.Annotations 24 | import org.junit.runner.RunWith 25 | import org.scalatest.junit.JUnitRunner 26 | import spray.json._ 27 | import spray.json.DefaultJsonProtocol.StringJsonFormat 28 | 29 | @RunWith(classOf[JUnitRunner]) 30 | class NodeJsSDKTests extends TestHelpers with WskTestHelpers with WskActorSystem { 31 | 32 | implicit val wskprops = WskProps() 33 | val wsk = new Wsk 34 | val activationPollDuration = 2.minutes 35 | lazy val actionKind = "nodejs:14" 36 | lazy val actionTypeDir: String = "tests/dat/sdk/" 37 | val controllerHost = WhiskProperties.getBaseControllerHost() 38 | val controllerPort = WhiskProperties.getControllerBasePort() 39 | val baseUrl = s"http://$controllerHost:$controllerPort" 40 | //when running tests on environment with valid ssl certs in whisk host then pass -DswiftUseSSLWhiskHost=true 41 | val ignoreSSL = "true" != System.getProperty("nodeUseSSLWhiskHost") 42 | 43 | behavior of s"Nodejs Whisk SDK tests using $actionKind" 44 | 45 | it should "allow NodeJS actions to invoke other actions" in withAssetCleaner(wskprops) { (wp, assetHelper) => 46 | val file = Some(new File(actionTypeDir, "invoke.js").toString()) 47 | 48 | val actionName = "invokeAction" 49 | assetHelper.withCleaner(wsk.action, actionName) { (action, _) => 50 | action.create( 51 | name = actionName, 52 | artifact = file, 53 | kind = Some(actionKind), 54 | annotations = Map(Annotations.ProvideApiKeyAnnotationName -> JsBoolean(true))) 55 | } 56 | // invoke the action 57 | var params = Map("dummy" -> JsString("dummy"), "ignore_certs" -> JsBoolean(ignoreSSL)) 58 | 59 | val run = wsk.action.invoke(actionName, params) 60 | withActivation(wsk.activation, run, initialWait = 5 seconds, totalWait = activationPollDuration) { activation => 61 | // should be successful 62 | activation.response.success shouldBe true 63 | 64 | // should have a field named "activationId" which is the date action's activationId 65 | activation.response.result.get.fields("activationId").toString.length should be >= 32 66 | 67 | val myresponse = activation.response.result.get.fields("response") 68 | val myresult = myresponse.asJsObject().fields("result") 69 | 70 | myresult.asJsObject().fields.get("date") shouldBe defined 71 | myresult.asJsObject().fields("date").toString.length should be > 10 72 | } 73 | } 74 | 75 | it should "allow NodeJs actions to trigger events" in withAssetCleaner(wskprops) { (wp, assetHelper) => 76 | // create a trigger 77 | val triggerName = s"TestTrigger ${System.currentTimeMillis()}" 78 | val ruleName = s"TestTriggerRule ${System.currentTimeMillis()}" 79 | val ruleActionName = s"TestTriggerAction ${System.currentTimeMillis()}" 80 | assetHelper.withCleaner(wsk.trigger, triggerName) { (trigger, _) => 81 | trigger.create(triggerName) 82 | } 83 | 84 | // create a dummy action 85 | assetHelper.withCleaner(wsk.action, ruleActionName) { (action, name) => 86 | val dummyFile = Some(new File(actionTypeDir, "hello.js").toString()) 87 | action.create( 88 | name, 89 | dummyFile, 90 | kind = Some(actionKind), 91 | annotations = Map(Annotations.ProvideApiKeyAnnotationName -> JsBoolean(true))) 92 | } 93 | // create a dummy rule 94 | assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) => 95 | rule.create(name, trigger = triggerName, action = ruleActionName) 96 | } 97 | 98 | // create an action that fires the trigger 99 | val file = Some(new File(actionTypeDir, "trigger.js").toString()) 100 | val actionName = "ActionThatTriggers" 101 | assetHelper.withCleaner(wsk.action, actionName) { (action, _) => 102 | action.create( 103 | name = actionName, 104 | file, 105 | kind = Some(actionKind), 106 | annotations = Map(Annotations.ProvideApiKeyAnnotationName -> JsBoolean(true))) 107 | } 108 | 109 | // invoke the action 110 | var params = Map("triggerName" -> JsString(triggerName), "ignore_certs" -> JsBoolean(ignoreSSL)) 111 | 112 | val run = wsk.action.invoke(actionName, params) 113 | withActivation(wsk.activation, run, initialWait = 5 seconds, totalWait = activationPollDuration) { activation => 114 | // should be successful 115 | activation.response.success shouldBe true 116 | 117 | // should have a field named "activationId" which is the date action's activationId 118 | activation.response.result.get.fields("activationId").toString.length should be >= 32 119 | 120 | // should result in an activation for triggerName 121 | val triggerActivations = wsk.activation.pollFor(1, Some(triggerName), retries = 20) 122 | withClue(s"trigger activations for $triggerName:") { 123 | triggerActivations.length should be(1) 124 | } 125 | } 126 | } 127 | 128 | it should "allow NodeJs actions to create a trigger" in withAssetCleaner(wskprops) { (wp, assetHelper) => 129 | // create an action that creates the trigger 130 | val file = Some(new File(actionTypeDir, "createTrigger.js").toString()) 131 | val actionName = "ActionThatTriggers" 132 | 133 | // the name of the trigger to create 134 | val triggerName = s"TestTrigger ${System.currentTimeMillis()}" 135 | 136 | assetHelper.withCleaner(wsk.action, actionName) { (action, _) => 137 | assetHelper.withCleaner(wsk.trigger, triggerName) { (_, _) => 138 | // using an asset cleaner on the created trigger name will clean it up at the conclusion of the test 139 | action.create( 140 | name = actionName, 141 | file, 142 | kind = Some(actionKind), 143 | annotations = Map(Annotations.ProvideApiKeyAnnotationName -> JsBoolean(true))) 144 | } 145 | } 146 | 147 | // invoke the action 148 | var params = Map("triggerName" -> JsString(triggerName), "ignore_certs" -> JsBoolean(ignoreSSL)) 149 | 150 | val run = wsk.action.invoke(actionName, params) 151 | withActivation(wsk.activation, run, initialWait = 5 seconds, totalWait = activationPollDuration) { activation => 152 | // should be successful 153 | activation.response.success shouldBe true 154 | 155 | // should have a field named "name" which is the name of the trigger created 156 | activation.response.result.get.fields("name") shouldBe JsString(triggerName) 157 | } 158 | } 159 | 160 | it should "allow NodeJs actions to create a rule" in withAssetCleaner(wskprops) { (wp, assetHelper) => 161 | val ruleTriggerName = s"TestTrigger ${System.currentTimeMillis()}" 162 | val ruleActionName = s"TestAction ${System.currentTimeMillis()}" 163 | val ruleName = s"TestRule ${System.currentTimeMillis()}" 164 | 165 | // create a dummy action and trigger for the rule 166 | assetHelper.withCleaner(wsk.action, ruleActionName) { (action, name) => 167 | val dummyFile = Some(new File(actionTypeDir, "hello.js").toString()) 168 | action.create( 169 | name, 170 | dummyFile, 171 | kind = Some(actionKind), 172 | annotations = Map(Annotations.ProvideApiKeyAnnotationName -> JsBoolean(true))) 173 | } 174 | 175 | assetHelper.withCleaner(wsk.trigger, ruleTriggerName) { (trigger, name) => 176 | assetHelper.withCleaner(wsk.rule, ruleName) { (_, _) => 177 | // using an asset cleaner on the created trigger name will clean it up at the conclusion of the test 178 | trigger.create(name) 179 | } 180 | } 181 | 182 | // create an action that creates the rule 183 | val createRuleFile = Some(new File(actionTypeDir, "createRule.js").toString()) 184 | assetHelper.withCleaner(wsk.action, "ActionThatCreatesRule") { (action, name) => 185 | action.create( 186 | name, 187 | createRuleFile, 188 | kind = Some(actionKind), 189 | annotations = Map(Annotations.ProvideApiKeyAnnotationName -> JsBoolean(true))) 190 | } 191 | 192 | // invoke the create rule action 193 | var params = Map( 194 | "triggerName" -> s"/_/$ruleTriggerName".toJson, 195 | "actionName" -> s"/_/$ruleActionName".toJson, 196 | "ruleName" -> ruleName.toJson, 197 | "ignore_certs" -> JsBoolean(ignoreSSL)) 198 | 199 | val run = wsk.action.invoke("ActionThatCreatesRule", params) 200 | withActivation(wsk.activation, run, initialWait = 5 seconds, totalWait = activationPollDuration) { activation => 201 | // should be successful 202 | activation.response.success shouldBe true 203 | 204 | // should have a field named "trigger" which is the name of the trigger associated with the rule 205 | activation.response.result.get.fields("trigger").asJsObject.fields("name") shouldBe ruleTriggerName.toJson 206 | 207 | // should have a field named "action" which is the name of the action associated with the rule 208 | activation.response.result.get.fields("action").asJsObject.fields("name") shouldBe ruleActionName.toJson 209 | } 210 | } 211 | 212 | } 213 | -------------------------------------------------------------------------------- /nodejs14/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # IBM Functions NodeJS 14 Runtime Container 2 | 3 | # Attention 4 | This runtime is deprecated and will not be supported anymore. The code is still here for reference only and might be deleted at any time! 5 | 6 | ## Migrating from `nodejs:12` to `nodejs:14` 7 | - The `@cloudant/cloudant` package is deprecated and therefore not available in this runtime. Please see the [Migration Guide](https://github.com/cloudant/nodejs-cloudant/blob/HEAD/MIGRATION.md) for advice about migrating to the replacement library [@ibm-cloud/cloudant](https://github.com/IBM/cloudant-node-sdk). 8 | - The `request-promise` package is deprecated and therefore not avalable in this runtime. You may use `axios`, `bent`, `got` or `needle` as an alternative. 9 | 10 | # 0.0.1 11 | Alpha release (changes can happen at any time). 12 | 13 | NodeJS version: 14 | - [14.19.0](https://nodejs.org/en/blog/release/v14.19.0/) 15 | 16 | NPM version: 17 | - [6.14.15](https://github.com/npm/cli/releases/tag/v6.14.15) 18 | 19 | NPM Packages: 20 | - [@cloudant/cloudant v4.3.1](https://www.npmjs.com/package/@cloudant/cloudant) - This is the official Cloudant library for Node.js. 21 | - [@ibm-functions/iam-token-manager v1.0.5](https://www.npmjs.com/package/@ibm-functions/iam-token-manager) - This is an IAM access token manager library for Node.js. 22 | - [@sendgrid/mail v6.5.2](https://www.npmjs.com/package/@sendgrid/mail) - Provides email support via the SendGrid API. 23 | - [@wiotp/sdk v0.6.2](https://www.npmjs.com/package/@wiotp/sdk) - IBM Watson IoT Platform Javascript SDK. 24 | - [amqplib v0.5.5](https://www.npmjs.com/package/amqplib) - A library for making AMQP 0-9-1 clients for Node.JS. 25 | - [apn v2.2.0](https://www.npmjs.com/package/apn) - A Node.js module for interfacing with the Apple Push Notification service. 26 | - [async v3.1.1](https://www.npmjs.com/package/async) - Provides functions for working with asynchronous functions. 27 | - [axios v0.19.2](https://www.npmjs.com/package/axios) - Promise based HTTP client for the browser and node.js. 28 | - [bent v7.0.5](https://www.npmjs.com/package/bent) - Functional HTTP client for Node.js w/ async/await. 29 | - [bodyparser v1.18.3](https://www.npmjs.com/package/body-parser) - Parse incoming request bodies in a middleware before your handlers, available under the req.body property. 30 | - [btoa v1.2.1](https://www.npmjs.com/package/btoa) - A port of the browser's btoa function. 31 | - [bufferutil 4.0.1](https://www.npmjs.com/package/bufferutil) - bufferutil is what makes ws fast. 32 | - [canvas 2.6.1](https://www.npmjs.com/package/canvas) - A Cairo-backed Canvas implementation for Node.js. 33 | - [cassandra-driver v4.4.0](https://www.npmjs.com/package/cassandra-driver) - DataStax Node.js Driver for Apache Cassandra. 34 | - [commander v4.1.1](https://www.npmjs.com/package/commander) - The complete solution for node.js command-line interfaces. 35 | - [composeaddresstranslator v1.0.4](https://www.npmjs.com/package/composeaddresstranslator) - Address translator from Compose UI or API for Scylla databases. 36 | - [consul v0.37.0](https://www.npmjs.com/package/consul) - A client for Consul, involving service discovery and configuration. 37 | - [cookie-parser v1.4.4](https://www.npmjs.com/package/cookie-parser) - Parse Cookie header and populate req.cookies with an object keyed by the cookie names. 38 | - [core-js v3.6.4](https://www.npmjs.com/package/core-js) - Modular standard library for JavaScript. 39 | - [elasticsearch v16.6.0](https://www.npmjs.com/package/elasticsearch) - The official low-level Elasticsearch client for Node.js. 40 | - [errorhandler v1.5.1](https://www.npmjs.com/package/errorhandler) - Development-only error handler middleware. 41 | - [etcd3 v0.2.13](https://www.npmjs.com/package/etcd3) - A high-quality, production-ready client for the Protocol Buffer-based etcdv3 API. 42 | - [express v4.16.4](https://www.npmjs.com/package/express) - A Fast, unopinionated, minimalist web framework for node. 43 | - [express-session v1.17.0](https://www.npmjs.com/package/express-session) - A server side session data storing module. 44 | - [formidable v1.2.1](https://www.npmjs.com/package/formidable) - A Node.js module for parsing form data, especially file uploads. 45 | - [glob v7.1.6](https://www.npmjs.com/package/glob) - Match files using the patterns the shell uses, like stars and stuff. 46 | - [gm v1.23.1](https://www.npmjs.com/package/gm) - GraphicsMagick and ImageMagick for Node. 47 | - [got v11.5.1](https://www.npmjs.com/package/got) - Human-friendly and powerful HTTP request library for Node.js. 48 | - [ibm-cos-sdk v1.10.0](https://www.npmjs.com/package/ibm-cos-sdk) - {{site.data.keyword.cos_full}} SDK for Node.js 49 | - [ibm_db v2.7.3](https://www.npmjs.com/package/ibm_db) - An asynchronous/synchronous interface for node.js to IBM DB2 and IBM Informix. 50 | - [@ibm-cloud/cloudant 0.0.18](https://www.npmjs.com/package/@ibm-cloud/cloudant) - IBM Cloudant Node.js SDK is a client library that interacts with the IBM Cloudant APIs. 51 | - [ibm-watson v6.0.4](https://www.npmjs.com/package/ibm-watson) - A node.js client library to use the Watson APIs. 52 | - [iconv-lite v0.5.1](https://www.npmjs.com/package/iconv-lite) - Pure JS character encoding conversion. 53 | - [jest v25.1.0](https://www.npmjs.com/package/jest) - Delightful JavaScript Testing. 54 | - [jsdom v16.1.0](https://www.npmjs.com/package/jsdom) - jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards. 55 | - [jsforce v1.9.3](https://www.npmjs.com/package/jsforce)Salesforce API Library for JavaScript applications. 56 | - [jsonwebtoken v8.5.1](https://www.npmjs.com/package/jsonwebtoken) - An implementation of JSON Web Tokens. 57 | - [lodash v4.17.19](https://www.npmjs.com/package/lodash) - The Lodash library exported as Node.js modules. 58 | - [log4js v6.1.2](https://www.npmjs.com/package/log4js) - This is a conversion of the log4js framework to work with node. 59 | - [marked v0.8.0](https://www.npmjs.com/package/marked) - A full-featured markdown parser and compiler, written in JavaScript. Built for speed. 60 | - [merge v1.2.1](https://www.npmjs.com/package/merge) - Merge multiple objects into one, optionally creating a new cloned object. 61 | - [moment v2.24.0](https://www.npmjs.com/package/moment) - A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates. 62 | - [mongodb v3.5.2](https://www.npmjs.com/package/mongodb) - The official MongoDB driver for Node.js. 63 | - [mustache v4.0.0](https://www.npmjs.com/package/mustache) - mustache.js is an implementation of the mustache template system in JavaScript. 64 | - [mysql v2.18.1](https://www.npmjs.com/package/mysql) - This is a node.js driver for mysql. 65 | - [nano v8.1.0](https://www.npmjs.com/package/nano) - minimalistic couchdb driver for Node.js. 66 | - [needle v2.5.0](https://www.npmjs.com/package/needle) - The leanest and most handsome HTTP client in the Nodelands. 67 | - [nodemailer v6.4.2](https://www.npmjs.com/package/nodemailer) - Send e-mails from Node.js – easy as cake! 68 | - [oauth2-server v3.0.1](https://www.npmjs.com/package/oauth2-server) - Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in Node.js. 69 | - [openwhisk v3.18.0](https://www.npmjs.com/package/openwhisk) - JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs. 70 | - [path-to-regex v6.1.0](https://www.npmjs.com/package/path-to-regexp) - Turn a path string such as /user/:name into a regular expression which can then be used to match against URL paths. 71 | - [pg v7.18.1](https://www.npmjs.com/package/pg) - Non-blocking PostgreSQL client for node.js. Pure JavaScript and optional native libpq bindings. 72 | - [process v0.11.10](https://www.npmjs.com/package/process) - require('process'); just like any other module. 73 | - [pug v3.0.2](https://www.npmjs.com/package/pug) - Implements the Pug templating language. 74 | - [redis v2.8.0](https://www.npmjs.com/package/redis) - This is a complete and feature rich Redis client for Node.js. 75 | - [rimraf v3.0.2](https://www.npmjs.com/package/rimraf) - The UNIX command rm -rf for node. 76 | - [semver v7.1.2](https://www.npmjs.com/package/semver) - Semantic Versioning for Nodejs 77 | - [serialize-error v3.0.0](https://www.npmjs.com/package/serialize-error) - Serialize an error into a plain object. 78 | - [serve-favicon v2.5.0](https://www.npmjs.com/package/serve-favicon) - Node.js middleware for serving a favicon. 79 | - [socket.io v2.4.1](https://www.npmjs.com/package/socket.io) - Socket.IO enables real-time bidirectional event-based communication. 80 | - [socket.io-client v2.4.0](https://www.npmjs.com/package/socket.io-client) - Realtime application framework for socket.io. 81 | - [superagent v5.2.1](https://www.npmjs.com/package/superagent) - SuperAgent is a small progressive client-side HTTP request library, and Node.js module with the same API, sporting many high-level HTTP client features. 82 | - [swagger-tools v0.10.4](https://www.npmjs.com/package/swagger-tools) - Package that provides various tools for integrating and interacting with Swagger. 83 | - [tmp v0.1.0](https://www.npmjs.com/package/tmp) - A simple temporary file and directory creator for node.js. 84 | - [ts-jest v25.2.0](https://www.npmjs.com/package/ts-jest) - A TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript. 85 | - [twilio v3.39.4](https://www.npmjs.com/package/twilio) - A wrapper for the Twilio API, related to voice, video, and messaging. 86 | - [underscore v1.9.2](https://www.npmjs.com/package/underscore) - Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects. 87 | - [url-pattern v1.0.3](https://www.npmjs.com/package/url-pattern) - Parse URLs for path parameters more easily than from using a regex string matcher. 88 | - [utf-8-validate v5.0.2](https://www.npmjs.com/package/utf-8-validate) - Check if a buffer contains valid UTF-8 encoded text. 89 | - [uuid v3.3.0](https://www.npmjs.com/package/uuid) - Simple, fast generation of RFC4122 UUIDS. 90 | - [validator v12.2.0](https://www.npmjs.com/package/validator) - A library of string validators and sanitizers. 91 | - [vcap_services v0.7.1](https://www.npmjs.com/package/vcap_services)Parse and return service credentials from VCAP_SERVICES environment variable that IBM Cloud provides. 92 | - [when v3.7.8](https://www.npmjs.com/package/when) - When.js is a rock solid, battle-tested Promises/A+ and when() implementation, including a complete ES6 Promise shim. 93 | - [winston v3.2.1](https://www.npmjs.com/package/winston) - A multi-transport async logging library for node.js. "CHILL WINSTON! ... I put it in the logs." 94 | - [ws v7.2.1](https://www.npmjs.com/package/ws) - ws is a simple to use, blazing fast, and thoroughly tested WebSocket client and server implementation. 95 | - [xlsx v0.15.5](https://www.npmjs.com/package/xlsx) - Parser and writer for various spreadsheet formats. 96 | - [xml2js v0.4.23](https://www.npmjs.com/package/xml2js) - Simple XML to JavaScript object converter. It supports bi-directional conversion. 97 | - [xmlhttprequest v1.8.0](https://www.npmjs.com/package/xmlhttprequest) - node-XMLHttpRequest is a wrapper for the built-in http client to emulate the browser XMLHttpRequest object. 98 | - [yauzl v2.10.0](https://www.npmjs.com/package/yauzl) - yet another unzip library for node. For zipping. 99 | - [yazl v2.5.1](https://www.npmjs.com/package/yauzl) - yet another unzip library for node. For zipping. 100 | -------------------------------------------------------------------------------- /nodejs20/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # IBM Functions NodeJS 20 Runtime Container 2 | 3 | ## Migrating from `nodejs:16` to `nodejs:20` 4 | Some of the packages have been updated to the latest version and might contain breaking changes please check that the packages you use are still working as expected all supported packages are refrenced in the [package.json](nodejs20/package.json). 5 | 6 | - The `@ibm-cloud/cloudant` package has been updated from 0.3.x to 0.5.x and contains breaking changes check the Repository for changes [cloudant-node-sdk](https://github.com/IBM/cloudant-node-sdk) 7 | 8 | # 1.4.0 9 | Changes: 10 | - Update parent image to latest Openwhisk Tag 110a0f4 11 | - Update package openwhisk from 3.21.7 to 3.21.8 12 | 13 | NodeJS version: 14 | - v20.11.1 15 | 16 | NPM version: 17 | - v10.2.4 18 | 19 | NodeJS packages: 20 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 21 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 22 | 23 | # 1.3.0 24 | Changes: 25 | - Update base image to latest Openwhisk Tag 08763c2 26 | 27 | NodeJS version: 28 | - v20.7.0 29 | 30 | NPM version: 31 | - v10.1.0 32 | 33 | NodeJS packages: 34 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 35 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 36 | 37 | # 1.2.0 38 | Changes: 39 | - Update Axios to 1.6.1 in order to fix vulnerability 40 | 41 | NodeJS version: 42 | - v20.7.0 43 | 44 | NPM version: 45 | - v10.1.0 46 | 47 | NodeJS packages: 48 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 49 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 50 | 51 | # 1.1.0 52 | Changes: 53 | - Update base image to latest Openwhisk Tag c60a667 54 | 55 | NodeJS version: 56 | - v20.7.0 57 | 58 | NPM version: 59 | - v10.1.0 60 | 61 | NodeJS packages: 62 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 63 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 64 | 65 | # 1.0.0 66 | 67 | NodeJS version: 68 | - [20.19.0](https://nodejs.org/en/blog/release/v20.19.0/) 69 | 70 | NPM version: 71 | - [9.8.0](https://github.com/npm/cli/releases/tag/v9.8.0) 72 | 73 | NPM Packages: 74 | - [@ibm-cloud/cloudant v0.5.55](https://www.npmjs.com/package/@ibm-cloud/cloudant) - This is the official Cloudant library for Node.js. 75 | - [@ibm-functions/iam-token-manager v1.0.11](https://www.npmjs.com/package/@ibm-functions/iam-token-manager) - This is an IAM access token manager library for Node.js. 76 | - [@sendgrid/mail v7.7.0](https://www.npmjs.com/package/@sendgrid/mail) - Provides email support via the SendGrid API. 77 | - [@wiotp/sdk v0.7.8](https://www.npmjs.com/package/@wiotp/sdk) - IBM Watson IoT Platform Javascript SDK. 78 | - [amqplib v0.10.3](https://www.npmjs.com/package/amqplib) - A library for making AMQP 0-9-1 clients for Node.JS. 79 | - [apn v2.2.0](https://www.npmjs.com/package/apn) - A Node.js module for interfacing with the Apple Push Notification service. 80 | - [async v3.2.4](https://www.npmjs.com/package/async) - Provides functions for working with asynchronous functions. 81 | - [axios v1.4.0](https://www.npmjs.com/package/axios) - Promise based HTTP client for the browser and node.js. 82 | - [bent v7.3.12](https://www.npmjs.com/package/bent) - Functional HTTP client for Node.js w/ async/await. 83 | - [bodyparser v1.20.2](https://www.npmjs.com/package/body-parser) - Parse incoming request bodies in a middleware before your handlers, available under the req.body property. 84 | - [btoa v1.2.1](https://www.npmjs.com/package/btoa) - A port of the browser's btoa function. 85 | - [bufferutil 4.0.7](https://www.npmjs.com/package/bufferutil) - bufferutil is what makes ws fast. 86 | - [canvas v2.11.2](https://www.npmjs.com/package/canvas) - A Cairo-backed Canvas implementation for Node.js. 87 | - [cassandra-driver v4.6.4](https://www.npmjs.com/package/cassandra-driver) - DataStax Node.js Driver for Apache Cassandra. 88 | - [commander v11.0.0](https://www.npmjs.com/package/commander) - The complete solution for node.js command-line interfaces. 89 | - [composeaddresstranslator v1.0.4](https://www.npmjs.com/package/composeaddresstranslator) - Address translator from Compose UI or API for Scylla databases. 90 | - [consul v1.2.0](https://www.npmjs.com/package/consul) - A client for Consul, involving service discovery and configuration. 91 | - [cookie-parser v1.4.6](https://www.npmjs.com/package/cookie-parser) - Parse Cookie header and populate req.cookies with an object keyed by the cookie names. 92 | - [core-js v3.21.1](https://www.npmjs.com/package/core-js) - Modular standard library for JavaScript. 93 | - [@elastic/elasticsearch v8.8.1](https://www.npmjs.com/package/@elastic/elasticsearch) - The official low-level Elasticsearch client for Node.js. 94 | - [errorhandler v1.5.1](https://www.npmjs.com/package/errorhandler) - Development-only error handler middleware. 95 | - [etcd3 v1.1.0](https://www.npmjs.com/package/etcd3) - A high-quality, production-ready client for the Protocol Buffer-based etcdv3 API. 96 | - [express v4.17.3](https://www.npmjs.com/package/express) - A Fast, unopinionated, minimalist web framework for node. 97 | - [express-session v1.17.3](https://www.npmjs.com/package/express-session) - A server side session data storing module. 98 | - [formidable v3.5.0](https://www.npmjs.com/package/formidable) - A Node.js module for parsing form data, especially file uploads. 99 | - [glob v10.3.3](https://www.npmjs.com/package/glob) - Match files using the patterns the shell uses, like stars and stuff. 100 | - [gm v1.25.0](https://www.npmjs.com/package/gm) - GraphicsMagick and ImageMagick for Node. 101 | - [got v13.0.0](https://www.npmjs.com/package/got) - Human-friendly and powerful HTTP request library for Node.js. 102 | - [ibm-cos-sdk v1.13.1](https://www.npmjs.com/package/ibm-cos-sdk) - {{site.data.keyword.cos_full}} SDK for Node.js 103 | - [ibm_db v3.2.1](https://www.npmjs.com/package/ibm_db) - An asynchronous/synchronous interface for node.js to IBM DB2 and IBM Informix. 104 | - [ibm-watson v8.0.0](https://www.npmjs.com/package/ibm-watson) - A node.js client library to use the Watson APIs. 105 | - [iconv-lite v0.6.3](https://www.npmjs.com/package/iconv-lite) - Pure JS character encoding conversion. 106 | - [jest v29.6.1](https://www.npmjs.com/package/jest) - Delightful JavaScript Testing. 107 | - [jsdom v22.1.0](https://www.npmjs.com/package/jsdom) - jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards. 108 | - [jsforce v1.11.1](https://www.npmjs.com/package/jsforce)Salesforce API Library for JavaScript applications. 109 | - [jsonwebtoken v9.0.1](https://www.npmjs.com/package/jsonwebtoken) - An implementation of JSON Web Tokens. 110 | - [lodash v4.17.21](https://www.npmjs.com/package/lodash) - The Lodash library exported as Node.js modules. 111 | - [log4js v6.9.1](https://www.npmjs.com/package/log4js) - This is a conversion of the log4js framework to work with node. 112 | - [marked v5.1.1](https://www.npmjs.com/package/marked) - A full-featured markdown parser and compiler, written in JavaScript. Built for speed. 113 | - [merge v2.1.1](https://www.npmjs.com/package/merge) - Merge multiple objects into one, optionally creating a new cloned object. 114 | - [moment v2.29.1](https://www.npmjs.com/package/moment) - A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates. 115 | - [mongodb v5.7.0](https://www.npmjs.com/package/mongodb) - The official MongoDB driver for Node.js. 116 | - [mustache v4.2.0](https://www.npmjs.com/package/mustache) - mustache.js is an implementation of the mustache template system in JavaScript. 117 | - [mysql v2.18.1](https://www.npmjs.com/package/mysql) - This is a node.js driver for mysql. 118 | - [nano v10.1.2](https://www.npmjs.com/package/nano) - minimalistic couchdb driver for Node.js. 119 | - [needle v3.2.0](https://www.npmjs.com/package/needle) - The leanest and most handsome HTTP client in the Nodelands. 120 | - [nodemailer v6.9.4](https://www.npmjs.com/package/nodemailer) - Send e-mails from Node.js – easy as cake! 121 | - [oauth2-server v3.1.1](https://www.npmjs.com/package/oauth2-server) - Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in Node.js. 122 | - [openwhisk v3.21.7](https://www.npmjs.com/package/openwhisk) - JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs. 123 | - [path-to-regex v6.2.1](https://www.npmjs.com/package/path-to-regexp) - Turn a path string such as /user/:name into a regular expression which can then be used to match against URL paths. 124 | - [pg v8.11.1](https://www.npmjs.com/package/pg) - Non-blocking PostgreSQL client for node.js. Pure JavaScript and optional native libpq bindings. 125 | - [process v0.11.10](https://www.npmjs.com/package/process) - require('process'); just like any other module. 126 | - [pug v3.0.2](https://www.npmjs.com/package/pug) - Implements the Pug templating language. 127 | - [redis v4.0.4](https://www.npmjs.com/package/redis) - This is a complete and feature rich Redis client for Node.js. 128 | - [rimraf v5.0.1](https://www.npmjs.com/package/rimraf) - The UNIX command rm -rf for node. 129 | - [semver v7.5.4](https://www.npmjs.com/package/semver) - Semantic Versioning for Nodejs 130 | - [serialize-error v9.1.0](https://www.npmjs.com/package/serialize-error) - Serialize an error into a plain object. 131 | - [serve-favicon v2.5.0](https://www.npmjs.com/package/serve-favicon) - Node.js middleware for serving a favicon. 132 | - [socket.io v4.7.1](https://www.npmjs.com/package/socket.io) - Socket.IO enables real-time bidirectional event-based communication. 133 | - [socket.io-client v4.7.1](https://www.npmjs.com/package/socket.io-client) - Realtime application framework for socket.io. 134 | - [superagent v8.0.9](https://www.npmjs.com/package/superagent) - SuperAgent is a small progressive client-side HTTP request library, and Node.js module with the same API, sporting many high-level HTTP client features. 135 | - [swagger-tools v0.10.4](https://www.npmjs.com/package/swagger-tools) - Package that provides various tools for integrating and interacting with Swagger. 136 | - [tmp v0.2.1](https://www.npmjs.com/package/tmp) - A simple temporary file and directory creator for node.js. 137 | - [ts-jest v29.1.1](https://www.npmjs.com/package/ts-jest) - A TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript. 138 | - [twilio v4.13.0](https://www.npmjs.com/package/twilio) - A wrapper for the Twilio API, related to voice, video, and messaging. 139 | - [underscore v1.13.6](https://www.npmjs.com/package/underscore) - Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects. 140 | - [url-pattern v1.0.3](https://www.npmjs.com/package/url-pattern) - Parse URLs for path parameters more easily than from using a regex string matcher. 141 | - [utf-8-validate v6.0.3](https://www.npmjs.com/package/utf-8-validate) - Check if a buffer contains valid UTF-8 encoded text. 142 | - [uuid v8.3.2](https://www.npmjs.com/package/uuid) - Simple, fast generation of RFC4122 UUIDS. 143 | - [validator v13.9.0](https://www.npmjs.com/package/validator) - A library of string validators and sanitizers. 144 | - [vcap_services v0.7.1](https://www.npmjs.com/package/vcap_services)Parse and return service credentials from VCAP_SERVICES environment variable that IBM Cloud provides. 145 | - [when v3.7.8](https://www.npmjs.com/package/when) - When.js is a rock solid, battle-tested Promises/A+ and when() implementation, including a complete ES6 Promise shim. 146 | - [winston v3.10.0](https://www.npmjs.com/package/winston) - A multi-transport async logging library for node.js. "CHILL WINSTON! ... I put it in the logs." 147 | - [ws v8.13.0](https://www.npmjs.com/package/ws) - ws is a simple to use, blazing fast, and thoroughly tested WebSocket client and server implementation. 148 | - [xlsx v0.18.5](https://www.npmjs.com/package/xlsx) - Parser and writer for various spreadsheet formats. 149 | - [xml2js v0.6.0](https://www.npmjs.com/package/xml2js) - Simple XML to JavaScript object converter. It supports bi-directional conversion. 150 | - [xmlhttprequest v1.8.0](https://www.npmjs.com/package/xmlhttprequest) - node-XMLHttpRequest is a wrapper for the built-in http client to emulate the browser XMLHttpRequest object. 151 | - [yauzl v2.10.0](https://www.npmjs.com/package/yauzl) - yet another unzip library for node. For zipping. 152 | - [yazl v2.5.1](https://www.npmjs.com/package/yauzl) - yet another unzip library for node. For zipping. 153 | -------------------------------------------------------------------------------- /nodejs16/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # IBM Functions NodeJS 16 Runtime Container 2 | 3 | ## Migrating from `nodejs:12` to `nodejs:16` 4 | - The `@cloudant/cloudant` package is deprecated and therefore not available in this runtime. Please see the [Migration Guide](https://github.com/cloudant/nodejs-cloudant/blob/HEAD/MIGRATION.md) for advice about migrating to the replacement library [@ibm-cloud/cloudant](https://github.com/IBM/cloudant-node-sdk). 5 | - The `request-promise` package is deprecated and therefore not avalable in this runtime. You may use `axios`, `bent`, `got` or `needle` as an alternative. 6 | - The `elasticsearch` package is no longer maintained and ha been replaced with `@elastic/elasticsearch `and is therefore not available in this runtime. Please see the [Migration Guide](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/breaking-changes.html) 7 | - Mongodb drivers have been upgraded to version 4 please check the [Upgrade Guide](https://github.com/mongodb/node-mongodb-native/blob/HEAD/docs/CHANGES_4.0.0.md) 8 | - The `redis` package has been updated to version 4 please check the [Migration Guide](https://github.com/redis/node-redis/blob/HEAD/docs/v3-to-v4.md) 9 | 10 | # 1.0.6 11 | Changes: 12 | - Update base image to latest Openwhisk Tag 28ac4c0 13 | 14 | NodeJS version: 15 | - v16.20.0 16 | 17 | NPM version: 18 | - v8.19.4 19 | 20 | NodeJS packages: 21 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 22 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 23 | 24 | # 1.0.5 25 | Changes: 26 | - Update base image to latest Openwhisk Tag 577ccbb 27 | 28 | NodeJS version: 29 | - v16.20.0 30 | 31 | NPM version: 32 | - v8.19.4 33 | 34 | NodeJS packages: 35 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 36 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 37 | 38 | # 1.0.4 39 | Changes: 40 | - Update base image to latest Openwhisk Tag 7e0173b 41 | - Update openwhisk 3.21.6 -> 3.21.7 to match openwhisk/action-nodejs-v16 42 | 43 | NodeJS version: 44 | - v16.19.1 45 | 46 | NodeJS packages: 47 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 48 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 49 | 50 | # 1.0.3 51 | Changes: 52 | - Update base image to latest Tag 21de03c 53 | 54 | NodeJS version: 55 | - v16.18.1 56 | 57 | NodeJS packages: 58 | - The file [package.json](package.json) lists the packages we guarantee to be included in this runtime. 59 | Ensure that you only use packages mentioned there. Other nodejs packages might be part of this runtime, but only due to indirect dependencies of the above listed packages. These indirectly included packages are candidates to be removed at any time in case they are not required by the referring package anymore. 60 | 61 | # 1.0.2 62 | Changes: 63 | - Update base image to latest Tag 59dd01a 64 | 65 | NodeJS version: 66 | - v16.17.1 67 | 68 | # 1.0.1 69 | Changes: 70 | - Update base image to latest Tag 431acd7 71 | 72 | # 1.0.0 73 | 74 | NodeJS version: 75 | - [16.19.0](https://nodejs.org/en/blog/release/v14.19.0/) 76 | 77 | NPM version: 78 | - [6.14.15](https://github.com/npm/cli/releases/tag/v6.14.15) 79 | 80 | NPM Packages: 81 | - [@ibm-cloud/cloudant v0.0.25](https://www.npmjs.com/package/@ibm-cloud/cloudant) - This is the official Cloudant library for Node.js. 82 | - [@ibm-functions/iam-token-manager v1.0.7](https://www.npmjs.com/package/@ibm-functions/iam-token-manager) - This is an IAM access token manager library for Node.js. 83 | - [@sendgrid/mail v6.6.1](https://www.npmjs.com/package/@sendgrid/mail) - Provides email support via the SendGrid API. 84 | - [@wiotp/sdk v0.7.8](https://www.npmjs.com/package/@wiotp/sdk) - IBM Watson IoT Platform Javascript SDK. 85 | - [amqplib v0.8.0](https://www.npmjs.com/package/amqplib) - A library for making AMQP 0-9-1 clients for Node.JS. 86 | - [apn v2.2.0](https://www.npmjs.com/package/apn) - A Node.js module for interfacing with the Apple Push Notification service. 87 | - [async v3.2.3](https://www.npmjs.com/package/async) - Provides functions for working with asynchronous functions. 88 | - [axios v0.26.0](https://www.npmjs.com/package/axios) - Promise based HTTP client for the browser and node.js. 89 | - [bent v7.3.12](https://www.npmjs.com/package/bent) - Functional HTTP client for Node.js w/ async/await. 90 | - [bodyparser v1.19.2](https://www.npmjs.com/package/body-parser) - Parse incoming request bodies in a middleware before your handlers, available under the req.body property. 91 | - [btoa v1.2.1](https://www.npmjs.com/package/btoa) - A port of the browser's btoa function. 92 | - [bufferutil 4.0.6](https://www.npmjs.com/package/bufferutil) - bufferutil is what makes ws fast. 93 | - [canvas 2.9.0](https://www.npmjs.com/package/canvas) - A Cairo-backed Canvas implementation for Node.js. 94 | - [cassandra-driver v4.6.3](https://www.npmjs.com/package/cassandra-driver) - DataStax Node.js Driver for Apache Cassandra. 95 | - [commander v9.0.0](https://www.npmjs.com/package/commander) - The complete solution for node.js command-line interfaces. 96 | - [composeaddresstranslator v1.0.4](https://www.npmjs.com/package/composeaddresstranslator) - Address translator from Compose UI or API for Scylla databases. 97 | - [consul v0.40.0](https://www.npmjs.com/package/consul) - A client for Consul, involving service discovery and configuration. 98 | - [cookie-parser v1.4.6](https://www.npmjs.com/package/cookie-parser) - Parse Cookie header and populate req.cookies with an object keyed by the cookie names. 99 | - [core-js v3.21.1](https://www.npmjs.com/package/core-js) - Modular standard library for JavaScript. 100 | - [@elastic/elasticsearch v8.0.0](https://www.npmjs.com/package/@elastic/elasticsearch) - The official low-level Elasticsearch client for Node.js. 101 | - [errorhandler v1.5.1](https://www.npmjs.com/package/errorhandler) - Development-only error handler middleware. 102 | - [etcd3 v1.1.0](https://www.npmjs.com/package/etcd3) - A high-quality, production-ready client for the Protocol Buffer-based etcdv3 API. 103 | - [express v4.17.3](https://www.npmjs.com/package/express) - A Fast, unopinionated, minimalist web framework for node. 104 | - [express-session v1.17.2](https://www.npmjs.com/package/express-session) - A server side session data storing module. 105 | - [formidable v2.0.1](https://www.npmjs.com/package/formidable) - A Node.js module for parsing form data, especially file uploads. 106 | - [glob v7.2.0](https://www.npmjs.com/package/glob) - Match files using the patterns the shell uses, like stars and stuff. 107 | - [gm v1.23.1](https://www.npmjs.com/package/gm) - GraphicsMagick and ImageMagick for Node. 108 | - [got v12.0.1](https://www.npmjs.com/package/got) - Human-friendly and powerful HTTP request library for Node.js. 109 | - [ibm-cos-sdk v1.11.0](https://www.npmjs.com/package/ibm-cos-sdk) - {{site.data.keyword.cos_full}} SDK for Node.js 110 | - [ibm_db v2.8.1](https://www.npmjs.com/package/ibm_db) - An asynchronous/synchronous interface for node.js to IBM DB2 and IBM Informix. 111 | - [ibm-watson v6.2.2](https://www.npmjs.com/package/ibm-watson) - A node.js client library to use the Watson APIs. 112 | - [iconv-lite v0.6.3](https://www.npmjs.com/package/iconv-lite) - Pure JS character encoding conversion. 113 | - [jest v27.5.1](https://www.npmjs.com/package/jest) - Delightful JavaScript Testing. 114 | - [jsdom v19.0.0](https://www.npmjs.com/package/jsdom) - jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards. 115 | - [jsforce v1.11.0](https://www.npmjs.com/package/jsforce)Salesforce API Library for JavaScript applications. 116 | - [jsonwebtoken v8.5.1](https://www.npmjs.com/package/jsonwebtoken) - An implementation of JSON Web Tokens. 117 | - [lodash v4.17.21](https://www.npmjs.com/package/lodash) - The Lodash library exported as Node.js modules. 118 | - [log4js v6.4.1](https://www.npmjs.com/package/log4js) - This is a conversion of the log4js framework to work with node. 119 | - [marked v4.0.12](https://www.npmjs.com/package/marked) - A full-featured markdown parser and compiler, written in JavaScript. Built for speed. 120 | - [merge v2.1.1](https://www.npmjs.com/package/merge) - Merge multiple objects into one, optionally creating a new cloned object. 121 | - [moment v2.29.1](https://www.npmjs.com/package/moment) - A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates. 122 | - [mongodb v4.3.1](https://www.npmjs.com/package/mongodb) - The official MongoDB driver for Node.js. 123 | - [mustache v4.2.0](https://www.npmjs.com/package/mustache) - mustache.js is an implementation of the mustache template system in JavaScript. 124 | - [mysql v2.18.1](https://www.npmjs.com/package/mysql) - This is a node.js driver for mysql. 125 | - [nano v9.0.5](https://www.npmjs.com/package/nano) - minimalistic couchdb driver for Node.js. 126 | - [needle v3.0.0](https://www.npmjs.com/package/needle) - The leanest and most handsome HTTP client in the Nodelands. 127 | - [nodemailer v6.7.2](https://www.npmjs.com/package/nodemailer) - Send e-mails from Node.js – easy as cake! 128 | - [oauth2-server v3.1.1](https://www.npmjs.com/package/oauth2-server) - Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in Node.js. 129 | - [openwhisk v3.21.6](https://www.npmjs.com/package/openwhisk) - JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs. 130 | - [path-to-regex v6.2.0](https://www.npmjs.com/package/path-to-regexp) - Turn a path string such as /user/:name into a regular expression which can then be used to match against URL paths. 131 | - [pg v8.7.3](https://www.npmjs.com/package/pg) - Non-blocking PostgreSQL client for node.js. Pure JavaScript and optional native libpq bindings. 132 | - [process v0.11.10](https://www.npmjs.com/package/process) - require('process'); just like any other module. 133 | - [pug v3.0.2](https://www.npmjs.com/package/pug) - Implements the Pug templating language. 134 | - [redis v4.0.3](https://www.npmjs.com/package/redis) - This is a complete and feature rich Redis client for Node.js. 135 | - [rimraf v3.0.2](https://www.npmjs.com/package/rimraf) - The UNIX command rm -rf for node. 136 | - [semver v7.3.5](https://www.npmjs.com/package/semver) - Semantic Versioning for Nodejs 137 | - [serialize-error v9.1.0](https://www.npmjs.com/package/serialize-error) - Serialize an error into a plain object. 138 | - [serve-favicon v2.5.0](https://www.npmjs.com/package/serve-favicon) - Node.js middleware for serving a favicon. 139 | - [socket.io v4.4.1](https://www.npmjs.com/package/socket.io) - Socket.IO enables real-time bidirectional event-based communication. 140 | - [socket.io-client v4.4.1](https://www.npmjs.com/package/socket.io-client) - Realtime application framework for socket.io. 141 | - [superagent v7.1.1](https://www.npmjs.com/package/superagent) - SuperAgent is a small progressive client-side HTTP request library, and Node.js module with the same API, sporting many high-level HTTP client features. 142 | - [swagger-tools v0.10.4](https://www.npmjs.com/package/swagger-tools) - Package that provides various tools for integrating and interacting with Swagger. 143 | - [tmp v0.2.1](https://www.npmjs.com/package/tmp) - A simple temporary file and directory creator for node.js. 144 | - [ts-jest v27.1.3](https://www.npmjs.com/package/ts-jest) - A TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript. 145 | - [twilio v3.74.0](https://www.npmjs.com/package/twilio) - A wrapper for the Twilio API, related to voice, video, and messaging. 146 | -[typescript v4.5.5](https://www.npmjs.com/package/typescript) - TypeScript is a language for application scale JavaScript development 147 | - [underscore v1.13.2](https://www.npmjs.com/package/underscore) - Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects. 148 | - [url-pattern v1.0.3](https://www.npmjs.com/package/url-pattern) - Parse URLs for path parameters more easily than from using a regex string matcher. 149 | - [utf-8-validate v5.0.8](https://www.npmjs.com/package/utf-8-validate) - Check if a buffer contains valid UTF-8 encoded text. 150 | - [uuid v8.3.2](https://www.npmjs.com/package/uuid) - Simple, fast generation of RFC4122 UUIDS. 151 | - [validator v13.7.0](https://www.npmjs.com/package/validator) - A library of string validators and sanitizers. 152 | - [vcap_services v0.7.1](https://www.npmjs.com/package/vcap_services)Parse and return service credentials from VCAP_SERVICES environment variable that IBM Cloud provides. 153 | - [when v3.7.8](https://www.npmjs.com/package/when) - When.js is a rock solid, battle-tested Promises/A+ and when() implementation, including a complete ES6 Promise shim. 154 | - [winston v3.6.0](https://www.npmjs.com/package/winston) - A multi-transport async logging library for node.js. "CHILL WINSTON! ... I put it in the logs." 155 | - [ws v8.5.0](https://www.npmjs.com/package/ws) - ws is a simple to use, blazing fast, and thoroughly tested WebSocket client and server implementation. 156 | - [xlsx v0.18.2](https://www.npmjs.com/package/xlsx) - Parser and writer for various spreadsheet formats. 157 | - [xml2js v0.4.23](https://www.npmjs.com/package/xml2js) - Simple XML to JavaScript object converter. It supports bi-directional conversion. 158 | - [xmlhttprequest v1.8.0](https://www.npmjs.com/package/xmlhttprequest) - node-XMLHttpRequest is a wrapper for the built-in http client to emulate the browser XMLHttpRequest object. 159 | - [yauzl v2.10.0](https://www.npmjs.com/package/yauzl) - yet another unzip library for node. For zipping. 160 | - [yazl v2.5.1](https://www.npmjs.com/package/yauzl) - yet another unzip library for node. For zipping. 161 | --------------------------------------------------------------------------------