./setup.shThe following environment variables can be used to configure the server (the ones that are mandatory in a production environment are marked with a *):
| Variable | Default | Explanation | Format |
|---|---|---|---|
| SERVER_PORT | 3000 | The port to which bind the web server | Any valid port |
| SERVER_HOST | localhost | The host of the server sent to the devices | Any valid host string |
| DISCOVERY_PORT | 30000 | The port to listen to for device announces | Any valid port |
| MONGO_HOST | localhost | The host on which to find mongodb | Any valid host string |
| MONGO_PORT | 27017 | The port on which to find mongodb | Any valid port |
| *JWT_SECRET | secret | The secret used to sign JWTs | Any non empty string |
- Compiles the code
- Runs
build-client - It runs the server
- Ensures the code compiles
- Runs
build-client - Starts a development docker compose environment with multiple emulated devices
- It runs the server under
nodemon - Stops the development docker compose environment
Subsequent runs will have containers using the same volumes in order to not lose the application state.
The same as start but every time it is executed it will clean container volumes in order to start in a clean state.
Checks if the client is built and ready to be served and if not it launches rebuild-client
Builds the client to be served by the server
Runs eslint
- Ensures the code compiles
- Starts a testing docker compose environment
- It runs tests and computes coverage
- Stops and cleans the testing docker compose enviroment
The same as test but it doesn't compute coverage
Uses prettier to formats the src folder according to .prettierrc.json
Uses prettier to check if the src folder is formatted according to .prettierrc.json
For debugging purposes multiple console logs can be enabled distincively through boolean environment variables:
| Variable | What it does |
|---|---|
| LOG_DEVICE_STATUS_CHANGES | Logs every time a device changes its status (Online/Offline) |
| LOG_REQ_URLS | Logs every request url with the relative http method |
| LOG_REQ_BODIES | Logs every request body |
| LOG_ANNOUNCES | Logs every device announce for discovery |
| BASE_DELAY_MS | Milliseconds of delay to add to every response |
| RANDOM_DELAY_MULTIPLIER_MS | Milliseconds to multiply by a random delay from 0 to 1 (ex: 1000 -> delay between 0 and 1s) to add to every response |