Compare commits

...

1 Commits

Author SHA1 Message Date
Bastien OLLIER b646ad576d add build code from requests
continuous-integration/drone/push Build is passing Details
1 year ago

@ -26,10 +26,20 @@ const server = http.createServer((req, res) => {
res.end();
return;
}
const jobId = generateId();
let body: Uint8Array[] = [];
switch (req.url) {
case '/run':
const jobId = generateId();
const code = 'echo a';
req
.on('data', chunk => {
body.push(chunk);
})
.on('end', () => {
let params = JSON.parse(Buffer.concat(body).toString());
const code = params.code;
const image = 'ghcr.io/moshell-lang/moshell:master';
const buffer = Buffer.allocUnsafe(jobId.length + image.length + code.length + 8);
buffer.write(jobId, 0);
@ -48,11 +58,15 @@ const server = http.createServer((req, res) => {
res.write(`data: ${jobId}\n`);
res.write('id: 0\n\n');
});
req.on('close', () => {
//res.end(body);
})
.on('close', () => {
res.end('OK');
delete clients[jobId];
});
clients[jobId] = res;
//res.end()
break;
default:
res.writeHead(404, CORS);

Loading…
Cancel
Save