this needs more testing, and the regexs could stand to be fine tuned more.
also, the general loops should probably be re-thought some more.
but this is working.
changed the hostname key to interface, since you can bind by IP or hostname.
in this case, binding by IP seems more appropriate, even if node is doing a lookup on hostname.
also added a requirement for the api_key value, to be 16-40 length alphanumeric characters.
perhaps there should be a configurable setting to not use the key, but will think that through later.
still need to update the documentation for the changes.
WIP
the basic function and error return is working, but is not verifying anything in the config yet.
also made some changes to the startup messaging, including version output.
/weather now returns the full data structure
temperature and humidity parameters still return only their resource.
also cleaned up the route verification to allow trailing slash.
now the following are supported:
/weather
/weather/
/weather/temperature
/weather/temperature/
/weather/humidity
/weather/humidity/
everything other uri returns an exception for unknown route.
WIP
added exception handling which logs the error as well as returns 500 to the user.
also updated documentation with installation instructions, including downloading and compiling the necessary bcm2835 C library.
after research into the sensor I would be using, landed on a library and thought more through how the read mechanism would work.
the sensor, the DHT22, works a little differently than I originally thought.
this doesn't allow for / at the end of the parameter, but potentially should.
other API frameworks I've worked with distinguish between a trailing slash and not. I've often thought that allowing a trailing slash leads to potentially less confusion for people getting started.
renamed the script to the project name, weather-api
updated documentation to match
added external dependencies to a package.json file for easy installation through npm
updated documentation to indicate npm install
There are modules to handle config settings in a more agnostic way. I'm personally familiar with env style configs, and like them, but for the sake of keeping it simple, decided to load through a js file. There has been a lot of dialogue about which method is best, but ultimately the reasoning and layout for js objects won out for me.