Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Enterprise setting as env var #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,12 @@ To use the Enterprise APIs add the root URL when instantiating Octokat:
```js
var octo = new Octokat({
token: 'API_TOKEN',
rootURL: 'https://example.com/api/v3'
githubEndpoint: 'https://example.com/api/v3'
})
```

You can also set the githubEndpoint as an environmental token called `GITHUB_ENDPOINT`.

## Using EcmaScript 6 Generators

This requires Node.js 0.11 with the `--harmony-generators` flag:
Expand Down
6 changes: 3 additions & 3 deletions dist/octokat.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/requester.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = class Requester {
// Provide an option to override the default URL
this._instance = _instance
this._clientOptions = _clientOptions
if (this._clientOptions.rootURL == null) { this._clientOptions.rootURL = 'https://api.github.com' }
if (this._clientOptions.githubEndpoint == null) { this._clientOptions.githubEndpoint = process.env.GITHUB_ENDPOINT || 'https://api.github.com' }
if (this._clientOptions.useETags == null) { this._clientOptions.useETags = true }
if (this._clientOptions.usePostInsteadOfPatch == null) { this._clientOptions.usePostInsteadOfPatch = false }
if (this._clientOptions.userAgent == null) {
Expand Down Expand Up @@ -53,7 +53,7 @@ module.exports = class Requester {

// Only prefix the path when it does not begin with http.
// This is so pagination works (which provides absolute URLs).
if (!/^http/.test(path)) { path = `${this._clientOptions.rootURL}${path}` }
if (!/^http/.test(path)) { path = `${this._clientOptions.githubEndpoint}${path}` }

let headers = {
'Accept': this._clientOptions.acceptHeader || 'application/json',
Expand Down