兼容脚本、日志、配置文件详情接口

This commit is contained in:
whyour
2024-02-08 20:47:03 +08:00
parent 29f0c2c9ac
commit e83058c3bc
5 changed files with 91 additions and 25 deletions
+20 -1
View File
@@ -29,7 +29,6 @@ export default (app: Router) => {
route.get(
'/detail',
async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger');
try {
if (blacklist.includes(req.path)) {
return res.send({ code: 403, message: '暂无权限' });
@@ -47,6 +46,26 @@ export default (app: Router) => {
},
);
route.get(
'/:file',
async (req: Request, res: Response, next: NextFunction) => {
try {
if (blacklist.includes(req.path)) {
return res.send({ code: 403, message: '暂无权限' });
}
const filePath = join(
config.logPath,
(req.query.path || '') as string,
req.params.file,
);
const content = await getFileContentByName(filePath);
res.send({ code: 200, data: content });
} catch (e) {
return next(e);
}
},
);
route.delete(
'/',
celebrate({