Rebase on latest master
Revert refactor versioning Tidy revert of versioning Bump version
This commit is contained in:
15
server.js
15
server.js
@@ -1,14 +1,17 @@
|
||||
var express = require( "express" ),
|
||||
weather = require( "./routes/weather.js" ),
|
||||
local = require( "./routes/local.js" ),
|
||||
cors = require( "cors" ),
|
||||
host = process.env.HOST || "127.0.0.1",
|
||||
port = process.env.PORT || 3000,
|
||||
pws = process.env.PWS || "none",
|
||||
app = express();
|
||||
|
||||
if ( !process.env.HOST || !process.env.PORT ) {
|
||||
if ( !process.env.HOST || !process.env.PORT || !process.env.LOCAL_PWS ) {
|
||||
require( "dotenv" ).load();
|
||||
host = process.env.HOST || host;
|
||||
port = process.env.PORT || port;
|
||||
pws = process.env.PWS || pws;
|
||||
}
|
||||
|
||||
// Handle requests matching /weatherID.py where ID corresponds to the
|
||||
@@ -21,6 +24,11 @@ app.get( /(\d+)/, weather.getWateringData );
|
||||
app.options( /weatherData/, cors() );
|
||||
app.get( /weatherData/, cors(), weather.getWeatherData );
|
||||
|
||||
// Endpoint to stream Weather Underground data from local PWS
|
||||
if ( pws === "WU" ) {
|
||||
app.get( "/weatherstation/updateweatherstation.php", local.captureWUStream );
|
||||
}
|
||||
|
||||
app.get( "/", function( req, res ) {
|
||||
res.send( "OpenSprinkler Weather Service" );
|
||||
} );
|
||||
@@ -34,6 +42,11 @@ app.use( function( req, res ) {
|
||||
// Start listening on the service port
|
||||
app.listen( port, host, function() {
|
||||
console.log( "OpenSprinkler Weather Service now listening on %s:%s", host, port );
|
||||
|
||||
if (pws !== "none" ) {
|
||||
console.log( "OpenSprinkler Weather Service now listening for local weather stream" );
|
||||
}
|
||||
} );
|
||||
|
||||
exports.app = app;
|
||||
exports.pws = pws;
|
||||
|
||||
Reference in New Issue
Block a user