@cntrl-site/sdk 0.0.3 → 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.
- package/lib/client/Client.js +6 -0
- package/package.json +2 -2
- package/src/client/Client.ts +8 -1
package/lib/client/Client.js
CHANGED
|
@@ -11,6 +11,12 @@ class Client {
|
|
|
11
11
|
this.projectId = projectId;
|
|
12
12
|
this.APIUrl = APIUrl;
|
|
13
13
|
this.fetchImpl = fetchImpl;
|
|
14
|
+
if (projectId.length === 0) {
|
|
15
|
+
throw new Error('CNTRL SDK: Project ID is empty. Did you forget to pass it?');
|
|
16
|
+
}
|
|
17
|
+
if (APIUrl.length === 0) {
|
|
18
|
+
throw new Error('CNTRL SDK: API URL is empty. Did you forget to pass it?');
|
|
19
|
+
}
|
|
14
20
|
}
|
|
15
21
|
async getProject() {
|
|
16
22
|
const response = await this.fetchImpl(`${this.APIUrl}/projects/${this.projectId}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Generic SDK for use in public websites.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lib": "lib"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@cntrl-site/core": "^1.0.
|
|
27
|
+
"@cntrl-site/core": "^1.0.9",
|
|
28
28
|
"@types/isomorphic-fetch": "^0.0.36",
|
|
29
29
|
"isomorphic-fetch": "^3.0.0"
|
|
30
30
|
},
|
package/src/client/Client.ts
CHANGED
|
@@ -6,7 +6,14 @@ export class Client {
|
|
|
6
6
|
private projectId: string,
|
|
7
7
|
private APIUrl: string,
|
|
8
8
|
private fetchImpl = fetch
|
|
9
|
-
) {
|
|
9
|
+
) {
|
|
10
|
+
if (projectId.length === 0) {
|
|
11
|
+
throw new Error('CNTRL SDK: Project ID is empty. Did you forget to pass it?');
|
|
12
|
+
}
|
|
13
|
+
if (APIUrl.length === 0) {
|
|
14
|
+
throw new Error('CNTRL SDK: API URL is empty. Did you forget to pass it?');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
10
17
|
|
|
11
18
|
async getProject(): Promise<TProject> {
|
|
12
19
|
const response = await this.fetchImpl(`${this.APIUrl}/projects/${this.projectId}`);
|