Initial version of Node.js rewrite

This commit is contained in:
Samer Albahra
2015-07-01 00:12:02 -05:00
parent 3bd0decc2d
commit 3d6c7d6da3
8 changed files with 339 additions and 448 deletions

21
server.js Normal file
View File

@@ -0,0 +1,21 @@
var express = require( "express" ),
weather = require( "./routes/weather.js" ),
port = process.env.PORT || 3000;
app = express();
// Handle requests matching /weatherID.py where ID corresponds to the
// weather adjustment method selector.
// This endpoint is considered deprecated and supported for prior firmware
app.get( /weather(\d+)\.py/, weather.getWeather );
// Handle 404 error
app.use( function( req, res ) {
res.status( 404 );
res.send( "Not found" );
} );
// Start listening on the service port
var server = app.listen( port, "127.0.0.1", function() {
console.log( "OpenSprinkler Weather Service now listening on port %s", port );
} );