This project serves as a proof of concept (PoC) for implementing rules engines in Node.js. It utilizes two different rules engines: @gorules/zen-engine
and json-rules-engine
.
Before running the project, make sure you have Node.js and npm installed on your machine. Then, follow these steps:
- Clone this repository to your local machine.
- Navigate to the project directory.
- Run
npm install
to install the project dependencies.
To build the project, you can use the following command:
npm run build
This command will compile TypeScript files to JavaScript files using tsc
with the --watch
flag to continuously watch for changes.
This project includes two demo scripts for each rules engine:
zen-demo.js
for the@gorules/zen-engine
jre-demo.js
for thejson-rules-engine
You can start each demo using the following commands:
npm run start:zen-engine
npm run start:json-rules-engine
To start the Zen Engine demo, run the following command:
npm run start:zen-engine
Example output:
{ performance: '928.25µs', result: { scanning: { interval: 120000 } } }
To start the JSON Rules Engine demo, run the following command:
npm run start:json-rules-engine
Example output:
scanning interval: 30000
performance: 1.382125000000002 ms
Please note that in these demonstrations, the start date is randomly generated to be in the future, specifically from the current time onwards (NOW or later).
Upload the JDM file rulesets/blackwidow-jdm.json
into the ZEN Editor in order to visualize & update it: https://editor.gorules.io/
Manualy change the ruleset file: rulesets/blackwidow-jre.json
src/
: Contains TypeScript source files.dist/
: Output directory for compiled JavaScript files.
This project relies on the following dependencies:
typescript
: TypeScript compiler for compiling TypeScript code.@types/node
: TypeScript type definitions for Node.js.
@gorules/zen-engine
: Zen engine for implementing business rules.json-rules-engine
: JSON Rules Engine for defining and executing rules.
This project is licensed under the ISC License.
Yair Nevet