Comparing version 1.0.0 to 1.0.1
@@ -0,5 +1,13 @@ | ||
const path = require('path'); | ||
const isArray = require('lodash/isArray'); | ||
const isString = require('lodash/isString'); | ||
const isFunction = require('lodash/isFunction'); | ||
const RedboneError = require('../Errors/RedboneError'); | ||
const dispatcher = require('./dispatcher'); | ||
const Socket = require('Socket'); | ||
const Socket = require('./Socket'); | ||
const scandir = require('./scandir'); | ||
const handleError = require('./handleError'); | ||
const intel = require('../middlewares/intel'); | ||
const handleError = require('./handleError'); | ||
@@ -50,3 +58,3 @@ /** | ||
/** | ||
* catch proxy to dispatcher.watch | ||
* watch proxy to dispatcher.watch | ||
* @param {String} type action.type of redux action object | ||
@@ -61,3 +69,22 @@ * @param {Function} fn callback function to process watched data (socket, action, next) | ||
/** | ||
* Watchers autoloader | ||
* Read files in the dir dirrectory, and add watchers from them to redbone watch | ||
* @param {String} dir path to dir | ||
* @return {Promise} | ||
*/ | ||
redbone.readWatchers = function readWatchers(dir) { | ||
return scandir(dir, function(file) { | ||
const watchers = require(path.join(dir, file)); | ||
if (!isArray(watchers)) throw new RedboneError('Watchers is not an array'); | ||
watchers.forEach((watcher) => { | ||
if (!(watcher.type && isString(watcher.type))) throw new RedboneError('Watcher type is not defined'); | ||
if (!(watcher.action && isFunction(watcher.action))) throw new RedboneError('Watcher action is not defined'); | ||
redbone.watch(watcher.type, watcher.action); | ||
}); | ||
}); | ||
} | ||
redbone.dispatcher = dispatcher; | ||
redbone.Socket = Socket; | ||
redbone.RedboneError = RedboneError; |
{ | ||
"name": "redbone", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -18,5 +18,4 @@ "main": "index.js", | ||
"eslint": "^3.16.0", | ||
"pre-commit": "^1.2.2", | ||
"precommit": "^1.2.2" | ||
"pre-commit": "^1.2.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11281
2
13
253
3