Intenté hacerlo pero me di por vencido... sí, ¿es posible cuando llamas al ejemplo, https:api.domain.com/createfile/(+ data) crea un archivo en ese servidor en la carpeta que quiero si es así, cómo?
Es un archivo javascript que también quiero hacer funcionar y comenzar el proceso. (ejecútelo npm).
Suponiendo que tiene acceso de root en su servidor.
Pasos de inicialización:
npm install express debería funcionarCómo se verá el servidor Express ahora:
const express = require('express'); const shell = require('shelljs') const app = express(); app.post('/createfile/:data', async function (req, res) { if (!req || !req.params || !req.params.data ) { return res.status(400).send("Malformed url"); } // I assume the data in the paramas is the url to the git repo const giturl = req.params.data; // You should probably lightly check the url to make sure its a valid one on the surface level. const path = 'absolute/path/to/folder' if (!shell.which('git')) { shell.echo('Sorry, this script requires git'); shell.exit(1); return res.status(400).send("Not supported"); } shell.cd(path) shell.exec('git clone ' + giturl, function (code, stdout, stderr) { console.log('Exit code:', code); console.log('Program output:', stdout); console.log('Program stderr:', stderr); if (code === 0) return res.status(200).send("Success"); else return res.status(400).send("Issue with clone") }); }); const server = await app.listen(3000);