summaryrefslogtreecommitdiff
path: root/api.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-04-28 17:37:39 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-05-05 12:11:38 +0200
commitc8dc06971c6dab447250bb81cca20836ed5b2772 (patch)
tree0a1fc039c29fd4052afd7ff828d9ae3e76fd7bbc /api.js
downloadbrokentalents-c8dc06971c6dab447250bb81cca20836ed5b2772.tar.gz
brokentalents-c8dc06971c6dab447250bb81cca20836ed5b2772.zip
first working version
Diffstat (limited to 'api.js')
-rw-r--r--api.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/api.js b/api.js
new file mode 100644
index 0000000..3e65d66
--- /dev/null
+++ b/api.js
@@ -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,
+};