feat: inject _update_ts into all JSON responses for global OTA updates
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user