This repository was archived by the owner on Aug 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (34 loc) · 1.19 KB
/
index.js
File metadata and controls
38 lines (34 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { get } = require('node-superfetch');
module.exports = class derpy {
constructor(options) {
this.key = options.key;
this.url = options.url || 'https://apiv2.derpyenterprises.org'
}
static image(type) {
return new Promise((reject, resolve) => {
get(`${this.url}/image/${type}`)
.set("Authorization", this.key)
.then((res) => resolve(res.body))
.catch(err => reject(err))
});
}
static text(type, text) {
return new Promise((reject, resolve) => {
get(`${this.url}/text/${type}?text=${text}`)
.set("Authorization", this.key)
.then((res) => resolve(res.body))
.catch(err => reject(err))
});
}
static imagegen(type, url, text, query) {
let owo; // OwO what's this?
if (!url) return owo = text;
if (!text) return owo = url;
return new Promise((reject, resolve) => {
get(`${this.url}/imagegen/${type}?${owo}=${query}`)
.set("Authorization", this.key)
.then((res) => resolve(res.body))
.catch(err => reject(err))
});
}
}