Newer
Older
ez-indexation / app / node_modules / ezs-istex / lib / query.js
@kieffer kieffer on 7 Mar 2017 466 bytes v0.0.0

const OBJ = require('dot-prop');
const QueryString = require('qs');

module.exports = function(data, feed) {
  let path = this.getParam('path', 'query');
  let query = OBJ.get(data, path);
  if (query === undefined) {
    query = data;
  }
  let urlObj = {
    protocol: 'https:',
    host : 'api.istex.fr',
    pathname: '/document/',
    search: QueryString.stringify(query)
  }
  if (this.isLast()) {
    feed.close();
  }
  else {
    feed.send(urlObj);
  }
}