Skip to content

Commit 951b66f

Browse files
Updating examples and readme for correctness (#23)
* Updating examples and readme for correctness * Allowing override of patreon url with env variable
1 parent f1f8b0d commit 951b66f

File tree

7 files changed

+53
-51
lines changed

7 files changed

+53
-51
lines changed

changelog.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
# 0.4.1
2+
3+
## Added
4+
5+
* Allow override of patreon base URL via environment variable (for internal testing)
6+
7+
## Fixed
8+
9+
* Corrected errors in README
10+
* Fixed errors in examples/package.json, so npm install will work properly there
11+
12+
## Updated
13+
14+
* Removed unused dependencies
15+
116
# 0.4.0
217

318
* Improve README to better explain responses
419
* Use JSONAPIStore for response
520
* Add User-Agent string for better platform attribution
621
* Adjust our API urls to the canonical form
7-
* Add a package.json to the examples directory for easier testing
22+
* Add a package.json to the examples directory for easier testing

examples/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
"description": "Test package for using the Patreon JS client library",
55
"main": "server.js",
66
"scripts": {
7-
"start": "node server.js"
7+
"start": "babel-node server.js"
88
},
99
"author": "Patreon",
1010
"license": "ISC",
1111
"dependencies": {
1212
"express": "^4.16.2",
13-
"patreon": "^0.3.0"
13+
"patreon": "0.4.1"
14+
},
15+
"devDependencies": {
16+
"babel-cli": "^6.26.0"
1417
}
1518
}

package-lock.json

Lines changed: 20 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "patreon",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Use the Patreon API via OAuth.",
55
"main": "dist/index.js",
66
"scripts": {
@@ -30,8 +30,7 @@
3030
"form-urlencoded": "^2.0.4",
3131
"is-plain-object": "^2.0.4",
3232
"isomorphic-fetch": "^2.2.1",
33-
"jsonapi-datastore": "^0.4.0-beta",
34-
"verror": "^1.10.0"
33+
"jsonapi-datastore": "^0.4.0-beta"
3534
},
3635
"devDependencies": {
3736
"babel-cli": "^6.26.0",

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ The lists of valid `includes` and `fields` arguments are provided in `patreon/sc
169169
For instance, if you wanted to request the total amount a patron has ever paid to your campaign,
170170
which is not included by default, you could do:
171171
```js
172-
const { patreonAPI, jsonApiURL } = require('patreon')
172+
const { patreon, jsonApiURL } = require('patreon')
173173
const pledge_schema = require('patreon/schemas/pledge')
174174

175-
const patreonAPIClient = patreonAPI(access_token)
175+
const patreonAPIClient = patreon(access_token)
176176
const url = jsonApiURL(`/current_user`, {
177177
fields: {
178178
pledge: [...pledge_schema.default_attributes, pledge_schema.attributes.total_historical_amount_cents]

src/oauth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fetch from 'isomorphic-fetch'
22
import formurlencoded from 'form-urlencoded'
3-
import { checkStatus, getJson, userAgentString } from './utils'
3+
import { buildUrl, checkStatus, getJson, userAgentString } from './utils'
44

55
function errMap(err, params) {
66
if (err === 'invalid_grant') {
@@ -13,7 +13,7 @@ function errMap(err, params) {
1313
}
1414

1515
function updateToken(params) {
16-
const url = 'https://www.patreon.com/api/oauth2/token'
16+
const url = buildUrl('/api/oauth2/token')
1717
const options = {
1818
method: 'POST',
1919
headers: {

src/utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { version } from '../package.json'
22
const os = require('os')
33

4-
const BASE_HOST = 'https://www.patreon.com'
4+
const BASE_HOST = process.env.PATREON_OAUTH_HOST || 'https://www.patreon.com'
55
const BASE_PATH = 'api/oauth2/api'
66

7+
function buildUrl(path) {
8+
return BASE_HOST + path
9+
}
10+
711
function stripPreSlash(str) {
812
return str.replace(/^\//, '')
913
}
@@ -34,4 +38,4 @@ function userAgentString() {
3438
return `Patreon-JS, version ${version}, platform ${os.platform()}-${os.release()}-${os.arch()}`
3539
}
3640

37-
export { stripPreSlash, normalizeRequest, checkStatus, getJson, userAgentString }
41+
export { stripPreSlash, normalizeRequest, checkStatus, getJson, userAgentString, buildUrl }

0 commit comments

Comments
 (0)