badmfck-api-server 1.7.5 → 1.7.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.
@@ -12,5 +12,7 @@ export declare class DataProvider<T> {
12
12
  data: T | null | undefined;
13
13
  error?: boolean;
14
14
  }>, cacheTime?: number, name?: string);
15
+ forceUpdate(): void;
16
+ localUpdate(data: T): void;
15
17
  getData(): Promise<T | null | undefined>;
16
18
  }
@@ -24,6 +24,20 @@ class DataProvider {
24
24
  if (!this.name)
25
25
  this.name = "DataProvider " + (DataProvider.nextID++);
26
26
  }
27
+ forceUpdate() {
28
+ if (this.busy)
29
+ return;
30
+ this.wasError = false;
31
+ this.lastRequestTime = 0;
32
+ this.getData();
33
+ }
34
+ localUpdate(data) {
35
+ if (this.busy)
36
+ return;
37
+ this.wasError = false;
38
+ this.lastRequestTime = +new Date();
39
+ this.data = data;
40
+ }
27
41
  async getData() {
28
42
  if (this.busy)
29
43
  return new Promise((resolve, reject) => this.callbacks.subscribe((d) => resolve(d)));
@@ -12,9 +12,9 @@ class ErrorUtils {
12
12
  const isFieldsExists = Validator_1.Validator.validateObject(['code', 'message'], obj);
13
13
  if (!isFieldsExists)
14
14
  return false;
15
- if (Validator_1.Validator.validateValue("code", { type: "number" }) !== Validator_1.ValidationReport.OK)
15
+ if (Validator_1.Validator.validateValue(obj.code, { type: "number" }) !== Validator_1.ValidationReport.OK)
16
16
  return false;
17
- if (Validator_1.Validator.validateValue("message", { type: "string" }) !== Validator_1.ValidationReport.OK)
17
+ if (Validator_1.Validator.validateValue(obj.message, { type: "string" }) !== Validator_1.ValidationReport.OK)
18
18
  return false;
19
19
  return true;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",