diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2018-04-28 17:37:39 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-05 12:11:38 +0200 |
| commit | c8dc06971c6dab447250bb81cca20836ed5b2772 (patch) | |
| tree | 0a1fc039c29fd4052afd7ff828d9ae3e76fd7bbc /api.js | |
| download | brokentalents-c8dc06971c6dab447250bb81cca20836ed5b2772.tar.gz brokentalents-c8dc06971c6dab447250bb81cca20836ed5b2772.zip | |
first working version
Diffstat (limited to 'api.js')
| -rw-r--r-- | api.js | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -0,0 +1,42 @@ +#!/usr/bin/node + +const requestP = require('request-promise') + Future = require('fluture'); + +const API_KEY = process.env.API_KEY || require('./secret').apikey, + API_BASE = 'https://api.dc01.gamelockerapp.com', + API_TIMEOUT = 1; // seconds + +const requestF = Future.encaseP(requestP); + +function apiRequest(path, query) { + return requestF({ + uri: API_BASE + path, + headers: { + 'X-Title-Id': 'semc-vainglory', + 'Authorization': API_KEY + }, + qs: query, + json: true, + gzip: true, + forever: true, + timeout: API_TIMEOUT*1000, + strictSSL: true + }); +} + +function awsRequest(url) { + return requestF({ + uri: url, + json: true, + gzip: true, + forever: true, + timeout: API_TIMEOUT*1000, + strictSSL: true + }); +} + +module.exports = { + apiRequest, + awsRequest, +}; |
