Add support to switch between deno and nodejs function executor
This commit is contained in:
@@ -6,6 +6,7 @@ const Editor = {
|
||||
this.isPublic = vnode.attrs.isPublic || false;
|
||||
this.logRequest = vnode.attrs.logRequest || false;
|
||||
this.logResponse = vnode.attrs.logResponse || false;
|
||||
this.runtime = vnode.attrs.runtime || "node"; // Add runtime
|
||||
|
||||
// Only controls whether the name/version is shown (left side of header),
|
||||
// but we still always show the Execute button on the right side.
|
||||
@@ -119,7 +120,11 @@ const Editor = {
|
||||
const resp = await fetch(this.executeUrl, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ code, environment_info }),
|
||||
body: JSON.stringify({
|
||||
code,
|
||||
environment_info,
|
||||
runtime: this.runtime,
|
||||
}),
|
||||
});
|
||||
if (!resp.ok) {
|
||||
throw new Error(`HTTP error! status: ${resp.status}`);
|
||||
@@ -149,6 +154,7 @@ const Editor = {
|
||||
is_public: this.isPublic,
|
||||
log_request: this.logRequest,
|
||||
log_response: this.logResponse,
|
||||
runtime: this.runtime,
|
||||
};
|
||||
|
||||
// Create payload based on whether this is a timer function
|
||||
@@ -172,6 +178,7 @@ const Editor = {
|
||||
is_public: this.isPublic,
|
||||
log_request: this.logRequest,
|
||||
log_response: this.logResponse,
|
||||
runtime: this.runtime,
|
||||
};
|
||||
|
||||
const response = await m.request({
|
||||
@@ -513,6 +520,39 @@ const Editor = {
|
||||
m("div", { class: "flex flex-col space-y-4" }, [
|
||||
// Toggles group
|
||||
m("div", { class: "flex flex-wrap gap-6" }, [
|
||||
// Runtime dropdown
|
||||
m("div", { class: "flex flex-col" }, [
|
||||
m(
|
||||
"label",
|
||||
{
|
||||
for: "runtime-select",
|
||||
class: "mb-2 text-sm font-medium",
|
||||
},
|
||||
"Runtime"
|
||||
),
|
||||
m(
|
||||
"select",
|
||||
{
|
||||
id: "runtime-select",
|
||||
class:
|
||||
"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",
|
||||
onchange: (e) => (this.runtime = e.target.value),
|
||||
},
|
||||
[
|
||||
m(
|
||||
"option",
|
||||
{ value: "node", selected: this.runtime === "node" },
|
||||
"Node.js"
|
||||
),
|
||||
m(
|
||||
"option",
|
||||
{ value: "deno", selected: this.runtime === "deno" },
|
||||
"Deno"
|
||||
),
|
||||
]
|
||||
),
|
||||
]),
|
||||
|
||||
// Public/Private toggle
|
||||
this.showPublicToggle &&
|
||||
m(
|
||||
|
||||
Reference in New Issue
Block a user