caprover-api 0.0.2 → 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
@@ -2,15 +2,15 @@ https://github.com/caprover/caprover-api
2
2
 
3
3
  # Official CapRover API SDK (TypeScript)
4
4
 
5
- A simple, typed TypeScript SDK for the CapRover API.
5
+ A simple, typed Typescript SDK for the CapRover API.
6
+
7
+ EXPERIMENTAL - backward compatibility is not guaranteed.
6
8
 
7
9
  ## Install
8
10
 
11
+ ```
9
12
  npm install caprover-api
10
-
11
- csharp
12
- Copy
13
- Edit
13
+ ```
14
14
 
15
15
  ## Usage
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caprover-api",
3
- "version": "0.0.2",
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",
@@ -14,6 +14,10 @@
14
14
  "dev": "rm -rf ./dist && npx tsc && node ./dist/example.js",
15
15
  "generate-barrels": "barrelsby --directory src/models"
16
16
  },
17
+ "keywords": [
18
+ "caprover",
19
+ "api"
20
+ ],
17
21
  "repository": {
18
22
  "type": "git",
19
23
  "url": "https://github.com/caprover/caprover-api.git"
@@ -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() {