This Express server serves as the backend for the nomadPi React Frontend. It provides the needed functionality to handle resources (Switches, batteries, settings etc.) and it also acts as an intermediary to the more low-level APIs nomadPi core and nomadPi automation.
Ensure the following environment variables are set before running the server, preferably through direnv as part of the nomadPi Docker Stack:
ENCRYPTION_KEY: Encryption key for securing sensitive data.DB_HOST,DB_USER,DB_PASSWORD,DB_NAME: Database connection details.
-
Within your nomadPi Docker Stack, clone the repository under
volumes. -
Start the
docker-composestack and access the server at http://raspberrypi.local:3001 (assumingraspberrypiis the host you set for your Pi).
- CORS: Headers set based on allowed domains in
VANPI_APP_API_ALLOWED_DOMAINS. - Forwarding Endpoints: Specific routes forwarded to Van Pi core and Automation APIs.
- Encryption: Sensitive data in the database encrypted and decrypted using
ENCRYPTION_KEY. - Database: Connection details fetched from environment variables. Migrations run on startup.
- nomadPi core API:
POST /relays/stateGET /relays/stateGET /usb_devicesGET /batteries/:connection_type/:device_type/:device_id/state
- nomadPi Automation API:
POST /modes/:mode_keyGET /modes/state
- Settings:
GET /settingsPUT /settings/:setting_key
- CRUD Endpoints:
relayswifi_relaysmodesaction_switchesswitch_groupsbatteries
- Key dependencies:
express,axios,body-parser,express-session,cors,bcrypt,mysql2,knex.