app.post('/rank', upload.array(), function (req, res) { var state = { originResponse: res, originPokemon: req.body, consulClient: consul(), slat: req.query.slat, slng: req.query.slng } console.log(state); if(state.originPokemon == null) { state.originResponse.status(503).send("OriginPokemon was null"); } else { state.uberReqs = state.originPokemon.map(function(obj){ return { requestId: obj.id, dlat: obj.position.lat, dlng : obj.position.lng }; }); console.log('GET /rank'); state.consulClient.catalog.service.nodes('pokedash-uberestimate', lookupPokeDashUberestimate.bind(undefined, state)); } });
function getConsulClient( options ) { var client = consul( options ); var lifted; _.each( toLift, function( path ) { lifted = lift( _get( client, path ) ); _set( client, path, lifted ); } ); return client; }
module.exports = function( _config ) { var consul = consulFactory( _config ); _.each( toLift, function( methods, key ) { _.each( methods, function( m ) { consul[ key ][ m ] = lift( consul[ key ][ m ] ); } ); } ); return consul; };
app.get('/tap', function (req, res) { req.body.id var state = { originResponse: res, uberRequestInfo : [{requestId:0, dlat: req.query.dlat, dlng: req.query.dlng}], slat: req.query.slat, slng: req.query.slng, consulClient: consul() } state.consulClient.catalog.service.nodes('pokedash-uberestimate', lookupPokeDashUberPoke.bind(undefined, state)); });
function getPoll(req, res) { console.log('inside poll'); var state = { originResponse: res, originLat: req.query.lat, originLng: req.query.lng, consulClient: consul() }; console.log('GET /poll: lat=' + state.originLat + ', lng=' + state.originLng); state.consulClient.catalog.service.nodes('pokedash-scan', consulPokeDashScanCallback.bind(undefined, state)); }
const vaultSecrets = (done) => consul({}).kv.get({key: 'playground/secrets'}, done);
const storeSecrets = (secrets, done) => { consul({}).kv.set({ key: 'playground/secrets', value: JSON.stringify(secrets) }, (err) => done(err, err ? null : secrets)); };
const getLeader = (wait) => (done) => setTimeout(() => consul({}).status.leader(done), wait);
seneca.add('init:consul_registry',function(args,done){ consul = consulReq(options); done(); });
function clean(done) { consulClient({}).kv.del( {key: "unittest", recurse: true }, done); }