调试脚本增加停止,修复调试交互

This commit is contained in:
whyour
2021-12-23 23:25:39 +08:00
parent a29392bb08
commit 2e6ca5419d
4 changed files with 87 additions and 12 deletions
+26
View File
@@ -266,4 +266,30 @@ export default (app: Router) => {
}
},
);
route.put(
'/stop',
celebrate({
body: Joi.object({
filename: Joi.string().required(),
path: Joi.string().optional().allow(''),
}),
}),
async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger');
try {
let { filename, path } = req.body as {
filename: string;
path: string;
};
const filePath = join(path, filename);
const scriptService = Container.get(ScriptService);
const result = await scriptService.stopScript(filePath);
res.send(result);
} catch (e) {
logger.error('🔥 error: %o', e);
return next(e);
}
},
);
};