spice-js 2.5.4 → 2.5.8

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.
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -16,8 +14,11 @@ var path = require('path');
16
14
  var open = require("open");
17
15
 
18
16
  class File {
19
- constructor() {
20
- var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
+ constructor(args) {
18
+ if (args === void 0) {
19
+ args = {};
20
+ }
21
+
21
22
  this.sender = args.sender;
22
23
  this.subject = args.subject;
23
24
  this.htmlText = args.htmlText;
@@ -28,12 +29,14 @@ class File {
28
29
  }
29
30
  }
30
31
 
31
- send(htmlText) {
32
- var _arguments = arguments,
33
- _this = this;
32
+ send(htmlText, options) {
33
+ var _this = this;
34
34
 
35
35
  return _asyncToGenerator(function* () {
36
- var options = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
36
+ if (options === void 0) {
37
+ options = {};
38
+ }
39
+
37
40
  var email = {
38
41
  to: options.to,
39
42
  from: options.sender || _this.sender,
@@ -41,8 +44,8 @@ class File {
41
44
  htmlText: htmlText || _this.htmlText
42
45
  };
43
46
  var time = new Date().getTime();
44
- fs.ensureDirSync("".concat(_this.dest, "/").concat(email.subject, "/").concat(time));
45
- var full_path = "".concat(_this.dest, "/").concat(email.subject, "/").concat(time, "/to:").concat(email.to, " from:").concat(email.from, ".html");
47
+ fs.ensureDirSync(_this.dest + "/" + email.subject + "/" + time);
48
+ var full_path = _this.dest + "/" + email.subject + "/" + time + "/to:" + email.to + " from:" + email.from + ".html";
46
49
  fs.writeFileSync(full_path, email.htmlText);
47
50
  open(full_path);
48
51
  })();
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  var _2 = require("..");
9
7
 
10
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
11
-
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
9
 
16
10
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
17
11
 
@@ -42,13 +36,15 @@ if (!Promise.allSettled) {
42
36
  }
43
37
 
44
38
  class SpiceModel {
45
- constructor() {
46
- var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
39
+ constructor(args) {
40
+ if (args === void 0) {
41
+ args = {};
42
+ }
47
43
 
48
44
  try {
49
45
  var dbtype = spice.config.database.connections[args.connection].type || "couchbase";
50
46
 
51
- var Database = require("spice-".concat(dbtype));
47
+ var Database = require("spice-" + dbtype);
52
48
 
53
49
  this.type = "";
54
50
  this[_hooks] = {
@@ -214,11 +210,11 @@ class SpiceModel {
214
210
  }
215
211
 
216
212
  if (i == "requires") {
217
- returnVal.push("shouldExist:".concat(props[i]));
213
+ returnVal.push("shouldExist:" + props[i]);
218
214
  }
219
215
 
220
216
  if (i == "unique") {
221
- returnVal.push("unique:".concat(this.constructor.name, ",").concat(property_name));
217
+ returnVal.push("unique:" + this.constructor.name + "," + property_name);
222
218
  }
223
219
 
224
220
  if (i == "type") {
@@ -298,13 +294,16 @@ class SpiceModel {
298
294
  return _.join(returnVal, "|");
299
295
  }
300
296
 
301
- getValidationRules() {
302
- var method = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "POST";
297
+ getValidationRules(method, _temp) {
298
+ if (method === void 0) {
299
+ method = "POST";
300
+ }
301
+
303
302
  var {
304
303
  complete = false,
305
304
  pick = [],
306
305
  omit = []
307
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
306
+ } = _temp === void 0 ? {} : _temp;
308
307
  var rules = {};
309
308
  var filters = {};
310
309
  var working_properties = this.props;
@@ -402,7 +401,7 @@ class SpiceModel {
402
401
  var results = yield _this.database.get(args.id);
403
402
 
404
403
  if (results.type != _this.type) {
405
- throw new Error("".concat(_this.type, " does not exist"));
404
+ throw new Error(_this.type + " does not exist");
406
405
  }
407
406
 
408
407
  if (results.deleted == undefined || results.deleted == false) {
@@ -410,7 +409,7 @@ class SpiceModel {
410
409
  results = yield _this.do_serialize(results, "read", {}, args);
411
410
  return results;
412
411
  } else {
413
- throw new Error("".concat(_this.type, " does not exist"));
412
+ throw new Error(_this.type + " does not exist");
414
413
  }
415
414
  }
416
415
  } catch (e) {
@@ -497,7 +496,7 @@ class SpiceModel {
497
496
  var item_exist = yield _this5.exist(results);
498
497
 
499
498
  if (!item_exist) {
500
- throw new Error("".concat(_this5.type, " does not exist."));
499
+ throw new Error(_this5.type + " does not exist.");
501
500
  }
502
501
 
503
502
  delete results["id"];
@@ -523,7 +522,7 @@ class SpiceModel {
523
522
  yield _this5.database.update(args.id, form || _this5);
524
523
 
525
524
  if (args.skip_hooks != true) {
526
- yield _this5.run_hook(_objectSpread(_objectSpread({}, _this5), {}, {
525
+ yield _this5.run_hook(_extends({}, _this5, {
527
526
  id: args.id
528
527
  }), "update", "after");
529
528
  }
@@ -533,7 +532,7 @@ class SpiceModel {
533
532
  }
534
533
 
535
534
  _this5.id = args.id;
536
- return _objectSpread(_objectSpread({}, form), {}, {
535
+ return _extends({}, form, {
537
536
  id: args.id
538
537
  });
539
538
  } catch (e) {
@@ -560,7 +559,7 @@ class SpiceModel {
560
559
 
561
560
  var workingForm = form || _this6;
562
561
  _this6.updated_at = new SDate().now();
563
- var id = "".concat(args.id_prefix, "-").concat(UUID.v4());
562
+ var id = args.id_prefix + "-" + UUID.v4();
564
563
 
565
564
  if (args && args.id) {
566
565
  id = args.id;
@@ -569,11 +568,11 @@ class SpiceModel {
569
568
  yield _this6.run_hook(workingForm, "create", "before");
570
569
  workingForm = yield _this6.do_serialize(workingForm, "write", {}, args);
571
570
  var results = yield _this6.database.insert(id, workingForm, args.expiry);
572
- yield _this6.run_hook(_objectSpread(_objectSpread({}, results), {}, {
571
+ yield _this6.run_hook(_extends({}, results, {
573
572
  id
574
573
  }), "create", "after");
575
574
  results = yield _this6.do_serialize(results, "read", {}, args);
576
- return _objectSpread(_objectSpread({}, results), {}, {
575
+ return _extends({}, results, {
577
576
  id
578
577
  });
579
578
  } catch (e) {
@@ -590,7 +589,7 @@ class SpiceModel {
590
589
  var item_exist = yield _this7.exist(args.id);
591
590
 
592
591
  if (!item_exist) {
593
- throw new Error("".concat(_this7.type, " does not exist."));
592
+ throw new Error(_this7.type + " does not exist.");
594
593
  }
595
594
 
596
595
  try {
@@ -857,7 +856,7 @@ class SpiceModel {
857
856
  when: properties[i].map.when || "read",
858
857
  execute: function () {
859
858
  var _execute = _asyncToGenerator(function* (data) {
860
- return yield _this10.mapToObject(data, properties[i].map.reference, i, properties[i].map.destination || i, properties[i]);
859
+ return yield _this10.mapToObject(data, _.isString(properties[i].map.reference) ? spice.models[properties[i].map.reference] : properties[i].map.reference, i, properties[i].map.destination || i, properties[i]);
861
860
  });
862
861
 
863
862
  function execute(_x) {
@@ -878,7 +877,8 @@ class SpiceModel {
878
877
  when: properties[i].map.when || "read",
879
878
  execute: function () {
880
879
  var _execute2 = _asyncToGenerator(function* (data) {
881
- return yield _this10.mapToObjectArray(data, properties[i].map.reference, i, properties[i].map.destination || i, properties[i]);
880
+ console.log(_.isString(properties[i].map.reference), _.isString(properties[i].map.reference) ? spice.models[properties[i].map.reference] : properties[i].map.reference, spice.models, properties[i].map.reference);
881
+ return yield _this10.mapToObjectArray(data, _.isString(properties[i].map.reference) ? spice.models[properties[i].map.reference] : properties[i].map.reference, i, properties[i].map.destination || i, properties[i]);
882
882
  });
883
883
 
884
884
  function execute(_x2) {
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  var _lodash = _interopRequireDefault(require("lodash"));
@@ -13,15 +11,18 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
13
11
 
14
12
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
13
 
16
- var views = require('koa-views');
14
+ var views = require("koa-views");
17
15
 
18
16
  var path = require("path");
19
17
 
20
- var juice = require('juice');
18
+ var juice = require("juice");
21
19
 
22
20
  class Storage {
23
- constructor() {
24
- var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
+ constructor(args) {
22
+ if (args === void 0) {
23
+ args = {};
24
+ }
25
+
25
26
  this.driver_name = args.driver_name || spice.config.storage.default_driver;
26
27
  this.driver_options = _lodash.default.merge(spice.config.storage.drivers[this.driver_name], args.options); //console.log(this.driver_name, spice.config.storage.providers)
27
28
 
@@ -46,7 +47,7 @@ class Storage {
46
47
  var driver = new _this.Driver(_this.driver_options);
47
48
  return yield driver.save({
48
49
  files,
49
- path
50
+ path: _this.driver_options.base_path ? _this.driver_options.base_path + "/" + path : path
50
51
  });
51
52
  })();
52
53
  }
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -10,17 +8,22 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
10
8
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
9
 
12
10
  class Mail {
13
- constructor() {
14
- var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11
+ constructor(args) {
12
+ if (args === void 0) {
13
+ args = {};
14
+ }
15
+
15
16
  this.options = args;
16
17
  }
17
18
 
18
- send(file) {
19
- var _arguments = arguments,
20
- _this = this;
19
+ send(file, options) {
20
+ var _this = this;
21
21
 
22
22
  return _asyncToGenerator(function* () {
23
- var options = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
23
+ if (options === void 0) {
24
+ options = {};
25
+ }
26
+
24
27
  var email = {
25
28
  to: options.to,
26
29
  from: options.sender || _this.sender,
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  var _lodash = _interopRequireDefault(require("lodash"));
@@ -22,8 +20,11 @@ var open = require("open");
22
20
  var uuid = require('uuid');
23
21
 
24
22
  class Local {
25
- constructor() {
26
- var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
+ constructor(args) {
24
+ if (args === void 0) {
25
+ args = {};
26
+ }
27
+
27
28
  this.args = args;
28
29
  }
29
30
 
@@ -84,12 +85,12 @@ class Local {
84
85
 
85
86
  var file_name = _lodash.default.last(uuid.v4().split("-"));
86
87
 
87
- var writeStream = fs.createWriteStream("".concat(path, "/").concat(file_name, ".").concat(extension));
88
+ var writeStream = fs.createWriteStream(path + "/" + file_name + "." + extension);
88
89
  item.readStream.pipe(writeStream);
89
90
  item.readStream.on("end", function (err) {
90
91
  fs.unlink(item.file.path, function (obj) {});
91
92
  });
92
- return "".concat(path, "/").concat(file_name, ".").concat(extension);
93
+ return path + "/" + file_name + "." + extension;
93
94
  });
94
95
 
95
96
  if (paths.length == 1) {
@@ -3,9 +3,7 @@
3
3
  * Created by chadfraser on 12/12/15.
4
4
  */
5
5
 
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
6
+ exports.__esModule = true;
9
7
  exports.default = void 0;
10
8
 
11
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  class DataType {}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  class MapType {}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
 
8
6
  var _flat = _interopRequireDefault(require("flat"));
@@ -78,8 +76,8 @@ class RestHelper {
78
76
  }
79
77
 
80
78
  makeDirectory("./storage/exports");
81
- makeDirectory("./storage/exports/".concat(download_type, "/"));
82
- var file = path.resolve("./storage/exports/".concat(download_type, "/").concat(RestHelper.makeid(9), ".").concat(download_type));
79
+ makeDirectory("./storage/exports/" + download_type + "/");
80
+ var file = path.resolve("./storage/exports/" + download_type + "/" + RestHelper.makeid(9) + "." + download_type);
83
81
  yield fs.writeFile(file, content, function (err) {
84
82
  if (err) throw err;
85
83
  });
@@ -107,11 +105,14 @@ class RestHelper {
107
105
  return result;
108
106
  }
109
107
 
110
- static prepare_collection(status) {
111
- var obj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
112
- data: [],
113
- total: null
114
- };
108
+ static prepare_collection(status, obj) {
109
+ if (obj === void 0) {
110
+ obj = {
111
+ data: [],
112
+ total: null
113
+ };
114
+ }
115
+
115
116
  var data = {
116
117
  status: status,
117
118
  type: "collection",
@@ -3,9 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
6
+ exports.__esModule = true;
9
7
  exports.default = void 0;
10
8
 
11
9
  var _ = require('lodash');
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.copy = copy;
7
5
  exports.default = void 0;
8
6
 
@@ -4,7 +4,7 @@ var Rules = spice.classes.validate.Rules;
4
4
 
5
5
  Rules.prototype.shouldExist = function* (field, value, args, message) {
6
6
  try {
7
- var loaded = require(spice.root_path + "/models/".concat(args));
7
+ var loaded = require(spice.root_path + ("/models/" + args));
8
8
 
9
9
  var Class = loaded.default;
10
10
  var obj = new Class();
@@ -22,12 +22,12 @@ Rules.prototype.shouldExist = function* (field, value, args, message) {
22
22
 
23
23
  Rules.prototype.unique = function* (field, value, args, message) {
24
24
  try {
25
- var loaded = require(spice.root_path + "/models/".concat(args[0]));
25
+ var loaded = require(spice.root_path + ("/models/" + args[0]));
26
26
 
27
27
  var Class = loaded.default;
28
28
  var obj = new Class();
29
29
  var found = yield obj.list({
30
- query: "".concat(args[1], " = \"").concat(value, "\"")
30
+ query: args[1] + " = \"" + value + "\""
31
31
  });
32
32
 
33
33
  if (found.data.length == 0) {
package/gulpfile.js CHANGED
@@ -1,34 +1,37 @@
1
- var gulp = require('gulp');
2
- var babel = require('gulp-babel');
1
+ var gulp = require("gulp");
2
+ var babel = require("gulp-babel");
3
3
  var paths = {};
4
- paths.src = './src/**/*.js';
4
+ paths.src = "./src/**/*.js";
5
5
 
6
- gulp.task('build_spice', () =>
7
- gulp.src(paths.src)
8
- .pipe(babel({
9
- presets: [
10
- [
11
- "@babel/preset-env",
12
- {
13
- "targets": {
14
- "esmodules": true,
15
- "node": "current",
6
+ gulp.task("build_spice", () =>
7
+ gulp
8
+ .src(paths.src)
9
+ .pipe(
10
+ babel({
11
+ presets: [
12
+ [
13
+ "@babel/preset-env",
14
+ {
15
+ loose: true,
16
+ targets: {
17
+ esmodules: true,
18
+ node: "current",
19
+ },
16
20
  },
17
-
18
- },
21
+ ],
22
+ ],
23
+ plugins: [
24
+ ["@babel/plugin-proposal-class-properties", { loose: true }],
25
+ ["@babel/plugin-proposal-export-namespace-from", { loose: true }],
26
+ ["@babel/plugin-proposal-export-default-from", { loose: true }],
19
27
  ],
20
- ],
21
- plugins: [
22
- ['@babel/plugin-proposal-class-properties', { "loose": true }],
23
- "@babel/plugin-proposal-export-namespace-from",
24
- "@babel/plugin-proposal-export-default-from",
25
- ],
26
- }))
27
- .pipe(gulp.dest('build'))
28
+ })
29
+ )
30
+ .pipe(gulp.dest("build"))
28
31
  );
29
32
 
30
33
  // Default task
31
- gulp.task('default', gulp.series('build_spice'));
32
- gulp.task('watch', function () {
33
- gulp.watch(paths.src, gulp.series('build_spice'));
34
+ gulp.task("default", gulp.series("build_spice"));
35
+ gulp.task("watch", function () {
36
+ gulp.watch(paths.src, gulp.series("build_spice"));
34
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.5.4",
3
+ "version": "2.5.8",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -15,6 +15,7 @@
15
15
  "license": "ISC",
16
16
  "dependencies": {
17
17
  "agenda": "^3.1.0",
18
+ "caniuse-lite": "^1.0.30001283",
18
19
  "co": "^4.6.0",
19
20
  "dotenv": "^8.2.0",
20
21
  "flat": "^5.0.0",
@@ -1,9 +1,9 @@
1
1
  import path from "path";
2
2
  import _ from "lodash";
3
- const EventEmitter = require("events").EventEmitter;
4
- const myEmitter = new EventEmitter();
3
+ const EventEmitter = require("events");
4
+ class MyEmitter extends EventEmitter { }
5
+ const myEmitter = new MyEmitter();
5
6
  spice.EventEmitter = myEmitter;
6
-
7
7
  let eventingManifest = require(path.resolve(
8
8
  path.join(spice.root_path, "/eventing/manifest.js")
9
9
  ));
@@ -16,7 +16,6 @@ _.each(eventingManifest.default, (entry) => {
16
16
  new entry.event().driver || spice.config.event.default_driver
17
17
  ];
18
18
  let processor = new Processor();
19
- console.log(processor);
20
19
  _.each(entry.handlers, (handler) => {
21
20
  processor.on(topic, new handler().handle);
22
21
  });
@@ -0,0 +1,18 @@
1
+ import path from "path";
2
+
3
+ try {
4
+ let resources = ["models", "controllers", "schemas"];
5
+ resources.every((resource) => {
6
+ let paths = path.join(spice.root_path, resource);
7
+ spice[resource] = {};
8
+ require("fs")
9
+ .readdirSync(paths)
10
+ .forEach(async function (file) {
11
+ spice[resource][file.split(".")[0]] = (
12
+ await import(path.join(paths, file))
13
+ ).default;
14
+ });
15
+ });
16
+ } catch (error) {
17
+ console.log(error);
18
+ }
@@ -1,11 +1,11 @@
1
- import io from "socket.io-client";
2
- export default class SpiceEventDriver {
3
- dispatch({ topic, data } = {}) {
1
+ //import io from "socket.io-client";
2
+ export default class SocketEventDriver {
3
+ /*dispatch({ topic, data } = {}) {
4
4
  spice.io.broadcast(topic, data);
5
5
  }
6
6
 
7
7
  on(topic, callback) {
8
8
  var socket = io("http://localhost:3005");
9
9
  socket.on(topic, callback);
10
- }
10
+ }*/
11
11
  }
@@ -1,4 +1,4 @@
1
- export default class SocketEventDriver {
1
+ export default class SpiceEventDriver {
2
2
  dispatch({ topic, data } = {}) {
3
3
  spice.EventEmitter.emit(topic, data);
4
4
  }
package/src/index.js CHANGED
@@ -74,6 +74,12 @@ export default class Spice {
74
74
 
75
75
  io.attach(app);
76
76
  spice.io = io;
77
+ io.on("message", (ctx, data) => {
78
+ console.log("client sent data to message endpoint", data);
79
+ });
80
+ app._io.on("connection", (sock) => {
81
+ console.log("Connection Up", sock);
82
+ });
77
83
  app.use(
78
84
  koaSwagger({
79
85
  hideTopbar: true,