mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
new linting, make sure code is type safe
This commit is contained in:
@@ -7,7 +7,7 @@ const port = 3081;
|
||||
const ES_ENDPOINT_ROOT = '/es/';
|
||||
const ES_LOG_ENDPOINT = ES_ENDPOINT_ROOT + 'log';
|
||||
|
||||
const INTERVAL = 2000;
|
||||
const INTERVAL = 1000;
|
||||
|
||||
function pad(number) {
|
||||
var r = String(number);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"@msgpack/msgpack": "^2.8.0",
|
||||
"compression": "^1.7.4",
|
||||
"express": "^4.19.2",
|
||||
"itty-router": "^5.0.15",
|
||||
"itty-router": "^5.0.16",
|
||||
"multer": "^1.4.5-lts.1"
|
||||
},
|
||||
"packageManager": "yarn@4.1.1",
|
||||
|
||||
@@ -2293,8 +2293,6 @@ const emsesp_deviceentities_4 = [
|
||||
|
||||
// END DATA
|
||||
|
||||
// ROUTING STARTS HERE
|
||||
|
||||
// LOG
|
||||
router
|
||||
.post(FETCH_LOG_ENDPOINT, () => {
|
||||
@@ -2303,6 +2301,7 @@ router
|
||||
.get(LOG_SETTINGS_ENDPOINT, () => log_settings)
|
||||
.post(LOG_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
log_settings = await request.json();
|
||||
console.log('log settings saved', log_settings);
|
||||
return status(200);
|
||||
});
|
||||
|
||||
@@ -2326,6 +2325,7 @@ router
|
||||
})
|
||||
.post(NETWORK_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
network_settings = await request.json();
|
||||
console.log('network settings saved', network_settings);
|
||||
return status(200);
|
||||
});
|
||||
|
||||
@@ -2335,6 +2335,7 @@ router
|
||||
.get(AP_STATUS_ENDPOINT, () => ap_status)
|
||||
.post(AP_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
ap_settings = await request.json();
|
||||
console.log('ap settings saved', ap_settings);
|
||||
return status(200);
|
||||
});
|
||||
|
||||
@@ -2343,6 +2344,7 @@ router
|
||||
.get(OTA_SETTINGS_ENDPOINT, () => ota_settings)
|
||||
.post(OTA_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
ota_settings = await request.json();
|
||||
console.log('ota settings saved', ota_settings);
|
||||
return status(200);
|
||||
});
|
||||
|
||||
@@ -2352,6 +2354,7 @@ router
|
||||
.get(MQTT_STATUS_ENDPOINT, () => mqtt_status)
|
||||
.post(MQTT_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
mqtt_settings = await request.json();
|
||||
console.log('mqtt settings saved', mqtt_settings);
|
||||
return status(200);
|
||||
});
|
||||
|
||||
@@ -2362,6 +2365,7 @@ router
|
||||
.post(TIME_ENDPOINT, () => status(200))
|
||||
.post(NTP_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
ntp_settings = await request.json();
|
||||
console.log('ntp settings saved', ntp_settings);
|
||||
return status(200);
|
||||
});
|
||||
|
||||
@@ -2373,6 +2377,7 @@ router
|
||||
.get(SECURITY_SETTINGS_ENDPOINT, () => security_settings)
|
||||
.post(SECURITY_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
security_settings = await request.json();
|
||||
console.log('security settings saved', security_settings);
|
||||
return status(200);
|
||||
})
|
||||
.get(VERIFY_AUTHORIZATION_ENDPOINT, () => verify_authentication)
|
||||
@@ -2442,8 +2447,9 @@ router
|
||||
.get(EMSESP_SETTINGS_ENDPOINT, () => settings)
|
||||
.post(EMSESP_SETTINGS_ENDPOINT, async (request: any) => {
|
||||
settings = await request.json();
|
||||
console.log('settings saved', settings);
|
||||
status(200); // no restart needed
|
||||
status(205); // restart needed
|
||||
// status(205); // restart needed
|
||||
})
|
||||
|
||||
// Device Dashboard Data
|
||||
@@ -2482,6 +2488,7 @@ router
|
||||
updateMask(entity, emsesp_deviceentities_6, emsesp_devicedata_6);
|
||||
}
|
||||
}
|
||||
console.log('customization saved', content);
|
||||
return status(200);
|
||||
})
|
||||
.post(EMSESP_RESET_CUSTOMIZATIONS_ENDPOINT, async (request: any) => {
|
||||
@@ -2492,6 +2499,7 @@ router
|
||||
.post(EMSESP_SCHEDULE_ENDPOINT, async (request: any) => {
|
||||
const content = await request.json();
|
||||
emsesp_schedule = content;
|
||||
console.log('schedule saved', emsesp_schedule);
|
||||
return status(200);
|
||||
})
|
||||
.get(EMSESP_SCHEDULE_ENDPOINT, () => emsesp_schedule)
|
||||
@@ -2500,6 +2508,7 @@ router
|
||||
.post(EMSESP_CUSTOMENTITIES_ENDPOINT, async (request: any) => {
|
||||
const content = await request.json();
|
||||
emsesp_customentities = content;
|
||||
console.log('custom entities saved', emsesp_customentities);
|
||||
return status(200);
|
||||
})
|
||||
.get(EMSESP_CUSTOMENTITIES_ENDPOINT, () => emsesp_customentities)
|
||||
@@ -2547,6 +2556,7 @@ router
|
||||
}
|
||||
|
||||
// await delay(1000); // wait to show spinner
|
||||
console.log('device value saved', content);
|
||||
return status(200);
|
||||
})
|
||||
|
||||
@@ -2558,6 +2568,7 @@ router
|
||||
emsesp_sensordata.ts[objIndex].n = ts.name;
|
||||
emsesp_sensordata.ts[objIndex].o = ts.offset;
|
||||
}
|
||||
console.log('temp sensor saved', ts);
|
||||
return status(200);
|
||||
})
|
||||
.post(EMSESP_WRITE_ANALOGSENSOR_ENDPOINT, async (request: any) => {
|
||||
@@ -2590,6 +2601,7 @@ router
|
||||
emsesp_sensordata.as[objIndex].t = as.type;
|
||||
}
|
||||
}
|
||||
console.log('analog sensor saved', as);
|
||||
|
||||
return status(200);
|
||||
})
|
||||
@@ -2723,6 +2735,7 @@ router
|
||||
data.eth_clock_mode = 0;
|
||||
}
|
||||
|
||||
console.log('board profile saved', data);
|
||||
return data;
|
||||
})
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ __metadata:
|
||||
"@types/multer": "npm:^1.4.11"
|
||||
compression: "npm:^1.7.4"
|
||||
express: "npm:^4.19.2"
|
||||
itty-router: "npm:^5.0.15"
|
||||
itty-router: "npm:^5.0.16"
|
||||
multer: "npm:^1.4.5-lts.1"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -526,10 +526,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"itty-router@npm:^5.0.15":
|
||||
version: 5.0.15
|
||||
resolution: "itty-router@npm:5.0.15"
|
||||
checksum: 10/ab437c33a9888f022ee465d3ab62a9434556eae493da1c4154a2621b746a36cdb6b5a5f417fd7ac631631ead69b95789cba01399936f5b1d8755a73934bb0e54
|
||||
"itty-router@npm:^5.0.16":
|
||||
version: 5.0.16
|
||||
resolution: "itty-router@npm:5.0.16"
|
||||
checksum: 10/114a4f123f27bb5ef5e3ad513a524e885bab3d6a0ba617e620cbaf9633ac24b38553a49b742dca59f9bf27797582ed2b097754e49d354ebbbf3d4103a6f60bd5
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user