diff --git a/config/serverless/templates/busola-serverless-extension.yaml b/config/serverless/templates/busola-serverless-extension.yaml index 48c23f8cd..7137688a7 100644 --- a/config/serverless/templates/busola-serverless-extension.yaml +++ b/config/serverless/templates/busola-serverless-extension.yaml @@ -241,10 +241,20 @@ data: defaultExpanded: true subscribe: sourceType: |- - $sourceType = 'Inline' ? $language = 'JavaScript' ? $exists($root.metadata.creationTimestamp) ? $root.spec.source.inline.source : "module.exports = { + $sourceType = 'Inline' ? $language = 'JavaScript' ? $exists($root.metadata.creationTimestamp) ? $root.spec.source.inline.source : "/* + If you prefer mjs import/export syntax over cjs you need to specify + 'type': 'module' + in the Function dependencies (package.json) and along with that change the import/export syntax to: + import foo from 'foo' + export function main(event, context) { + //your logic using foo library + return + } + */ + + module.exports = { main: async function (event, context) { var queryParams = event['extensions']['request']['query']; - //read query param, for example `?greeting=Hi` var greetingMsg = queryParams['greeting']; if(!greetingMsg) { @@ -267,7 +277,18 @@ data: return message" : '' : '' language: |- - $language = 'JavaScript' ? $exists($root.metadata.creationTimestamp) ? $root.spec.source.inline.source : "module.exports = { + $language = 'JavaScript' ? $exists($root.metadata.creationTimestamp) ? $root.spec.source.inline.source : "/* + If you prefer mjs import/export syntax over cjs you need to specify + 'type': 'module' + in the Function dependencies (package.json) and along with that change the import/export syntax to: + import foo from 'foo' + export function main(event, context) { + //your logic using foo library + return + } + */ + + module.exports = { main: async function (event, context) { var queryParams = event['extensions']['request']['query']; @@ -566,6 +587,17 @@ data: source: inline: source: |- + /* + If you prefer mjs import/export syntax over cjs you need to specify + 'type': 'module' + in the Function dependencies (package.json) and along with that change the import/export syntax to: + import foo from 'foo' + export function main(event, context) { + //your logic using foo library + return + } + */ + module.exports = { main: async function (event, context) { const message = `Hello World`