glitch-javascript-sdk 0.0.6 → 0.0.7

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.
@@ -5,10 +5,36 @@
5
5
  * API.
6
6
  */
7
7
  declare class Config {
8
- baseUrl: string;
9
- authToken: string;
10
- constructor(baseUrl: string, authToken: string);
11
- setBaseUrl(baseUrl: string): void;
12
- setAuthToken(authToken: string): void;
8
+ private static _baseUrl;
9
+ private static _authToken;
10
+ private static _baseUrlLocked;
11
+ /**
12
+ * Set the configuration
13
+ *
14
+ * @param baseUrl The url base endpoint of the api
15
+ * @param authToken The JSON Web Token
16
+ */
17
+ static setConfig(baseUrl: string, authToken: string, lock?: boolean): void;
18
+ /**
19
+ * Sets the endpoint for the API
20
+ *
21
+ * @param baseUrl The url that connects to the APIs base
22
+ * @param lock If set to true, will lock the baseUrl so it cannot be changed
23
+ */
24
+ static setBaseUrl(baseUrl: string, lock?: boolean): void;
25
+ /**
26
+ * Set the JSON Web Token (JWT) that will be passed to the API
27
+ *
28
+ * @param authToken The JWT
29
+ */
30
+ static setAuthToken(authToken: string): void;
31
+ /**
32
+ * Gets base url
33
+ */
34
+ static get baseUrl(): string;
35
+ /**
36
+ * Gets auth token
37
+ */
38
+ static get authToken(): string;
13
39
  }
14
40
  export default Config;
@@ -7,12 +7,6 @@ declare class Requests {
7
7
  private static baseUrl;
8
8
  private static authToken;
9
9
  constructor(config: Config);
10
- /**
11
- * Sets the configuration of the system.
12
- *
13
- * @param config Config The config class.
14
- */
15
- static setConfig(config: Config): void;
16
10
  /**
17
11
  * Sets the base url of the API.
18
12
  *
package/dist/index.d.ts CHANGED
@@ -7,11 +7,37 @@ import { AxiosPromise } from 'axios';
7
7
  * API.
8
8
  */
9
9
  declare class Config {
10
- baseUrl: string;
11
- authToken: string;
12
- constructor(baseUrl: string, authToken: string);
13
- setBaseUrl(baseUrl: string): void;
14
- setAuthToken(authToken: string): void;
10
+ private static _baseUrl;
11
+ private static _authToken;
12
+ private static _baseUrlLocked;
13
+ /**
14
+ * Set the configuration
15
+ *
16
+ * @param baseUrl The url base endpoint of the api
17
+ * @param authToken The JSON Web Token
18
+ */
19
+ static setConfig(baseUrl: string, authToken: string, lock?: boolean): void;
20
+ /**
21
+ * Sets the endpoint for the API
22
+ *
23
+ * @param baseUrl The url that connects to the APIs base
24
+ * @param lock If set to true, will lock the baseUrl so it cannot be changed
25
+ */
26
+ static setBaseUrl(baseUrl: string, lock?: boolean): void;
27
+ /**
28
+ * Set the JSON Web Token (JWT) that will be passed to the API
29
+ *
30
+ * @param authToken The JWT
31
+ */
32
+ static setAuthToken(authToken: string): void;
33
+ /**
34
+ * Gets base url
35
+ */
36
+ static get baseUrl(): string;
37
+ /**
38
+ * Gets auth token
39
+ */
40
+ static get authToken(): string;
15
41
  }
16
42
 
17
43
  interface Response<T> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Javascrip SDK for GLitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -7,31 +7,71 @@ import Requests from "../util/Requests";
7
7
  * API.
8
8
  */
9
9
  class Config {
10
- //The base url of the API, ie: http://api.example.com/v1/
11
- baseUrl: string;
12
10
 
13
- //The JWT token used to access the api.
14
- authToken: string;
15
-
16
- constructor(baseUrl: string, authToken: string) {
17
- this.baseUrl = baseUrl;
18
- this.authToken = authToken;
11
+ private static _baseUrl: string;
12
+ private static _authToken: string;
19
13
 
20
- Requests.setConfig(this);
21
- }
14
+ private static _baseUrlLocked: boolean = false;
15
+
16
+ /**
17
+ * Set the configuration
18
+ *
19
+ * @param baseUrl The url base endpoint of the api
20
+ * @param authToken The JSON Web Token
21
+ */
22
+ static setConfig(baseUrl: string, authToken: string, lock? : boolean) {
23
+
24
+ this.setBaseUrl(baseUrl, lock);
25
+
26
+ this.setAuthToken(authToken);
27
+
28
+ Requests.setBaseUrl(baseUrl);
29
+ Requests.setAuthToken(authToken);
30
+ }
31
+
32
+ /**
33
+ * Sets the endpoint for the API
34
+ *
35
+ * @param baseUrl The url that connects to the APIs base
36
+ * @param lock If set to true, will lock the baseUrl so it cannot be changed
37
+ */
38
+ static setBaseUrl(baseUrl: string, lock? : boolean) {
22
39
 
23
- setBaseUrl(baseUrl: string) {
24
- this.baseUrl = baseUrl;
40
+ if(!this._baseUrlLocked) {
41
+ Config._baseUrl = baseUrl;
25
42
 
26
43
  Requests.setBaseUrl(baseUrl);
27
44
  }
28
45
 
29
- setAuthToken(authToken: string) {
30
- this.authToken = authToken;
31
-
32
- Requests.setAuthToken(authToken);
46
+ if(lock) {
47
+ this._baseUrlLocked = true;
33
48
  }
49
+ }
50
+
51
+ /**
52
+ * Set the JSON Web Token (JWT) that will be passed to the API
53
+ *
54
+ * @param authToken The JWT
55
+ */
56
+ static setAuthToken(authToken: string) {
57
+ Config._authToken = authToken;
58
+
59
+ Requests.setAuthToken(authToken);
60
+ }
61
+
62
+ /**
63
+ * Gets base url
64
+ */
65
+ static get baseUrl(): string {
66
+ return Config._baseUrl;
67
+ }
34
68
 
69
+ /**
70
+ * Gets auth token
71
+ */
72
+ static get authToken(): string {
73
+ return Config._authToken;
35
74
  }
75
+ }
36
76
 
37
- export default Config;
77
+ export default Config;
@@ -19,18 +19,6 @@ class Requests {
19
19
  this.config = config;
20
20
  }
21
21
 
22
- /**
23
- * Sets the configuration of the system.
24
- *
25
- * @param config Config The config class.
26
- */
27
- public static setConfig(config: Config) {
28
-
29
- this.baseUrl = config.baseUrl;
30
-
31
- this.authToken = config.authToken;
32
- }
33
-
34
22
  /**
35
23
  * Sets the base url of the API.
36
24
  *