Skip to content

Commit

Permalink
Add inline hint how to switch to mjs syntax (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiatekus authored May 10, 2024
1 parent a41f55f commit 152cedb
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions config/serverless/templates/busola-serverless-extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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'];
Expand Down Expand Up @@ -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`
Expand Down

0 comments on commit 152cedb

Please sign in to comment.