Comparing version 0.0.0 to 0.0.1
40
index.js
const got = require('got') | ||
const api = got.extend({ | ||
baseUrl: 'https://api.guildwars2.com/v2/', | ||
json: true, | ||
}) | ||
const gw2 = (path, { token = null, headers = {}, ...options } = {}) => | ||
api | ||
.get(path, { | ||
...options, | ||
headers: { | ||
...headers, | ||
Authorization: token && `Bearer ${token}`, | ||
}, | ||
class Client { | ||
constructor({ | ||
baseUrl = 'https://api.guildwars2.com/', | ||
version = '2', | ||
token = null, | ||
} = {}) { | ||
this.client = got.extend({ | ||
baseUrl: `${baseUrl}v${version}/`, | ||
json: true, | ||
}) | ||
.then(res => res.body) | ||
this.token = token | ||
} | ||
get(path, { token = null, headers = {}, ...options } = {}) { | ||
return this.client | ||
.get(path, { | ||
...options, | ||
headers: { | ||
...headers, | ||
Authorization: token && `Bearer ${token}`, | ||
}, | ||
}) | ||
.then(res => res.body) | ||
} | ||
} | ||
module.exports = { | ||
gw2, | ||
Client, | ||
} |
{ | ||
"name": "gw2", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Guild Wars 2 API client for Node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,7 +14,9 @@ Guild Wars 2 API client for Node. | ||
gw2('achievements/daily').then(data => { | ||
const client = new gw2.Client() | ||
client.get('achievements/daily').then(data => { | ||
// | ||
}) | ||
gw2('account', { token: 'API-KEY' }).then(data => { | ||
client.get('account', { token: 'API-KEY' }).then(data => { | ||
// | ||
@@ -21,0 +23,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2533
28
30