diff --git a/mock-api/README.md b/mock-api/README.md index efc5dcd92..9da932ffd 100644 --- a/mock-api/README.md +++ b/mock-api/README.md @@ -1,40 +1,5 @@ -() +(Based on ) When developing and testing the web interface, it's handy not to bother with re-flashing an ESP32 each time. The idea is to mimic the ESP using a mock/stub server that responds to the REST (HTTP POST & GET) and WebSocket calls. -To set it up it do - -```sh -% cd mock-api -% npm install -% cd interface -% npm install -``` - -and to run it - -```sh -% cd interface -% npm run standalone -``` - -## Notes - -- new file `interface/src/setupProxy.js` -- new files `mock-api/server.js` with the hardcoded data. Requires its own npm packages for express - -## Testing - -```bash -% curl -i http://localhost:3080/rest/emsespSettings -``` - -or from a browser use port 3000 since `setupProxy.js` is redirecting, like http://172.22.227.82:3000/rest/emsespSettings - -http://172.22.227.82:3090/es/log?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWUsInZlcnNpb24iOiIzLjAuMmIwIn0.MsHSgoJKI1lyYz77EiT5ZN3ECMrb4mPv9FNy3udq0TU - -Testing the EventSource/SSE use http://172.22.227.82:3090/es/log - -## To Do - -- add filter rule to prevent from exposing yourself to malicious attacks when running the dev server() +To set it up it do run `npm install` in the `mock-api` folder, then from the `interface` folder run `npm run standalone`. This will start the mock API server on port 3080 using data from `mock-api/server.js` and the web server runs on port 3000. diff --git a/mock-api/server.js b/mock-api/server.js index d6b5686af..96fdb18a3 100644 --- a/mock-api/server.js +++ b/mock-api/server.js @@ -1132,7 +1132,7 @@ rest_server.post(EMSESP_BOARDPROFILE_ENDPOINT, (req, res) => { // EMS-ESP API specific const emsesp_info = { System: { - version: '3.x.x', + version: '3.4.2', uptime: '001+06:40:34.018', 'uptime (seconds)': 110434, freemem: 131, @@ -1224,7 +1224,6 @@ rest_server.get(GET_CUSTOMIZATIONS_ENDPOINT, (req, res) => { // start server const expressServer = rest_server.listen(port, () => - console.log(`Mock server for EMS-ESP is up and running at http://localhost:${port}`), ) console.log(`EMS-ESP Rest API listening to http://localhost:${port}/api`)