File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,20 @@ const newUser = await warrantClient.User.create({
6666});
6767```
6868
69+ ## Configuring the API Endpoint
70+ ---
71+ The API endpoint the SDK makes requests to is configurable via the ` endpoint ` attribute when initializing the client:
72+
73+ ``` js
74+ import { WarrantClient } from " @warrantdev/warrant-node" ;
75+
76+ // Set api and authorize endpoints to http://localhost:8000
77+ const warrantClient = new WarrantClient ({
78+ apiKey: " api_test_f5dsKVeYnVSLHGje44zAygqgqXiLJBICbFzCiAg1E=" ,
79+ endpoint: " http://localhost:8000" ,
80+ });
81+ ```
82+
6983## Authorization
7084
7185All access checks are performed based on an ` object ` , ` relation ` and ` subject ` . You can pass your own defined objects to the check methods by implementing the ` WarrantObject ` interface.
Original file line number Diff line number Diff line change @@ -92,14 +92,15 @@ export default class ApiClient implements HttpClient {
9292 const fetchRequestOptions : FetchRequestOptions = {
9393 method,
9494 headers : {
95- Authorization : `ApiKey ${ this . config . apiKey } ` ,
9695 'User-Agent' : `warrant-node/${ version } ` ,
9796 'Content-Type' : "application/json"
9897 } ,
9998 } ;
10099
101100 if ( requestOptions ?. apiKey ) {
102101 fetchRequestOptions . headers [ 'Authorization' ] = `ApiKey ${ requestOptions . apiKey } ` ;
102+ } else if ( this . config . apiKey ) {
103+ fetchRequestOptions . headers [ 'Authorization' ] = `ApiKey ${ this . config . apiKey } ` ;
103104 }
104105
105106 if ( requestOptions ?. baseUrl ) {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var assert = require('assert');
44// Uncomment .skip and add your API_KEY to run tests
55describe . skip ( 'Live Test' , function ( ) {
66 before ( function ( ) {
7- this . warrant = new WarrantClient ( { apiKey : "YOUR_KEY " } ) ;
7+ this . warrant = new WarrantClient ( { apiKey : "" , endpoint : "https://api.warrant.dev " } ) ;
88 } ) ;
99
1010 it ( 'CRUD users' , async function ( ) {
You can’t perform that action at this time.
0 commit comments