A REST API for checking out/in devices and seeing current status.
Tested on Ubuntu 18.
- Install node and npm:
sudo apt update sudo apt install -y nodejs npm
- Give node privileges to listen on low ports (like port 80) so it can be the webserver.
sudo setcap 'cap_net_bind_service=+ep' $(readlink -f $(which node))
- Clone this project and install needed libraries:
git clone git@github.com:mbanders/boardfarm_server_api.git cd boardfarm_server_api/ npm install
- You need a mongodb to store data. Specify the username, password, and server hostname as environment variables:
Then specify the mongodb connetion uri in the file
export MONGO_USER="myuser" export MONGO_PASS="mypass" export MONGO_SERVER="myserver"
config.js
:var user = process.env.MONGO_USER var pass = process.env.MONGO_PASS module.exports.mongodb_uri = `mongodb+srv://${user}:${pass}@boardfarm0-mgbyp.mongodb.net/test?retryWrites=true&w=majority`
- Now start the server:
node index.js
- Open a web browser and visit
http://YourServer:Port/api
, be sure to replace "YourServer:Port" with the IP address (or hostname) and port of your server. You should see a message saying "Welcome". - Post your boardfarm configuration JSON file so that stations and devices are stored:
curl -X POST \ -H "Content-Type: application/json" \ -d @boardfarm_config_example.json \ http://YourServer:Port/api/bf_config
- Visit
http://YourServer:Port/api/bf_config
to see the full boardfarm config file you just pushed. You will see some extra keys, that's ok. - Also visit
http://YourServer:Port/api/stations
andhttp://YourServer:port/api/devices
to see the stations and the shareable devices.
See production setup.
All paths begin with /api
.
path | Method | Data Parameters | Response |
---|---|---|---|
/ | GET | - | {"message": "Welcome to Boardfarm REST API","version": "X.Y.Z"} |
/bf_config | GET | - | A JSON document formatted for for bft |
/stations | GET | - | A JSON document describing all stations |
/stations/<name> | GET | - | A JSON document describing the station with a given name |
/stations/<name> | POST | JSON containing fields and values to change | |
/locations | GET | - | A JSON document describing all locations |