From 4e5dd8e3ec20f2d587af4eabab2b9da4909c265d Mon Sep 17 00:00:00 2001 From: Mark Tripoli Date: Tue, 21 Nov 2023 10:16:00 -0500 Subject: [PATCH] Bump platformVersion to 2023.2 (#19) * Bump to platformVersion 2023.2 * Bump node runtime to 18 * Use async/await * Remove runtime and version * Update example functions to use async --------- Co-authored-by: Camden Phalen Co-authored-by: Hugh McDonald --- components/example-app/app.functions/example-function.js | 8 ++------ components/example-app/app.functions/serverless.json | 2 -- components/example-app/extensions/Example.jsx | 7 +++---- projects/getting-started-template/hsproject.json | 2 +- .../src/app/app.functions/example-function.js | 8 ++------ .../src/app/app.functions/serverless.json | 2 -- .../src/app/extensions/Example.jsx | 7 +++---- projects/no-template/hsproject.json | 2 +- 8 files changed, 12 insertions(+), 26 deletions(-) diff --git a/components/example-app/app.functions/example-function.js b/components/example-app/app.functions/example-function.js index 331668f..3c65f81 100644 --- a/components/example-app/app.functions/example-function.js +++ b/components/example-app/app.functions/example-function.js @@ -1,11 +1,7 @@ -exports.main = (context = {}, sendResponse) => { +exports.main = async (context = {}) => { const { text } = context.parameters; const response = `This is coming from a serverless function! You entered: ${text}`; - try { - sendResponse(response); - } catch (error) { - sendResponse(error); - } + return response; }; diff --git a/components/example-app/app.functions/serverless.json b/components/example-app/app.functions/serverless.json index 488994e..7a37deb 100644 --- a/components/example-app/app.functions/serverless.json +++ b/components/example-app/app.functions/serverless.json @@ -1,6 +1,4 @@ { - "runtime": "nodejs16.x", - "version": "1.0", "appFunctions": { "myFunc": { "file": "example-function.js", diff --git a/components/example-app/extensions/Example.jsx b/components/example-app/extensions/Example.jsx index 1f4c6c8..f6031b1 100644 --- a/components/example-app/extensions/Example.jsx +++ b/components/example-app/extensions/Example.jsx @@ -24,10 +24,9 @@ const Extension = ({ context, runServerless, sendAlert }) => { // Call serverless function to execute with parameters. // The `myFunc` function name is configured inside `serverless.json` - const handleClick = () => { - runServerless({ name: "myFunc", parameters: { text: text } }).then((resp) => - sendAlert({ message: resp.response }) - ); + const handleClick = async () => { + const { response } = await runServerless({ name: "myFunc", parameters: { text: text } }); + sendAlert({ message: response }); }; return ( diff --git a/projects/getting-started-template/hsproject.json b/projects/getting-started-template/hsproject.json index 5afae36..9537762 100644 --- a/projects/getting-started-template/hsproject.json +++ b/projects/getting-started-template/hsproject.json @@ -1,5 +1,5 @@ { "name": "Get Started Project", "srcDir": "src", - "platformVersion": "2023.1" + "platformVersion": "2023.2" } diff --git a/projects/getting-started-template/src/app/app.functions/example-function.js b/projects/getting-started-template/src/app/app.functions/example-function.js index 331668f..3c65f81 100644 --- a/projects/getting-started-template/src/app/app.functions/example-function.js +++ b/projects/getting-started-template/src/app/app.functions/example-function.js @@ -1,11 +1,7 @@ -exports.main = (context = {}, sendResponse) => { +exports.main = async (context = {}) => { const { text } = context.parameters; const response = `This is coming from a serverless function! You entered: ${text}`; - try { - sendResponse(response); - } catch (error) { - sendResponse(error); - } + return response; }; diff --git a/projects/getting-started-template/src/app/app.functions/serverless.json b/projects/getting-started-template/src/app/app.functions/serverless.json index 488994e..7a37deb 100644 --- a/projects/getting-started-template/src/app/app.functions/serverless.json +++ b/projects/getting-started-template/src/app/app.functions/serverless.json @@ -1,6 +1,4 @@ { - "runtime": "nodejs16.x", - "version": "1.0", "appFunctions": { "myFunc": { "file": "example-function.js", diff --git a/projects/getting-started-template/src/app/extensions/Example.jsx b/projects/getting-started-template/src/app/extensions/Example.jsx index 1f4c6c8..f6031b1 100644 --- a/projects/getting-started-template/src/app/extensions/Example.jsx +++ b/projects/getting-started-template/src/app/extensions/Example.jsx @@ -24,10 +24,9 @@ const Extension = ({ context, runServerless, sendAlert }) => { // Call serverless function to execute with parameters. // The `myFunc` function name is configured inside `serverless.json` - const handleClick = () => { - runServerless({ name: "myFunc", parameters: { text: text } }).then((resp) => - sendAlert({ message: resp.response }) - ); + const handleClick = async () => { + const { response } = await runServerless({ name: "myFunc", parameters: { text: text } }); + sendAlert({ message: response }); }; return ( diff --git a/projects/no-template/hsproject.json b/projects/no-template/hsproject.json index 87a5049..6500e08 100644 --- a/projects/no-template/hsproject.json +++ b/projects/no-template/hsproject.json @@ -1,5 +1,5 @@ { "name": "Empty Project", "srcDir": "src", - "platformVersion": "2023.1" + "platformVersion": "2023.2" }