spice-js 2.6.9 → 2.6.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.6.9",
3
+ "version": "2.6.10",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -4,18 +4,20 @@ async function connect() {
4
4
  try {
5
5
  spice.cache_providers = {};
6
6
  spice.monitor = new Map();
7
- for (let key of Object.keys(spice.config.cache.providers)) {
8
- spice.cache_providers[key] = new spice.config.cache.providers[key](
9
- spice.config.cache.drivers[key] || {}
10
- );
11
- spice.cache_providers[key]
12
- .initialize()
13
- .then(() => {
14
- console.log("Redis initialized successfully");
15
- })
16
- .catch((err) => {
17
- console.error("Error initializing Redis:", err);
18
- });
7
+ if (spice.config?.cache?.providers) {
8
+ for (let key of Object.keys(spice.config.cache?.providers || {})) {
9
+ spice.cache_providers[key] = new spice.config.cache.providers[key](
10
+ spice.config.cache.drivers[key] || {}
11
+ );
12
+ spice.cache_providers[key]
13
+ .initialize()
14
+ .then(() => {
15
+ console.log("Redis initialized successfully");
16
+ })
17
+ .catch((err) => {
18
+ console.error("Error initializing Redis:", err);
19
+ });
20
+ }
19
21
  }
20
22
  } catch (e) {
21
23
  console.log(e.stack);
@@ -188,12 +188,16 @@ export default class SpiceModel {
188
188
  }
189
189
 
190
190
  if (this[_ctx]) {
191
- let returned = await new this[_ctx].state.process_fields().process(
192
- this[_ctx],
193
- data,
194
- this.type
195
- );
196
- return returned;
191
+ if (this[_ctx]?.state?.process_fields) {
192
+ let returned = await new this[_ctx].state.process_fields().process(
193
+ this[_ctx],
194
+ data,
195
+ this.type
196
+ );
197
+ return returned;
198
+ } else {
199
+ return data;
200
+ }
197
201
  }
198
202
  return [];
199
203
  }
@@ -484,6 +488,7 @@ export default class SpiceModel {
484
488
  }
485
489
  }
486
490
  } catch (e) {
491
+ console.log(e.message, e);
487
492
  throw e;
488
493
  }
489
494
  }