32 lines
		
	
	
		
			969 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			969 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| 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() {}
 | |
| }
 |