From 15bb8962d2f439c95e07f7ca6700445b9e99a781 Mon Sep 17 00:00:00 2001 From: Matthew Berryman Date: Fri, 29 Jul 2016 08:59:08 +1000 Subject: [PATCH] Use ES6 let, change default port to 3000 --- config.js | 4 ++-- index.js | 6 +++--- libs/Task.js | 16 ++++++++-------- libs/TaskManager.js | 2 +- libs/expressRequestId.js | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config.js b/config.js index c2d94c0..3bfdb1d 100644 --- a/config.js +++ b/config.js @@ -14,7 +14,7 @@ * @property {number} port Port to launch server on */ -var config = {}; +let config = {}; // Instance name - default name for this configuration (will be server process name) config.instance = 'node-OpenDroneMap'; @@ -28,7 +28,7 @@ config.logger.maxFiles = 10; // Max number of log files kept config.logger.logDirectory = ''; // Set this to a full path to a directory - if not set logs will be written to the application directory. // Server port -config.port = process.env.PORT || 8081; +config.port = process.env.PORT || 3000; // process.env.PORT is what AWS Elastic Beanstalk defines // on IBM bluemix use config.port = process.env.VCAP_APP_PORT || 8081; diff --git a/index.js b/index.js index 2f27e15..1cede3f 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ along with this program. If not, see . */ "use strict"; -var config = require('./config.js') +let config = require('./config.js') let logger = require('winston'); let fs = require('fs'); @@ -34,7 +34,7 @@ let morgan = require('morgan'); // Set up logging // Configure custom File transport to write plain text messages -var logPath = ( config.logger.logDirectory ? config.logger.logDirectory : __dirname ); +let logPath = ( config.logger.logDirectory ? config.logger.logDirectory : __dirname ); // Check that log file directory can be written to try { fs.accessSync(logPath, fs.W_OK); @@ -56,7 +56,7 @@ logger // Console transport is no use to us when running as a daemon .remove(logger.transports.Console); -var winstonStream = { +let winstonStream = { write: function(message, encoding){ logger.info(message.slice(0, -1)); } diff --git a/libs/Task.js b/libs/Task.js index 9a3eea6..e30a6ba 100644 --- a/libs/Task.js +++ b/libs/Task.js @@ -1,5 +1,5 @@ -/* -Node-OpenDroneMap Node.js App and REST API to access OpenDroneMap. +/* +Node-OpenDroneMap Node.js App and REST API to access OpenDroneMap. Copyright (C) 2016 Node-OpenDroneMap Contributors This program is free software: you can redistribute it and/or modify @@ -57,7 +57,7 @@ module.exports = class Task{ for (let k in taskJson){ task[k] = taskJson[k]; } - + // Tasks that were running should be put back to QUEUED state if (task.status.code === statusCodes.RUNNING){ task.status.code = statusCodes.QUEUED; @@ -94,13 +94,13 @@ module.exports = class Task{ this.status = { code: code }; - for (var k in extra){ + for (let k in extra){ this.status[k] = extra[k]; } } updateProcessingTime(resetTime){ - this.processingTime = resetTime ? + this.processingTime = resetTime ? -1 : new Date().getTime() - this.dateCreated; } @@ -135,12 +135,12 @@ module.exports = class Task{ if (this.status.code !== statusCodes.CANCELED){ let wasRunning = this.status.code === statusCodes.RUNNING; this.setStatus(statusCodes.CANCELED); - + if (wasRunning && this.runnerProcess){ // TODO: this does guarantee that // the process will immediately terminate. // In fact, often times ODM will continue running for a while - // This might need to be fixed on ODM's end. + // This might need to be fixed on ODM's end. this.runnerProcess.kill('SIGINT'); this.runnerProcess = null; } @@ -262,4 +262,4 @@ module.exports = class Task{ options: this.options } } -}; \ No newline at end of file +}; diff --git a/libs/TaskManager.js b/libs/TaskManager.js index 71ea2ef..80c6fda 100644 --- a/libs/TaskManager.js +++ b/libs/TaskManager.js @@ -207,7 +207,7 @@ module.exports = class TaskManager{ // Serializes the list of tasks and saves it // to disk dumpTaskList(done){ - var output = []; + let output = []; for (let uuid in this.tasks){ output.push(this.tasks[uuid].serialize()); diff --git a/libs/expressRequestId.js b/libs/expressRequestId.js index b7ec05a..575d630 100644 --- a/libs/expressRequestId.js +++ b/libs/expressRequestId.js @@ -1,6 +1,6 @@ 'use strict'; -var uuid = require('node-uuid'); +let uuid = require('node-uuid'); module.exports = function (options) { options = options || {}; @@ -14,4 +14,4 @@ module.exports = function (options) { } next(); }; -}; \ No newline at end of file +};