Some code base improvements

This commit is contained in:
Wessel Tip
2019-06-07 20:22:59 +02:00
parent f8fa21e384
commit faa6deb8a9
7 changed files with 145 additions and 91 deletions

View File

@@ -2,7 +2,6 @@ module.exports = class WumpResponse {
constructor (res) {
this.body = Buffer.alloc(0);
this.coreRes = res;
this.headers = res.headers;
this.statusCode = res.statusCode;
}
@@ -12,19 +11,11 @@ module.exports = class WumpResponse {
}
parse () {
if (this.headers['content-type'] === 'application/json') return JSON.parse(this.body);
if (this.headers['content-type'].includes('application/json')) return JSON.parse(this.body);
else return this.body.toString();
}
buffer () {
return this.body;
}
text () {
return this.body.toString();
}
json () {
return JSON.parse(this.body);
}
text () { return this.body.toString(); }
json () { return JSON.parse(this.body); }
buffer () { return this.body; }
};