feat(core): Add permission-controlled Deno execution, configurable script server port, improved downloader, dependency bumps and test updates
This commit is contained in:
@@ -1,17 +1,30 @@
|
||||
import type { DenoExecution } from './classes.denoexecution.js';
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export interface IScriptServerOptions {
|
||||
port?: number;
|
||||
}
|
||||
|
||||
export class ScriptServer {
|
||||
private server: plugins.typedserver.servertools.Server;
|
||||
public smartshellInstance = new plugins.smarthshell.Smartshell({
|
||||
private port: number;
|
||||
public smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
|
||||
public executionMap = new plugins.lik.ObjectMap<DenoExecution>();
|
||||
|
||||
constructor(options: IScriptServerOptions = {}) {
|
||||
this.port = options.port ?? 3210;
|
||||
}
|
||||
|
||||
public getPort(): number {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public async start() {
|
||||
this.server = new plugins.typedserver.servertools.Server({
|
||||
port: 3210,
|
||||
port: this.port,
|
||||
cors: true,
|
||||
});
|
||||
this.server.addRoute(
|
||||
@@ -20,12 +33,24 @@ export class ScriptServer {
|
||||
const executionId = req.params.executionId;
|
||||
const denoExecution = await this.executionMap.find(async denoExecutionArg => {
|
||||
return denoExecutionArg.id === executionId;
|
||||
})
|
||||
});
|
||||
if (!denoExecution) {
|
||||
res.statusCode = 404;
|
||||
res.write('Execution not found');
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
res.write(denoExecution.script);
|
||||
res.end();
|
||||
})
|
||||
);
|
||||
await this.server.start();
|
||||
}
|
||||
public async stop() {}
|
||||
|
||||
public async stop() {
|
||||
if (this.server) {
|
||||
await this.server.stop();
|
||||
}
|
||||
this.executionMap.wipe();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user