Skip to content

Instantly share code, notes, and snippets.

@leifermendez
Created June 4, 2025 17:18
Show Gist options
  • Save leifermendez/c7b22c9bba8830a3d27f92435ae451a3 to your computer and use it in GitHub Desktop.
Save leifermendez/c7b22c9bba8830a3d27f92435ae451a3 to your computer and use it in GitHub Desktop.
project.web.js
/************
.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