Tidying other modules, fixing password and fx

This commit is contained in:
Martin Donnelly 2017-09-11 16:23:44 +01:00
parent fd475cb5e8
commit fdb10dcebe
3 changed files with 55 additions and 53 deletions

View File

@ -147,5 +147,7 @@ exports.setEmitter = (newEmitter) => {
eventEmitter = newEmitter;
};
updateBitcoin();
updateBalance();
setTimeout(function() {
updateBitcoin();
updateBalance();
}, 25000);

View File

@ -3,25 +3,25 @@
"version": "0.1.1",
"devDependencies": {
"babel": "^6.23.0",
"babel-core": "^6.24.0",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.1",
"babel-preset-es2015": "^6.24.0",
"cheerio": "^0.20.0",
"dateformat": "^1.0.12",
"ejs": "^2.3.4",
"eslint": "^3.18.0",
"cheerio": "^0.22.0",
"dateformat": "^2.0.0",
"ejs": "^2.5.7",
"eslint": "^4.6.1",
"eslint-config-defaults": "^9.0.0",
"eslint-config-standard": "^7.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^4.2.2",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^6.10.3",
"eslint-plugin-standard": "^2.1.1",
"eslint-plugin-react": "^7.3.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-watch": "^3.0.1",
"fitbit-oauth2": "0.0.1",
"forecast.io": "0.0.9",
"gulp-autoprefixer": "^3.1.1",
"gulp-babel": "^6.1.2",
"forecast.io": "0.0.11",
"gulp-autoprefixer": "^4.0.0",
"gulp-babel": "^7.0.0",
"gulp-cache": "^0.4.6",
"gulp-concat": "^2.6.1",
"gulp-cssnano": "^2.1.2",
@ -33,53 +33,50 @@
"gulp-sass": "^3.1.0",
"gulp-scss": "^1.4.0",
"gulp-strip-debug": "^1.1.0",
"gulp-uglify": "^2.1.2",
"gulp-uglify": "^3.0.0",
"htmlparser": "^1.7.7",
"jade": "^1.11.0",
"jest": "^19.0.2",
"jest": "^21.0.2",
"jshint": "^2.9.4",
"jsonfile": "^2.3.0",
"jsonfile": "^3.0.1",
"lodash": "^4.11.2",
"log4js": "^0.6.35",
"lowdb": "^0.16.2",
"mammoth": "^1.0.1",
"nano": "^6.2.0",
"log4js": "^2.3.3",
"lowdb": "^1.0.0",
"mammoth": "^1.4.2",
"nano": "^6.4.0",
"node-localstorage": "^1.3.0",
"request": "^2.72.0",
"request": "^2.81.0",
"simple-weather": "^1.2.2",
"sugar-date": "^1.5.1",
"sugar-date": "^2.0.4",
"wordsoap": "^0.2.0",
"xmljson": "^0.2.0",
"xmltojson": "^1.1.0"
"xmltojson": "^1.3.5"
},
"dependencies": {
"apicache": "^0.11.2",
"body-parser": "^1.15.0",
"body-parser": "^1.18.0",
"cloudant": "^1.6.2",
"cookie-parser": "^1.4.1",
"cookieparser": "^0.1.0",
"elapsed": "0.0.7",
"errorhandler": "^1.4.3",
"eslint-plugin-react": "^6.10.3",
"express": "^4.13.4",
"express-session": "^1.13.0",
"express": "^4.15.4",
"express-session": "^1.15.5",
"ftse": "^1.0.6",
"gulp": "^3.9.1",
"ical2json": "^0.2.0",
"ical2json": "^1.2.0",
"limitedarray": "git+https://gitlab.silvrtree.co.uk/martind2000/limitedArray.git",
"logger": "0.0.1",
"method-override": "^2.3.5",
"morgan": "^1.7.0",
"nano": "^6.2.0",
"node-cron": "^1.0.0",
"node-cron": "^1.2.1",
"pug": "^2.0.0-beta11",
"scrape": "^0.2.3",
"string": "^3.3.1",
"sugar-date": "^1.5.1",
"trend": "^0.3.0",
"ultrases": "^0.1.3",
"unstyler": "^0.2.2",
"ws": "^1.1.1"
"ws": "^3.1.0"
},
"scripts": {
"start": "node web-server.js",

View File

@ -12,7 +12,6 @@ const events = require('./lib/events');
const morgan = require('morgan');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const apicache = require('apicache');
const methodoverride = require('method-override');
const bodyparser = require('body-parser');
@ -32,10 +31,10 @@ const SocketHandler = require('./lib/wshandlerv2');
// const webSocket = new SocketHandler(busEmitter, wss);
btc.setEmitter(busEmitter);
btc.setEmitter(busEmitter);
// today.setEmitter(busEmitter);
// train = require('lib/train')
// train = require('lib/train')
/* ,submit = require('./routes/mongo/submit') */
const fs = require('fs');
@ -45,6 +44,8 @@ const Fitbit = require('fitbit-oauth2');
const polys = require('./lib/poly.js');
const logger = require('log4js').getLogger('web-server');
const apicache = require('apicache');
const app = express();
GLOBAL.lastcheck = 0;
GLOBAL.fxLastCheck = 0;
@ -62,7 +63,7 @@ app.use(session({
'saveUninitialized': false
}));
/* 'default', 'short', 'tiny', 'dev' */
/* 'default', 'short', 'tiny', 'dev' */
app.use(methodoverride());
app.use(bodyparser.urlencoded({ 'extended': false }));
@ -70,36 +71,38 @@ app.use(bodyparser.urlencoded({ 'extended': false }));
// parse application/json
app.use(bodyparser.json());
// apicache.options({ 'debug': true });
// const cache = apicache.middleware;
// logger.debug(apicache);
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
next();
});
// app.use(app.router);
// app.use(app.router);
app.use(express.static(path.join(__dirname, 'app')));
app.use(errorhandler({ 'dumpExceptions': true, 'showStack': true }));
// apicache.options({ 'debug': true });
const cache = apicache.middleware;
app.use('/btc', btc.doBTC);
app.use('/balance', btc.doBalance);
app.use('/btc', cache('15 minutes'), btc.doBTC);
app.use('/balance', cache('15 minutes'), btc.doBalance);
app.use('/fx', cache('15 minutes'), fx.doFx);
app.use('/fx', fx.doFx);
app.use('/dbeglq', train.dbe_glq);
app.use('/glqdbe', train.glq_dbe);
app.use('/gettrains', train.getTrainTimes);
app.use('/getnexttraintimes', cache('1 minute'), train.getNextTrainTimes);
app.use('/getnexttraintimes', train.getNextTrainTimes);
app.use('/getroute', train.getRoute);
app.use('/generate', password.generate);
app.use('/cleanit', clean.cleanit);
app.use('/events', cache('6 hours'), events.getEvents);
app.get('/cinema/:id', cache('6 hours'), events.getCinema);
app.use('/events', events.getEvents);
app.get('/cinema/:id', events.getCinema);
app.route('/poly').get(polys);
@ -132,14 +135,14 @@ app.get( '/fb-profile', function( req, res, next ) {
}, function( err, body, token ) {
if ( err ) return next( err );
var profile = JSON.parse( body );
// if token is not null, a refesh has happened and we need to persist the new token
// if token is not null, a refesh has happened and we need to persist the new token
if ( token )
persist.write( tfile, token, function( err ) {
if ( err ) return next( err );
res.send( `<pre>${ JSON.stringify( profile, null, 2 ) }</pre>` );
});
else
res.send( `<pre>${ JSON.stringify( profile, null, 2 ) }</pre>` );
res.send( `<pre>${ JSON.stringify( profile, null, 2 ) }</pre>` );
});
});
@ -153,14 +156,14 @@ app.get( '/fb-today', function( req, res, next ) {
}, function( err, body, token ) {
if ( err ) return next( err );
var profile = JSON.parse( body );
// if token is not null, a refesh has happened and we need to persist the new token
// if token is not null, a refesh has happened and we need to persist the new token
if ( token )
persist.write( tfile, token, function( err ) {
if ( err ) return next( err );
res.send( `<pre>${ JSON.stringify( profile, null, 2 ) }</pre>` );
});
else
res.send( `<pre>${ JSON.stringify( profile, null, 2 ) }</pre>` );
res.send( `<pre>${ JSON.stringify( profile, null, 2 ) }</pre>` );
});
});
@ -174,7 +177,7 @@ app.get('/fitbit_auth_callback', function(req, res, next) {
if (err)
return next(err);
// persist the token
// persist the token
jsonfile.writeFile(tfile, token, function(err) {
if (err)
return next(err);