diff --git a/web2/README.md b/web2/README.md new file mode 100644 index 00000000..70d8249d --- /dev/null +++ b/web2/README.md @@ -0,0 +1,35 @@ +# Web UI + +This contains the web UI for espMH. The UI is written with the following stack: + +* Typescript +* React +* Tailwind +* Shadcn/ui +* esbuild + +It compiles everything into C++ header files which are copied to `dist` and included as a part of the platformio build process. + +## Development + +It _should_ be enough to install node v20+ and run: + +```bash +npm run watch +``` + +This will continuously run the build as files change. When I develop, I typically also use the nodejs server: + +```bash +PROXY_URL=http://hostname-of-your-hub node server.js +``` + +I do this only to proxy API requests to an actual ESP8266 running on my local network. + +### API Client + +The API client in `web2/api` is generated from the openapi spec using `openapi-zod-client`. Run it with this command: + +```bash +openapi-zod-client ../docs/openapi.yaml -o ./api/api-zod.ts --with-description +``` \ No newline at end of file diff --git a/web2/server.js b/web2/server.js index 98d5d68f..5f3fbd76 100644 --- a/web2/server.js +++ b/web2/server.js @@ -4,7 +4,7 @@ const path = require('path'); const app = express(); const PORT = 3000; // You can change this to any port you prefer -const PROXY_URL = 'http://10.133.8.88'; // Replace with your proxy URL +const PROXY_URL = process.env.PROXY_URL || 'http://10.133.8.88'; // Replace with your proxy URL const proxyMiddleware = createProxyMiddleware({ target: PROXY_URL,