修复获取sample文件

This commit is contained in:
hanhh
2021-07-03 16:49:02 +08:00
parent 53123af832
commit 5c2bbc941f
2 changed files with 12 additions and 3 deletions
+10 -3
View File
@@ -36,9 +36,16 @@ export default (app: Router) => {
async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger');
try {
const content = getFileContentByName(
`${config.configPath}${req.params.file}`,
);
let content = '';
if (req.params.file.includes('sample')) {
content = getFileContentByName(
`${config.samplePath}${req.params.file}`,
);
} else {
content = getFileContentByName(
`${config.configPath}${req.params.file}`,
);
}
res.send({ code: 200, data: content });
} catch (e) {
logger.error('🔥 error: %o', e);