Merge branch 'develop' into feat/dev-settings

This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-06-21 18:00:23 +08:00
commit b77f05709b
8 files changed
+238 -14

No files matched your search

+37 -1
View File
@@ -681,7 +681,7 @@ class MonitorController {
explain,
});
return res.success({
msg: "OK", // TODO
msg: "OK",
data: result,
});
} catch (error) {
@@ -698,6 +698,42 @@ class MonitorController {
next(handleError(error, SERVICE_NAME, "seedDb"));
}
};
exportMonitorsToCSV = async (req, res, next) => {
try {
const { teamId } = req.user;
const monitors = await this.db.getMonitorsByTeamId({ teamId });
if (!monitors || monitors.length === 0) {
return res.success({
msg: this.stringService.noMonitorsFound,
data: null,
});
}
const csvData = monitors?.filteredMonitors?.map((monitor) => ({
name: monitor.name,
description: monitor.description,
type: monitor.type,
url: monitor.url,
interval: monitor.interval,
port: monitor.port,
ignoreTlsErrors: monitor.ignoreTlsErrors,
isActive: monitor.isActive,
}));
const csv = pkg.unparse(csvData);
return res.file({
data: csv,
headers: {
"Content-Type": "text/csv",
"Content-Disposition": "attachment; filename=monitors.csv",
},
});
} catch (error) {
next(handleError(error, SERVICE_NAME, "exportMonitorsToCSV"));
}
};
}
export default MonitorController;