smartdeno/ts/classes.scriptserver.ts

32 lines
969 B
TypeScript
Raw Normal View History

2024-03-17 20:24:25 +00:00
import type { DenoExecution } from './classes.denoexecution.js';
import * as plugins from './plugins.js';
export class ScriptServer {
private server: plugins.typedserver.servertools.Server;
public smartshellInstance = new plugins.smarthshell.Smartshell({
executor: 'bash'
});
public executionMap = new plugins.lik.ObjectMap<DenoExecution>();
public async start() {
this.server = new plugins.typedserver.servertools.Server({
port: 3210,
cors: true,
});
this.server.addRoute(
'/getscript/:executionId',
new plugins.typedserver.servertools.Handler('GET', async (req, res) => {
const executionId = req.params.executionId;
const denoExecution = await this.executionMap.find(async denoExecutionArg => {
return denoExecutionArg.id === executionId;
})
res.write(denoExecution.script);
res.end();
})
);
await this.server.start();
}
public async stop() {}
}