From 91aea417efc6295ddeeb6dc77bb7963a9e13e671 Mon Sep 17 00:00:00 2001 From: Felix Meissner Date: Wed, 19 Aug 2020 14:38:18 +0200 Subject: [PATCH] add: hello-config, s3uploader sample; update/adjust: project READMEs, type definitions --- examples/amqp-echo/README.md | 2 +- examples/amqp-echo/lib/index.js | 9 ++- examples/call-other-function/README.md | 9 +-- examples/call-other-function/lib/main.js | 9 ++- examples/hello-config/README.md | 26 +++++++ examples/hello-config/data/rv.json | 10 +++ examples/hello-config/data/text | 1 + examples/hello-config/faas.json | 25 +++++++ examples/hello-config/lib/index.js | 17 +++++ examples/hello-config/package.json | 26 +++++++ examples/hello-config/test/mock/values.yaml | 5 ++ .../test/unit/test-hello-secret.js | 74 +++++++++++++++++++ examples/hello-oauth-xsuaa/README.md | 4 +- examples/hello-oauth-xsuaa/lib/index.js | 9 ++- examples/hello-oauth/README.md | 8 +- examples/hello-oauth/lib/index.js | 9 ++- examples/hello-secret/README.md | 6 +- examples/hello-secret/lib/index.js | 9 ++- examples/hello-timer/README.md | 4 +- examples/hello-timer/lib/index.js | 9 ++- examples/kafka-producer/lib/index.js | 9 ++- examples/qrcode-producer/README.md | 8 +- examples/qrcode-producer/lib/iso-time.js | 5 ++ examples/s3uploader/README.md | 33 +++++++++ examples/s3uploader/data/s3/credentials.json | 9 +++ examples/s3uploader/faas.json | 25 +++++++ examples/s3uploader/lib/index.js | 48 ++++++++++++ examples/s3uploader/package.json | 27 +++++++ examples/s4sdk/README.md | 6 +- examples/s4sdk/lib/handler.js | 8 +- examples/slack-classify-image/README.md | 2 +- examples/weather/advanced_ui/README.md | 9 +-- examples/weather/basic_ui/README.md | 7 +- 33 files changed, 390 insertions(+), 77 deletions(-) create mode 100644 examples/hello-config/README.md create mode 100644 examples/hello-config/data/rv.json create mode 100644 examples/hello-config/data/text create mode 100644 examples/hello-config/faas.json create mode 100644 examples/hello-config/lib/index.js create mode 100644 examples/hello-config/package.json create mode 100644 examples/hello-config/test/mock/values.yaml create mode 100644 examples/hello-config/test/unit/test-hello-secret.js create mode 100644 examples/s3uploader/README.md create mode 100644 examples/s3uploader/data/s3/credentials.json create mode 100644 examples/s3uploader/faas.json create mode 100644 examples/s3uploader/lib/index.js create mode 100644 examples/s3uploader/package.json diff --git a/examples/amqp-echo/README.md b/examples/amqp-echo/README.md index a11a115..c9352fd 100644 --- a/examples/amqp-echo/README.md +++ b/examples/amqp-echo/README.md @@ -29,7 +29,7 @@ For this example we will register a service using the xfsrt-cli. This will simpl Given the __`Enterprise Messaging`__ service instance name and binding, run the following command: ```bash -xfsrt-cli faas service register -s -b +xfsrt-cli faas service register -s -b ``` Create a deployment file to provide credentials, topics and queue names. diff --git a/examples/amqp-echo/lib/index.js b/examples/amqp-echo/lib/index.js index 90d321b..5c8931f 100644 --- a/examples/amqp-echo/lib/index.js +++ b/examples/amqp-echo/lib/index.js @@ -1,8 +1,9 @@ 'use strict'; -/** -* @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ /** * @param {Faas.Event} event diff --git a/examples/call-other-function/README.md b/examples/call-other-function/README.md index 02791ee..0a86ec2 100644 --- a/examples/call-other-function/README.md +++ b/examples/call-other-function/README.md @@ -9,11 +9,10 @@ $ xfsrt-cli faas project deploy -v ``` ## Test -The HTTP trigger URL can be retrieved from: -``` -xfsrt-cli faas project get chain -``` -The `artifacts` array contains an object with the URL in its `name` property (and a `reference` to the HTTP trigger `chain-simple`) +The output received after executing the [deployment](#Deployment) step contains the trigger endpoint. + +Invoke the __`chain-func1`__ function via invoking the HTTP trigger URL. + ## License Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. diff --git a/examples/call-other-function/lib/main.js b/examples/call-other-function/lib/main.js index c7220bd..8fb7685 100644 --- a/examples/call-other-function/lib/main.js +++ b/examples/call-other-function/lib/main.js @@ -1,8 +1,9 @@ 'use strict'; -/** -* @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ /** * @param {Faas.Event} event diff --git a/examples/hello-config/README.md b/examples/hello-config/README.md new file mode 100644 index 0000000..cf4a1d0 --- /dev/null +++ b/examples/hello-config/README.md @@ -0,0 +1,26 @@ +# Example: hello-secret + +This example deploys a function which extracts information from a secret. + +## Deployment +First, create a deployment file to provide credentials. +Run inside the project directory: +```bash +faas-sdk init-values -y values.yaml +``` +Update the generated file. And finally, deploy the project as usual: +```bash + xfsrt-cli faas project deploy -y ./deploy/values.yaml -v +``` + +### Test +The output received after executing the [deployment](#Deployment) step contains the trigger endpoint. + +Invoke the function `hello-secret` via invoking the HTTP trigger URL. + +The returned function output should be identical to the value specified in `values.yaml` under `secret-values`->`sec1`->`rv.json`->`Info`->`Success` + + +## License +Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. +This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the [LICENSE file](../LICENSE.txt). \ No newline at end of file diff --git a/examples/hello-config/data/rv.json b/examples/hello-config/data/rv.json new file mode 100644 index 0000000..b1a7e90 --- /dev/null +++ b/examples/hello-config/data/rv.json @@ -0,0 +1,10 @@ +{ + "Info": { + "Success": "Demo", + "Failure": "Todo" + }, + "Code": { + "Success": "A", + "Failure": "X" + } +} \ No newline at end of file diff --git a/examples/hello-config/data/text b/examples/hello-config/data/text new file mode 100644 index 0000000..c57eff5 --- /dev/null +++ b/examples/hello-config/data/text @@ -0,0 +1 @@ +Hello World! \ No newline at end of file diff --git a/examples/hello-config/faas.json b/examples/hello-config/faas.json new file mode 100644 index 0000000..86a62e9 --- /dev/null +++ b/examples/hello-config/faas.json @@ -0,0 +1,25 @@ +{ + "project": "hello-config", + "version": "0.0.1", + "runtime": "nodejs10", + "library": "./lib", + "configs": { + "cfg1": { + "source": "./data" + } + }, + "functions": { + "hello-config": { + "module": "index.js", + "configs": [ + "cfg1" + ] + } + }, + "triggers": { + "demo-config": { + "type": "HTTP", + "function": "hello-config" + } + } +} \ No newline at end of file diff --git a/examples/hello-config/lib/index.js b/examples/hello-config/lib/index.js new file mode 100644 index 0000000..fa67948 --- /dev/null +++ b/examples/hello-config/lib/index.js @@ -0,0 +1,17 @@ +'use strict'; +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ + +/** + * @param {Faas.Event} event + * @param {Faas.Context} context + * @return {Promise<*>} + */ +module.exports = async function (event, context) { + const text = await context.getConfigValueString('cfg1', 'text'); + const rval = await context.getConfigValueJSON('cfg1', 'rv.json'); + return rval.Info.Success; +}; diff --git a/examples/hello-config/package.json b/examples/hello-config/package.json new file mode 100644 index 0000000..0421300 --- /dev/null +++ b/examples/hello-config/package.json @@ -0,0 +1,26 @@ +{ + "name": "example", + "version": "1.0.0", + "keywords": [ + "faas", + "example" + ], + "engines": { + "node": ">=8.11.3" + }, + "dependencies": {}, + "devDependencies": { + "@sap/faas": ">=0.7.0", + "mocha": "=7.0.0" + }, + "files": [ + "data", + "lib", + "faas.json", + "package.json" + ], + "scripts": { + "test": "npm run all-tests", + "all-tests": "node ./node_modules/mocha/bin/_mocha test/**/test*.js --colors -csdlJson --slow 200" + } +} diff --git a/examples/hello-config/test/mock/values.yaml b/examples/hello-config/test/mock/values.yaml new file mode 100644 index 0000000..68eb300 --- /dev/null +++ b/examples/hello-config/test/mock/values.yaml @@ -0,0 +1,5 @@ +config-values: + cfg1: + rv.json: + Info: + Success: Nice Test! diff --git a/examples/hello-config/test/unit/test-hello-secret.js b/examples/hello-config/test/unit/test-hello-secret.js new file mode 100644 index 0000000..cdeb412 --- /dev/null +++ b/examples/hello-config/test/unit/test-hello-secret.js @@ -0,0 +1,74 @@ +/*jshint mocha:true*/ +'use strict'; + +const assert = require('assert'); +const faas = require('@sap/faas'); + +describe('hello secret example', () => { + + // ************************************************************************************************ + + it('using default values', (done) => { + faas.test(done, + { + }, + async (context) => { + const result = await context.callFunction('hello-config', {}); + assert.equal(result.type, 'text/plain; charset=utf-8'); + assert.equal(result.data, 'Demo'); + } + ); + }); + + // ************************************************************************************************ + + it('using deploy values', (done) => { + faas.test(done, + { + 'deploy-values': '../mock/values.yaml' + }, + async (context) => { + const result = await context.callFunction('hello-config', {}); + assert.equal(result.type, 'text/plain; charset=utf-8'); + assert.equal(result.data, 'Nice Test!'); + } + ); + }); + + // ************************************************************************************************ + + it('read config text', (done) => { + faas.test(done, + { + }, + async (context) => { + assert.equal(await context.getConfigValueString('cfg1', 'text'), 'Hello World!'); + } + ); + }); + + // ************************************************************************************************ + + it('read config json', (done) => { + faas.test(done, + { + }, + async (context) => { + assert.deepStrictEqual(await context.getConfigValueJSON('cfg1', 'rv.json'), { + "Info": { + "Success": "Demo", + "Failure": "Todo" + }, + "Code": { + "Success": "A", + "Failure": "X" + } + }); + } + ); + }); + + // ************************************************************************************************ + +}); + diff --git a/examples/hello-oauth-xsuaa/README.md b/examples/hello-oauth-xsuaa/README.md index b592d91..40f1169 100644 --- a/examples/hello-oauth-xsuaa/README.md +++ b/examples/hello-oauth-xsuaa/README.md @@ -38,9 +38,9 @@ Once you have retrieved the token, the HTTP trigger URL can be retrieved from: ```bash xfsrt-cli faas project get hello-oauth-xsuaa ``` -The `artifacts` array contains an object with the URL in its `name` property (and a `reference` to HTTP trigger `trig-oauth`). +The output contains the trigger endpoint. -Call the function using the endpoint with the token: +Call the function `fun-oauth-xsuaa` using the endpoint with the token: ``` GET diff --git a/examples/hello-oauth-xsuaa/lib/index.js b/examples/hello-oauth-xsuaa/lib/index.js index 92d102d..2936612 100644 --- a/examples/hello-oauth-xsuaa/lib/index.js +++ b/examples/hello-oauth-xsuaa/lib/index.js @@ -1,8 +1,9 @@ 'use strict'; -/** -* @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ const auth = require('./auth'); diff --git a/examples/hello-oauth/README.md b/examples/hello-oauth/README.md index c9682d0..182783f 100644 --- a/examples/hello-oauth/README.md +++ b/examples/hello-oauth/README.md @@ -34,11 +34,7 @@ Update the generated file with the public key you generated above. And finally, ``` ### Test -The HTTP trigger URL can be retrieved from: -```bash -xfsrt-cli faas project get hello-oauth -``` -The `artifacts` array contains an object with the URL in its `name` property (and a `reference` to HTTP trigger `trig-oauth`) +The output received after executing the [deployment](#Deployment) step contains the trigger URL. Setup your HTTP request according to this to trigger the function: ``` @@ -48,7 +44,7 @@ Authorization: Bearer Check the function log on the command line ```bash -xfsrt-cli faas project logs -n hello-oauth --functions fun-oauth +xfsrt-cli faas project logs hello-oauth --functions fun-oauth ``` The output should contain the token payload. diff --git a/examples/hello-oauth/lib/index.js b/examples/hello-oauth/lib/index.js index ef733d8..50a792b 100644 --- a/examples/hello-oauth/lib/index.js +++ b/examples/hello-oauth/lib/index.js @@ -1,8 +1,9 @@ 'use strict'; -/** -* @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ const auth = require('./auth'); diff --git a/examples/hello-secret/README.md b/examples/hello-secret/README.md index f2db450..277164f 100644 --- a/examples/hello-secret/README.md +++ b/examples/hello-secret/README.md @@ -14,11 +14,7 @@ Update the generated file. And finally, deploy the project as usual: ``` ### Test -The HTTP trigger URL can be retrieved from: -``` -xfsrt-cli faas project get hello-secret -``` -The `artifacts` array contains an object with the URL in its `name` property (and a `reference` to HTTP trigger `demo`) +The output received after executing the [deployment](#Deployment) step contains the trigger URL. Invoke the function `hello-secret` via invoking the HTTP trigger URL. diff --git a/examples/hello-secret/lib/index.js b/examples/hello-secret/lib/index.js index 0bc73d9..2aac0e1 100644 --- a/examples/hello-secret/lib/index.js +++ b/examples/hello-secret/lib/index.js @@ -1,8 +1,9 @@ 'use strict'; -/** -* @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ /** * @param {Faas.Event} event diff --git a/examples/hello-timer/README.md b/examples/hello-timer/README.md index 8bd1471..3b388d1 100644 --- a/examples/hello-timer/README.md +++ b/examples/hello-timer/README.md @@ -12,11 +12,11 @@ The function is triggered by the timers `timer1`, `timer2`, `timer3` and logs th ## Test In order to verify that the function `hello-timer` is invoked according to the configurations of the three timer triggers, view the logs using: ``` -xfsrt-cli faas project logs -n hello-timer --functions hello-timer +xfsrt-cli faas project logs --functions hello-timer ``` Expected result: -* You should be able to see that e.g. `timer1` causes log entries of format `"/faas/timer/timer1 ` to be written every 15 seconds. +* You should be able to see that e.g. `timer1` causes log entries of format `"/default/sap.xfs.faas/timer1 ` to be written every 15 seconds. ## License Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. diff --git a/examples/hello-timer/lib/index.js b/examples/hello-timer/lib/index.js index 0bc2a9f..99b842d 100644 --- a/examples/hello-timer/lib/index.js +++ b/examples/hello-timer/lib/index.js @@ -1,8 +1,9 @@ 'use strict'; -/** -* @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ /** * @param {Faas.Event} event diff --git a/examples/kafka-producer/lib/index.js b/examples/kafka-producer/lib/index.js index 0a8e517..dd52f7c 100644 --- a/examples/kafka-producer/lib/index.js +++ b/examples/kafka-producer/lib/index.js @@ -1,8 +1,9 @@ 'use strict'; -/** -* @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ const { Kafka } = require('kafkajs'); diff --git a/examples/qrcode-producer/README.md b/examples/qrcode-producer/README.md index f8e797b..46e0352 100644 --- a/examples/qrcode-producer/README.md +++ b/examples/qrcode-producer/README.md @@ -6,15 +6,11 @@ The QR code is displayed in a browser window. ## Deployment Deploy the project: ```bash - xfsrt-cli faas project deploy -y ./deploy/values.yaml -v + xfsrt-cli faas project deploy ``` ## Test -The HTTP trigger URL can be retrieved from: -``` -xfsrt-cli faas project get qrcode-prodcuer -``` -The `artifacts` array contains an object with the URL in its `name` property (and a `reference` to the HTTP trigger `build-qrcode`) +The output received after executing the [deployment](#Deployment) step contains the trigger endpoint. Invoke the function `build-qrcode` via invoking the HTTP trigger URL. diff --git a/examples/qrcode-producer/lib/iso-time.js b/examples/qrcode-producer/lib/iso-time.js index 5fe1605..c54835e 100644 --- a/examples/qrcode-producer/lib/iso-time.js +++ b/examples/qrcode-producer/lib/iso-time.js @@ -1,4 +1,9 @@ 'use strict'; +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ const qr = require('qrcode'); diff --git a/examples/s3uploader/README.md b/examples/s3uploader/README.md new file mode 100644 index 0000000..88158a0 --- /dev/null +++ b/examples/s3uploader/README.md @@ -0,0 +1,33 @@ +# AWS S3 - Uploader +In this example, an uploader function is deployed. It is triggered by an HTTP trigger, extracts the payload from the request body which it then uploads to a configurable S3 bucket with a timestamp of the current time as its key. + + +## Requirements +* Access/Credentials for an Amazon Web Services (AWS) S3 bucket, either through a custom account or by using the [`SAP Object Store`](https://help.sap.com/viewer/2ee77ef7ea4648f9ab2c54ee3aef0a29/Cloud/en-US/84eb69a421294ba0a407579490413dfa.html). + +## Deployment +First, create a deployment file to provide credentials. + +Run inside the project directory: +```bash +faas-sdk init-values -y values.yaml +``` +Update the generated file. +Make the following adjustment: + * specify the account credentials for the S3 bucket `s3`->`credentials.json`. + + +Finally, deploy the project as usual. +Run inside the project directory: +```bash +xfsrt-cli faas project deploy -y ./deploy/values.yaml -v +``` + +### Test +The output received after executing the [deployment](#Deployment) step contains the trigger URL. + +Invoke the function `uploader` via HTTP POST request with the HTTP trigger URL, using e.g. `cURL`: +```bash +curl --header "Content-Type: application/json" --request POST --data '{"hello":"world"}' +``` +The output should be a JSON containing metadata information about the S3 upload. diff --git a/examples/s3uploader/data/s3/credentials.json b/examples/s3uploader/data/s3/credentials.json new file mode 100644 index 0000000..9935dcb --- /dev/null +++ b/examples/s3uploader/data/s3/credentials.json @@ -0,0 +1,9 @@ +{ + "bucket": "x", + "access_key_id": "x", + "secret_access_key": "x", + "host": "x", + "region": "x", + "uri": "x", + "username": "x" +} \ No newline at end of file diff --git a/examples/s3uploader/faas.json b/examples/s3uploader/faas.json new file mode 100644 index 0000000..ac4f847 --- /dev/null +++ b/examples/s3uploader/faas.json @@ -0,0 +1,25 @@ +{ + "project": "aws-uploader", + "version": "0.0.1", + "runtime": "nodejs8", + "library": "./lib", + "secrets": { + "s3": { + "source": "./data/s3" + } + }, + "functions": { + "uploader": { + "module": "index.js", + "secrets": [ + "s3" + ] + } + }, + "triggers": { + "uploader-trigger": { + "type": "HTTP", + "function": "uploader" + } + } +} \ No newline at end of file diff --git a/examples/s3uploader/lib/index.js b/examples/s3uploader/lib/index.js new file mode 100644 index 0000000..9e2f07f --- /dev/null +++ b/examples/s3uploader/lib/index.js @@ -0,0 +1,48 @@ +'use strict'; +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ + +const AWS = require('aws-sdk'); + +/** + * @param {Faas.Event} event + * @param {Faas.Context} context + * @return {Promise} + */ +module.exports = async function (event, context) { + + let credentials = await context.getSecretValueJSON('s3', 'credentials.json'); + + let s3 = new AWS.S3({ + accessKeyId: credentials.access_key_id, + secretAccessKey: credentials.secret_access_key + }); + + // let body = (event.data && typeof event.data === 'object') ? JSON.stringify(event.data) : event.data; + const contentType = event.getContentType(); + let body; + switch (contentType) { + case 'application/json': + body = JSON.stringify(event.data); + break; + case 'text/plain': + body = event.data; + break; + default: + body = Buffer.from(event.data, 'binary'); + } + let params = { + Bucket: credentials.bucket, + Key: Date.now().toString(), + Body: body, + }; + try { + return await s3.upload(params).promise(); + } catch (e) { + console.log(e); + return e; + } +}; \ No newline at end of file diff --git a/examples/s3uploader/package.json b/examples/s3uploader/package.json new file mode 100644 index 0000000..4460956 --- /dev/null +++ b/examples/s3uploader/package.json @@ -0,0 +1,27 @@ +{ + "name": "example", + "version": "0.0.1", + "keywords": [ + "faas", + "example" + ], + "engines": { + "node": ">=8.12.0" + }, + "dependencies": { + "aws-sdk": "^2.553.0" + }, + "devDependencies": { + "@sap/faas": "^0.7.2", + "jsdoc": "=3.6.2" + }, + "files": [ + "lib", + "faas.json", + "package.json" + ], + "scripts": { + "test": "npm run all-tests", + "all-tests": "node ./node_modules/mocha/bin/_mocha test/**/test*.js --colors -csdlJson --slow 200" + } +} diff --git a/examples/s4sdk/README.md b/examples/s4sdk/README.md index 9f2baa1..1bb8c56 100644 --- a/examples/s4sdk/README.md +++ b/examples/s4sdk/README.md @@ -25,11 +25,7 @@ xfsrt-cli faas project deploy -y ./deploy/values.yaml -v ``` ### Test -The HTTP trigger URL can be retrieved from: -``` -xfsrt-cli faas project get s4sdk-business-partner -``` -The `artifacts` array contains an object with the URL in its `name` property (and a `reference` to HTTP trigger `s4sdk-business-partner`) +The output received after executing the [deployment](#Deployment) step contains the trigger URL. Invoke the function `s4sdk-business-partner` via invoking the HTTP trigger URL. diff --git a/examples/s4sdk/lib/handler.js b/examples/s4sdk/lib/handler.js index 328b11a..c6ef6b6 100644 --- a/examples/s4sdk/lib/handler.js +++ b/examples/s4sdk/lib/handler.js @@ -1,7 +1,9 @@ 'use strict'; -/** @typedef {import("@sap/faas").Faas.Event} Faas.Event -* @typedef {import("@sap/faas").Faas.Context} Faas.Context -*/ +/** + * @namespace Faas + * @typedef {import("@sap/faas").Faas.Event} Faas.Event + * @typedef {import("@sap/faas").Faas.Context} Faas.Context + */ const { BusinessPartner } = require('@sap/cloud-sdk-vdm-business-partner-service'); diff --git a/examples/slack-classify-image/README.md b/examples/slack-classify-image/README.md index 99f1ba5..8b854a8 100644 --- a/examples/slack-classify-image/README.md +++ b/examples/slack-classify-image/README.md @@ -30,7 +30,7 @@ The HTTP trigger URL can be retrieved from: ``` xfsrt-cli faas project get slack ``` -The `artifacts` array contains an object with the URL in its `name` property (and a `reference` to HTTP trigger `slack-handler`) +The output contains the trigger URL. ## Test Install the Slack application to your workspace. In Slack, create a channel. Invite the bot to your channel. diff --git a/examples/weather/advanced_ui/README.md b/examples/weather/advanced_ui/README.md index dc1229b..5a84940 100644 --- a/examples/weather/advanced_ui/README.md +++ b/examples/weather/advanced_ui/README.md @@ -23,14 +23,9 @@ Update the generated file with your API key. And finally, deploy the project as The deployment contains two functions with each of them having an HTTP trigger attached: `getweather` which is triggered by the `GET` request of the start page, `postweather` for the `POST` request when the form is submitted. ### Test +The output received after executing the [deployment](#Deployment) step contains the trigger URLs. -The HTTP trigger URLs for the the functions can be retrieved from: -``` -xfsrt-cli faas project get weather -``` -The `artifacts` array contains two objects with the respective URL in the `name` property (and a `reference` to HTTP triggers `post` and `get`, respectively) - -Copy the URL of the `post` trigger. Update your configuration in [values.yaml](.deploy/values.yaml) and with the URL. +Copy the URL of the `post` trigger. Update your configuration in [values.yaml](.deploy/values.yaml) with the URL. Re-deploy the project. diff --git a/examples/weather/basic_ui/README.md b/examples/weather/basic_ui/README.md index 408f496..eb39de5 100644 --- a/examples/weather/basic_ui/README.md +++ b/examples/weather/basic_ui/README.md @@ -23,12 +23,7 @@ Update the generated file with your API key. And finally, deploy the project as The deployment contains two functions with each of them having an HTTP trigger attached: `getweather` which is triggered by the `GET` request of the start page, `postweather` for the `POST` request when the form is submitted. ### Test - -The HTTP trigger URLs for the the functions can be retrieved from: -``` -xfsrt-cli faas project get weather -``` -The `artifacts` array contains two objects with the respective URL in the `name` property (and a `reference` to HTTP triggers `post` and `get`, respectively) +The output received after executing the [deployment](#Deployment) step contains the trigger URLs. Copy the URL of the `post` trigger. Navigate to [HTML template file](./lib/views/index.ejs) and paste the URL as the value of the `action` attribute inside the `form` tag.