lib/service_new.js
async function request(cb) {
  // get name of current service, stop if it's `config-srv` itself
  const name = nconf.get('server:name') || 'test-srv';
  let data = {};
  if (name === 'config-srv') return cb(null, data);

  // setup & connect with config-srv on first run
  // if (!client && fs.existsSync(fullProtoPath))
  const config = _.clone(nconf.get('config-srv'));
  let service;

  if (config.transports
    && config.transports.grpc
    && config.transports.service) {
    client = new grpcClient.Client(config);
    service = await co(client.connect());
  } else {
    throw new Error('Missing configuration details');
  }

  await co(service.get({
    filter: client.toStruct({ name: name })
  }));

  // TODO: continue
  // fetch the latest configuration data if possible
  client.get({ field: [{ name }] }, (err, res) => {
    if (err) return cb(err, null);
    if (res.data) data = res.data;

    // update/mutate the nconf store and return
    nconf.use('default', data);
    return cb(null, nconf);
  });
  return true;
}
async function request(cb) {
  // get name of current service, stop if it's `config-srv` itself
  const name = nconf.get('server:name') || 'test-srv';
  let data = {};
  if (name === 'config-srv') return cb(null, data);

  // setup & connect with config-srv on first run
  // if (!client && fs.existsSync(fullProtoPath))
  const config = _.clone(nconf.get('config-srv'));
  let service;

  if (config.transports
    && config.transports.grpc
    && config.transports.service) {
    client = new grpcClient.Client(config);
    service = await co(client.connect());
  } else {
    throw new Error('Missing configuration details');
  }

  await co(service.get({
    filter: client.toStruct({ name: name })
  }));

  // TODO: continue
  // fetch the latest configuration data if possible
  client.get({ field: [{ name }] }, (err, res) => {
    if (err) return cb(err, null);
    if (res.data) data = res.data;

    // update/mutate the nconf store and return
    nconf.use('default', data);
    return cb(null, nconf);
  });
  return true;
}
async function request ( cb ) { // get name of current service, stop if it's `config-srv` itself const name = nconf . get ( 'server:name' ) || 'test-srv' ; let data = { } ; if ( name === 'config-srv' ) return cb ( null , data ) ; // setup & connect with config-srv on first run // if (!client && fs.existsSync(fullProtoPath)) const config = _ . clone ( nconf . get ( 'config-srv' ) ) ; let service ; if ( config . transports && config . transports . grpc && config . transports . service ) { client = new grpcClient . Client ( config ) ; service = await co ( client . connect ( ) ) ; } else { throw new Error ( 'Missing configuration details' ) ; } await co ( service . get ( { filter : client . toStruct ( { name : name } ) } ) ) ; // TODO: continue // fetch the latest configuration data if possible client . get ( { field : [ { name } ] } , ( err , res ) => { if ( err ) return cb ( err , null ) ; if ( res . data ) data = res . data ; // update/mutate the nconf store and return nconf . use ( 'default' , data ) ; return cb ( null , nconf ) ; } ) ; return true ; }
function to update the nconf object with data from the
remote `config-srv`.
function to update the nconf object with data from the remote config - srv .