diff --git a/.gitignore b/.gitignore index 9c959ef..f38038a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store node_modules .env WeatherService.zip diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index a87f8f0..0000000 --- a/.jscsrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "maximumLineLength": 150 -} diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..94a6a96 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,21 @@ +{ + "boss": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "expr": true, + "immed": true, + "noarg": true, + "onevar": true, + "quotmark": "double", + "smarttabs": true, + "trailing": true, + "undef": true, + "unused": true, + "browser": true, + "node": true, + "sub": true, + "globals": { + "module": true + } +} diff --git a/Gruntfile.js b/Gruntfile.js index bdc3b44..7b0f6dc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,29 +2,20 @@ module.exports = function( grunt ) { // Load node-modules; grunt.loadNpmTasks( "grunt-contrib-jshint" ); - grunt.loadNpmTasks( "grunt-jscs" ); // Project configuration. grunt.initConfig( { pkg: grunt.file.readJSON( "package.json" ), jshint: { - main: [ "Gruntfile.js", "server.js", "routes/**", "models/**" ], + main: [ "Gruntfile.js", "server.js", "routes/*.js", "models/*.js" ], options: { jshintrc: true } - }, - - jscs: { - main: [ "Gruntfile.js", "server.js", "routes/**", "models/**" ], - options: { - config: true, - fix: true - } } } ); // Default task(s). - grunt.registerTask( "default", [ "jshint", "jscs" ] ); + grunt.registerTask( "default", [ "jshint" ] ); }; diff --git a/package.json b/package.json index 5ad1ce4..f03d4c2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "express": "^4.13.0", "grunt": "^0.4.5", "grunt-contrib-jshint": "^0.11.2", - "grunt-jscs": "^1.8.0", "mongoose": "^4.0.6", "xml2js": "^0.4.9" } diff --git a/routes/weather.js b/routes/weather.js index b000b50..8d6843c 100644 --- a/routes/weather.js +++ b/routes/weather.js @@ -1,7 +1,7 @@ ( function() { var http = require( "http" ), - parseXML = require( "xml2js" ).parseString, +// parseXML = require( "xml2js" ).parseString, Cache = require( "../models/Cache" ), // Define regex filters to match against location @@ -92,7 +92,7 @@ } ); } - +/* // Retrieve the historical weather data for the provided location function getYesterdayWeatherData( location, callback ) { @@ -108,7 +108,7 @@ // Generate URL using WSI Cleaned History API in Imperial units showing daily average values url = "http://cleanedobservations.wsi.com/CleanedObs.svc/GetObs?ID=" + WSI_HISTORY_KEY + "&Lat=" + location[0] + "&Long=" + location[1] + - "&Req=davg&startdate=" + yesterday.toUSDate() + "&enddate=" + yesterday.toUSDate() + "&TS=LST"; + "&Req=davg&startdate=" + toUSDate( yesterday ) + "&enddate=" + toUSDate( yesterday ) + "&TS=LST"; // Perform the HTTP request to retrieve the weather data httpRequest( url, function( xml ) { @@ -117,7 +117,7 @@ }); } ); } - +*/ // Update weather cache record in the local database function updateCache( location, weather ) { @@ -163,7 +163,7 @@ } // Zimmerman method - if ( adjustmentMethod == 1 ) { + if ( adjustmentMethod === 1 ) { var humidityFactor = ( 30 - rh ), tempFactor = ( ( temp - 70 ) * 4 ), @@ -237,7 +237,7 @@ location = req.query.loc, weatherUndergroundKey = req.query.key, outputFormat = req.query.format, - firmwareVersion = req.query.fwv, +// firmwareVersion = req.query.fwv, remoteAddress = req.headers[ "x-forwarded-for" ] || req.connection.remoteAddress, // Function that will accept the weather after it is received from the API @@ -406,7 +406,8 @@ return ( ( ( ( ( ( +ip[0] ) * 256 ) + ( +ip[1] ) ) * 256 ) + ( +ip[2] ) ) * 256 ) + ( +ip[3] ); } - function F2C( temp ) { +/* + function f2c( temp ) { return ( temp - 32 ) * 5 / 9; } @@ -419,8 +420,8 @@ } // Resolves the Month / Day / Year of a Date object - Date.prototype.toUSDate = function(){ - return ( this.getMonth() + 1 ) + "/" + this.getDate() + "/" + this.getFullYear(); - }; - + function toUSDate( date ){ + return ( date.getMonth() + 1 ) + "/" + date.getDate() + "/" + date.getFullYear(); + } +*/ } )(); diff --git a/server.js b/server.js index d1ca424..b64adfd 100644 --- a/server.js +++ b/server.js @@ -3,7 +3,7 @@ var express = require( "express" ), mongoose = require( "mongoose" ), Cache = require( "./models/Cache" ), CronJob = require( "cron" ).CronJob, - port = process.env.PORT || 3000; + port = process.env.PORT || 3000, app = express(); if ( !process.env.PORT ) { @@ -30,7 +30,7 @@ app.use( function( req, res ) { } ); // Start listening on the service port -var server = app.listen( port, "127.0.0.1", function() { +app.listen( port, "127.0.0.1", function() { console.log( "OpenSprinkler Weather Service now listening on port %s", port ); } );