caprover-api 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,8 @@ https://github.com/caprover/caprover-api
4
4
 
5
5
  A simple, typed Typescript SDK for the CapRover API.
6
6
 
7
+ EXPERIMENTAL - backward compatibility is not guaranteed.
8
+
7
9
  ## Install
8
10
 
9
11
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caprover-api",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "API client for CapRover",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -43,13 +43,18 @@ export default class ApiManager {
43
43
 
44
44
  constructor(
45
45
  baseDomain: string,
46
- private authCallback: AuthRequiredCallback
46
+ private authCallback: AuthRequiredCallback,
47
+ private authToken?: string
47
48
  ) {
48
49
  const self = this
49
50
  const URL = baseDomain + '/api/v2'
50
- this.http = new HttpClient(URL, function () {
51
- return self.getAuthToken()
52
- })
51
+ this.http = new HttpClient(
52
+ URL,
53
+ function () {
54
+ return self.getAuthToken()
55
+ },
56
+ authToken
57
+ )
53
58
  }
54
59
 
55
60
  destroy() {
@@ -9,13 +9,15 @@ export default class HttpClient {
9
9
  public readonly GET = 'GET'
10
10
  public readonly POST = 'POST'
11
11
  public isDestroyed = false
12
- private authToken: string = ''
13
12
 
14
13
  constructor(
15
14
  private baseUrl: string,
16
- private onAuthFailure: () => Promise<string>
15
+ private onAuthFailure: () => Promise<string>,
16
+ private authToken?: string
17
17
  ) {
18
- //
18
+ if (!authToken) {
19
+ this.authToken = ''
20
+ }
19
21
  }
20
22
 
21
23
  createHeaders() {