A simple Node.js/Express app receiving data from a Raspberry Pi weather station and making it available via API request from other sources. This app is part of our final project, a separate app was written to create a Single Page App that utilises the API server and displays the weather data.
Go here to see the live SPA App
- Javascript linted with eslint
- express
- mocha + nyc test Coverage
- mongodb with mongoose
- deployed to heroku via Travis CI/CD
Running:
git clone https://github.com/riyadattani/weather_station_server.git
npm install
npm start
visit localhost:9000
Testing:
npm test
We employed a strict TDD process for the development of this app. We used the following test descriptions below:
- response status should be 200
- returns a confirmation message
- returns a helpful message if it couldn't save
- response include the Mongo error if it couldn't save
- saves the data in the database for a legit input
- returns an error message if it doesn't validate
- doesn't save the data in the database if it doesn't validate
- returns the posted data
- returns an empty response if the database is empty
- if no initial datetime and no final datetime provided
- Initial datetime defaults to 24 hours ago
- Final datetime defaults to now
- if initial datetime and final datetime provided
- Use provided initial datetime
- Use provided final datetime
- if no initial datetime provided but final datetime provided
- Initial datetime defaults to 24 hours before final datetime
- Use provided final datetime
- if initial datetime provided but no final datetime provided
- Use provided initial datetime
- Final datetime defaults to now
Connect to mongo production database:
mongo "mongodb+srv://weather-station-server-zrxmz.mongodb.net/test" --username weather-station-master
Sozza you need a password ;-)