@octokit/request
Advanced tools
Comparing version 1.0.0 to 1.1.0
31
index.js
@@ -1,25 +0,28 @@ | ||
module.exports = restRequest | ||
const restEndpoint = require('@octokit/endpoint') | ||
const endpoint = require('@octokit/endpoint') | ||
const fetch = require('node-fetch').default | ||
const getUserAgent = require('universal-user-agent') | ||
const request = require('./lib/request') | ||
const getUserAgent = require('universal-user-agent') | ||
const version = require('./package.json').version | ||
const userAgent = `octokit-request.js/${version} ${getUserAgent()}` | ||
function restRequest (route, options) { | ||
const requestOptions = restEndpoint.apply(null, arguments) | ||
function octokitRequest (endpoint, route, options) { | ||
return request(module.exports.fetch, endpoint(route, options)) | ||
} | ||
// override the default user-agent header set by @octokit/endpoit | ||
if (/^octokit-endpoint.js/.test(requestOptions.headers['user-agent'])) { | ||
requestOptions.headers['user-agent'] = userAgent | ||
function withDefaults (oldEndpoint, newDefaults) { | ||
const endpoint = oldEndpoint.defaults(newDefaults) | ||
const request = octokitRequest.bind(null, endpoint) | ||
request.endpoint = endpoint | ||
request.defaults = withDefaults.bind(null, endpoint) | ||
return request | ||
} | ||
module.exports = withDefaults(endpoint, { | ||
headers: { | ||
'user-agent': userAgent | ||
} | ||
}) | ||
return request(module.exports.fetch, requestOptions) | ||
} | ||
// expose internally used `fetch` method for testing/mocking only | ||
module.exports.fetch = fetch |
{ | ||
"name": "@octokit/request", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -236,3 +236,3 @@ # request.js | ||
const myOctokitRequest = require('@octokit/request').defaults({ | ||
baseUrl: 'http://github-enterprise.acme-inc.com/api/v3', | ||
baseUrl: 'https://github-enterprise.acme-inc.com/api/v3', | ||
headers: { | ||
@@ -253,3 +253,3 @@ 'user-agent': 'myApp/1.2.3', | ||
const myProjectRequest = request.defaults({ | ||
baseUrl: 'http://github-enterprise.acme-inc.com/api/v3', | ||
baseUrl: 'https://github-enterprise.acme-inc.com/api/v3', | ||
headers: { | ||
@@ -271,2 +271,6 @@ 'user-agent': 'myApp/1.2.3' | ||
## `request.endpoint` | ||
See https://github.com/octokit/endpoint.js | ||
## Special cases | ||
@@ -273,0 +277,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
326
33076
13
448
4