1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 18:32:50 +00:00

minor changes as well as new post

This commit is contained in:
2016-01-02 00:32:06 -06:00
parent b512e6c2a6
commit 9d1a5e460c
4 changed files with 14 additions and 10 deletions

View File

@@ -12,15 +12,20 @@ router.get('/', function(req, res, next) {
var location = req.query.location;
var key = req.query.key;
//implement a key for security
//the esp8266 will send "nan" (not a number) if it has a faulty temperature read
//we do not want to save it if it is not a number
if(key == "esp1234" && temperature != "nan" && humidity != "nan"){
//create a new object to insert into the database
//using mongoose for object modeling
var insert = new info({
temperature: temperature,
humidity: humidity,
location: location
});
//save information in the database
insert.save(function (err) {
if (err) return handleError(err);
@@ -28,6 +33,7 @@ router.get('/', function(req, res, next) {
console.log("--information saved--");
//send respnse back
res.send("Information Logged");
}
@@ -38,8 +44,6 @@ router.get('/', function(req, res, next) {
res.send("Invalid Authentication");
}
});
module.exports = router;