-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e09f28
commit 9e87337
Showing
42 changed files
with
224 additions
and
1,150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { ArgumentError } = require('rest-facade'); | ||
const Auth0RestClient = require('../Auth0RestClient'); | ||
const RetryRestClient = require('../RetryRestClient'); | ||
|
||
class BaseManager { | ||
constructor(options) { | ||
if (options === null || typeof options !== 'object') { | ||
throw new ArgumentError('Must provide manager options'); | ||
} | ||
|
||
if (options.baseUrl === null || options.baseUrl === undefined) { | ||
throw new ArgumentError('Must provide a base URL for the API'); | ||
} | ||
|
||
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { | ||
throw new ArgumentError('The provided base URL is invalid'); | ||
} | ||
|
||
this._options = options; | ||
} | ||
|
||
_getRestClient(path) { | ||
const options = this._options; | ||
const clientOptions = { | ||
errorFormatter: { message: 'message', name: 'error' }, | ||
headers: options.headers, | ||
query: { repeatParams: false }, | ||
}; | ||
|
||
const usersAuth0RestClient = new Auth0RestClient( | ||
`${options.baseUrl}${path}`, | ||
clientOptions, | ||
options.tokenProvider | ||
); | ||
return new RetryRestClient(usersAuth0RestClient, options.retry); | ||
} | ||
} | ||
|
||
module.exports = BaseManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.