feat: inject _update_ts into all JSON responses for global OTA updates

This commit is contained in:
2026-07-11 11:17:07 +08:00
parent 6d0596f614
commit 74b9754b7d
3 changed files with 102 additions and 1 deletions
+8
View File
@@ -19,6 +19,14 @@ app.use((req, res, next) => {
const origJson = res.json.bind(res);
res.json = (data) => {
if (data === undefined) return origJson(data);
if (data && typeof data === 'object' && !Array.isArray(data)) {
const cfg = DataService.getConfig && DataService.getConfig();
if (cfg && cfg.update_timestamp) {
data._update_ts = cfg.update_timestamp;
}
}
const body = jsonStringifyUnicode(data);
res.set('Content-Type', 'application/json; charset=utf-8');
return res.send(body);