imicros-rules
v0.0.6
Published
Execution service for rulesets
Downloads
2
Readme
imicros-rules
Moleculer service for rulesset execution
Uses imicros-rules-compiler as rules intepreter.
Installation
$ npm install imicros-rules --save
Dependencies
Required mixins (or a similar mixin with the same notation):
Usage
Usage rules service
const { ServiceBroker } = require("moleculer");
const { AclMixin } = require("imicros-acl");
const { MinioMixin } = require("imicros-minio");
const { Rules } = require("imicros-rules");
broker = new ServiceBroker({
logger: console
});
broker.createService(Rules, Object.assign({
mixins: [MinioMixin(), AclMixin]
}));
broker.start();
Actions rules service
- eval { name, data } => result
Example eval
// path/to/ruleset/test.rules: "@@ @ user.age :: >= 16 & <= 35 => result := 'true' @@"
let params = {
name: "path/to/ruleset/test.rules",
data: { user: { age: 25 } }
};
let res = await broker.call("rules.eval", params, opts)
// res = { result: 'true' }