@octokit/rest
Advanced tools
Comparing version 14.0.3 to 14.0.4
@@ -6,8 +6,8 @@ module.exports = authenticationPlugin | ||
function authenticationPlugin (github) { | ||
function authenticationPlugin (octokit) { | ||
const state = { | ||
auth: false | ||
} | ||
github.authenticate = authenticate.bind(null, state) | ||
github.hook.before('request', beforeRequest.bind(null, state)) | ||
octokit.authenticate = authenticate.bind(null, state) | ||
octokit.hook.before('request', beforeRequest.bind(null, state)) | ||
} |
@@ -10,5 +10,5 @@ module.exports = apiPlugin | ||
function apiPlugin (github) { | ||
function apiPlugin (octokit) { | ||
Object.keys(ENDPOINT_DEFAULTS).forEach(namespaceName => { | ||
github[namespaceName] = {} | ||
octokit[namespaceName] = {} | ||
@@ -19,8 +19,8 @@ Object.keys(ENDPOINT_DEFAULTS[namespaceName]).forEach(apiName => { | ||
github[namespaceName][apiName] = method.bind(null, github, endpointDefaults, apiOptions.params) | ||
octokit[namespaceName][apiName] = method.bind(null, octokit, endpointDefaults, apiOptions.params) | ||
// log deprecation warning for APIs flagged as deprecated | ||
if (apiOptions.deprecated) { | ||
github[namespaceName][apiName] = deprecate( | ||
github[namespaceName][apiName], | ||
octokit[namespaceName][apiName] = deprecate( | ||
octokit[namespaceName][apiName], | ||
apiOptions.deprecated | ||
@@ -27,0 +27,0 @@ ) |
@@ -7,3 +7,3 @@ module.exports = apiMethod | ||
function apiMethod (github, endpointDefaults, endpointParams, options, callback) { | ||
function apiMethod (octokit, endpointDefaults, endpointParams, options, callback) { | ||
const endpointOptions = defaultsDeep(options, endpointDefaults) | ||
@@ -13,3 +13,3 @@ | ||
.then(validate.bind(null, endpointParams)) | ||
.then(github.request) | ||
.then(octokit.request) | ||
@@ -16,0 +16,0 @@ if (callback) { |
@@ -5,4 +5,4 @@ module.exports = getFirstPage | ||
function getFirstPage (link, headers, callback) { | ||
return getPage(link, 'first', headers, callback) | ||
function getFirstPage (octokit, link, headers, callback) { | ||
return getPage(octokit, link, 'first', headers, callback) | ||
} |
@@ -5,4 +5,4 @@ module.exports = getLastPage | ||
function getLastPage (link, headers, callback) { | ||
return getPage(link, 'last', headers, callback) | ||
function getLastPage (octokit, link, headers, callback) { | ||
return getPage(octokit, link, 'last', headers, callback) | ||
} |
@@ -5,4 +5,4 @@ module.exports = getNextPage | ||
function getNextPage (link, headers, callback) { | ||
return getPage(link, 'next', headers, callback) | ||
function getNextPage (octokit, link, headers, callback) { | ||
return getPage(octokit, link, 'next', headers, callback) | ||
} |
@@ -5,5 +5,4 @@ module.exports = getPage | ||
const getPageLinks = require('./get-page-links') | ||
const request = require('../../request/request') | ||
function getPage (link, which, headers, callback) { | ||
function getPage (octokit, link, which, headers, callback) { | ||
if (typeof headers === 'function') { | ||
@@ -29,3 +28,3 @@ callback = headers | ||
const promise = request(requestOptions) | ||
const promise = octokit.request(requestOptions) | ||
@@ -44,3 +43,3 @@ if (callback) { | ||
if (!previous || (headers && headers.accept)) { | ||
return res.meta | ||
return headers | ||
} | ||
@@ -47,0 +46,0 @@ headers = headers || {} |
@@ -5,4 +5,4 @@ module.exports = getPreviousPage | ||
function getPreviousPage (link, headers, callback) { | ||
return getPage(link, 'prev', headers, callback) | ||
function getPreviousPage (octokit, link, headers, callback) { | ||
return getPage(octokit, link, 'prev', headers, callback) | ||
} |
module.exports = paginationPlugin | ||
function paginationPlugin (github) { | ||
github.getFirstPage = require('./get-first-page') | ||
github.getLastPage = require('./get-last-page') | ||
github.getNextPage = require('./get-next-page') | ||
github.getPreviousPage = require('./get-previous-page') | ||
github.hasFirstPage = require('./has-first-page') | ||
github.hasLastPage = require('./has-last-page') | ||
github.hasNextPage = require('./has-next-page') | ||
github.hasPreviousPage = require('./has-previous-page') | ||
function paginationPlugin (octokit) { | ||
octokit.getFirstPage = require('./get-first-page').bind(null, octokit) | ||
octokit.getLastPage = require('./get-last-page').bind(null, octokit) | ||
octokit.getNextPage = require('./get-next-page').bind(null, octokit) | ||
octokit.getPreviousPage = require('./get-previous-page').bind(null, octokit) | ||
octokit.hasFirstPage = require('./has-first-page') | ||
octokit.hasLastPage = require('./has-last-page') | ||
octokit.hasNextPage = require('./has-next-page') | ||
octokit.hasPreviousPage = require('./has-previous-page') | ||
} |
@@ -12,14 +12,13 @@ # `@octokit/plugins/*` | ||
```js | ||
const RestClient = require('@octokit/rest') | ||
const github = new RestClient() | ||
const octokit = require('@octokit/rest')() | ||
function myPlugin (github) { | ||
github.myMethod = function () { | ||
function myPlugin (octokit) { | ||
octokit.myMethod = function () { | ||
// ... | ||
} | ||
github.hook.before('request', (options) => { | ||
octokit.hook.before('request', (options) => { | ||
// change options or cancel request. | ||
// return promise for async methods | ||
}) | ||
github.hook.after('request', (result, options) => { | ||
octokit.hook.after('request', (result, options) => { | ||
// ... | ||
@@ -29,6 +28,6 @@ }) | ||
github.plugin(myPlugin) | ||
octokit.plugin(myPlugin) | ||
github.myMethod() | ||
github.request({url: '/'}) // runs before/after hooks defined above | ||
octokit.myMethod() | ||
octokit.request({url: '/'}) // runs before/after hooks defined above | ||
``` |
{ | ||
"name": "@octokit/rest", | ||
"version": "14.0.3", | ||
"version": "14.0.4", | ||
"publishConfig": { | ||
@@ -58,3 +58,4 @@ "access": "public" | ||
"standard": "^10.0.3", | ||
"standard-markdown": "^4.0.2" | ||
"standard-markdown": "^4.0.2", | ||
"typescript": "^2.6.2" | ||
}, | ||
@@ -74,2 +75,4 @@ "types": "index.d.ts", | ||
"build:ts": "node scripts/generate-typescript-types", | ||
"prevalidate:ts": "npm run -s build:ts", | ||
"validate:ts": "tsc index.d.ts", | ||
"deploy-docs": "gh-pages-with-token -d doc", | ||
@@ -76,0 +79,0 @@ "semantic-release": "semantic-release" |
@@ -117,3 +117,3 @@ # rest.js | ||
async function paginate (method) { | ||
let response = method({per_page: 100}) | ||
let response = await method({per_page: 100}) | ||
let {data} = response | ||
@@ -120,0 +120,0 @@ while (octokit.hasNextPage(response)) { |
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
557905
18
14655