How to use the phin.defaults function in phin

To help you get started, we’ve selected a few phin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zKillboard / evewho / cron / update_characters_by_affiliation.js View on Github external
module.exports = f;

var phin = require('phin').defaults({'headers': { 'User-Agent': 'evewho.com' } });

async function f(app) {
    let promises = [];

    let chars = await app.mysql.query('select character_id, corporation_id, alliance_id, faction_id from ew_characters where lastUpdated > 0 and lastAffUpdated < date_sub(now(), interval 1 day) order by lastAffUpdated limit 1000');
    if (chars.length == 0) return;

    let char_array = [];
    let map = {};
    for (let i =0; i < chars.length; i++) {
        char_array.push(chars[i].character_id);
        map[chars[i].character_id] = chars[i];
    }
    await app.mysql.query('update ew_characters set lastAffUpdated = now() where character_id in (' + char_array.join() + ')');

    let url = 'https://esi.evetech.net/v1/characters/affiliation/'
github MihaiVoinea / makerlog-cli / build / commands / done.js View on Github external
},{"../package.json":"../package.json"}],"../config/phin.config.js":[function(require,module,exports) {
const p = require("phin");

const store = require("./store.config");

let options = {
  parse: "json",
  core: {
    headers: {
      "Content-Type": "application/json"
    }
  }
};
if (store.has("token")) options.core.headers.Authorization = "Token " + store.get("token");
module.exports = p.defaults(options);
},{"./store.config":"../config/store.config.js"}],"../components/loader.js":[function(require,module,exports) {
"use strict";
github zKillboard / evewho / bin / cron.js View on Github external
#!/usr/bin/env node

var Database = require('../classes/Database.js');
var getJSON = require('get-json');
var redis = require('async-redis').createClient();
var phin = require('phin').defaults({'method': 'get', 'headers': { 'User-Agent': 'evewho.com' } });

const app = {};

app.debug = false;
app.bailout = false;
app.error_count = 0;
app.phin = phin;
app.fetch = async function(url, parser, failure, options) {
    try {
        return await parser(app, await phin(url), options);
    } catch (e) {
        return failure(app, e);
    }
};
app.redis = redis;
app.mysql = new Database({
github MihaiVoinea / makerlog-cli / build / commands / login.js View on Github external
},{"../package.json":"../package.json"}],"../config/phin.config.js":[function(require,module,exports) {
const p = require("phin");

const store = require("./store.config");

let options = {
  parse: "json",
  core: {
    headers: {
      "Content-Type": "application/json"
    }
  }
};
if (store.has("token")) options.core.headers.Authorization = "Token " + store.get("token");
module.exports = p.defaults(options);
},{"./store.config":"../config/store.config.js"}],"../components/loader.js":[function(require,module,exports) {
"use strict";
github MihaiVoinea / makerlog-cli / build / commands / todo.js View on Github external
},{"../package.json":"../package.json"}],"../config/phin.config.js":[function(require,module,exports) {
const p = require("phin");

const store = require("./store.config");

let options = {
  parse: "json",
  core: {
    headers: {
      "Content-Type": "application/json"
    }
  }
};
if (store.has("token")) options.core.headers.Authorization = "Token " + store.get("token");
module.exports = p.defaults(options);
},{"./store.config":"../config/store.config.js"}],"../components/loader.js":[function(require,module,exports) {
"use strict";

phin

The ultra-lightweight Node.js HTTP client

MIT
Latest version published 7 months ago

Package Health Score

73 / 100
Full package analysis

Popular phin functions