Created
June 4, 2025 17:18
-
-
Save leifermendez/c7b22c9bba8830a3d27f92435ae451a3 to your computer and use it in GitHub Desktop.
project.web.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************ | |
.web.js file | |
************ | |
Backend '.web.js' files contain functions that run on the server side and can be called from page code. | |
Learn more at https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/web-modules/calling-backend-code-from-the-frontend | |
****/ | |
/**** Call the sample multiply function below by pasting the following into your page code: | |
import { multiply } from 'backend/new-module.web'; | |
$w.onReady(async function () { | |
console.log(await multiply(4,5)); | |
}); | |
****/ | |
import { Permissions, webMethod } from "wix-web-module"; | |
export const createProject = webMethod( | |
Permissions.Anyone, | |
async (name, lastname) => { | |
const TOKEN = 'bbc-XXXXXXXXXXXXXXXXXXXXXXX' | |
const ID_PROJECT = 'TU-ID-PROYECTO' | |
const response = await fetch(`https://app.builderbot.cloud/api/v1/manager/project/${ID_PROJECT}/duplicate`,{ | |
method:'POST', | |
headers:{ | |
'Content-Type':'application/json', | |
'x-api-builderbot': TOKEN | |
}, | |
body: JSON.stringify({ | |
name:`${name}_${lastname}` | |
}) | |
}) | |
const data = await response.json() | |
return data.newProject.uuid | |
} | |
); | |
export const deployProject = webMethod( | |
Permissions.Anyone, | |
async (newIdProject) => { | |
const TOKEN = 'bbc-XXXXXXXXXXXXXXXXXXXXXXX' | |
const response = await fetch(`https://app.builderbot.cloud/api/v1/manager/deploys`,{ | |
method:'POST', | |
headers:{ | |
'Content-Type':'application/json', | |
'x-api-builderbot': TOKEN | |
}, | |
body: JSON.stringify({ | |
projectId: newIdProject | |
}) | |
}) | |
const data = await response.json() | |
return data | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment