Refactor to dedupe and add version

This commit is contained in:
Pete ba
2019-05-06 12:14:15 +01:00
parent ca21058977
commit 612f911285
3 changed files with 58 additions and 92 deletions

View File

@@ -1,4 +1,5 @@
var express = require( "express" ),
var package = require( "./package.json" ),
express = require( "express" ),
weather = require( "./routes/weather.js" ),
local = require( "./routes/local.js" ),
cors = require( "cors" ),
@@ -30,7 +31,7 @@ if ( pws === "WU" ) {
}
app.get( "/", function( req, res ) {
res.send( "OpenSprinkler Weather Service" );
res.send( package.description + " v" + package.version );
} );
// Handle 404 error
@@ -41,10 +42,10 @@ 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 );
console.log( "%s now listening on %s:%s", package.description, host, port );
if (pws !== "none" ) {
console.log( "OpenSprinkler Weather Service now listening for local weather stream" );
console.log( "%s now listening for local weather stream", package.description );
}
} );