sj-api.js 633 Bytes
const md5 = require('yoho-md5');
const rp = require('request-promise');

const userKey = '7fe2d9ada6-MWI5NWUyM2';
const user_secret = 'M3ZmUyZDlhZGE2NT-523cdf23981b95e';
const timestamp = parseInt(Date.now() / 1000, 10);
const source_id = 737210;
const sign = md5(`${userKey}${timestamp}${user_secret}`);

// const query = 'source(__id:{gt:0}, limit: 2000){data{__id},page_info{end_cursor,has_next_page}}';


module.exports = (query) => {
  return rp({
    url: `https://graphql.shenjian.io/?user_key=${userKey}&timestamp=${timestamp}&sign=${sign}&source_id=${source_id}&query=${encodeURIComponent(query)}`,
    json: true
  });
};