https://github.com/brandonhein/hein.rulesengine-v3
Dynamic Rules Engine that applies defined logic to payload
https://github.com/brandonhein/hein.rulesengine-v3
api nodejs rules-engine rulesengine
Last synced: 4 months ago
JSON representation
Dynamic Rules Engine that applies defined logic to payload
- Host: GitHub
- URL: https://github.com/brandonhein/hein.rulesengine-v3
- Owner: brandonhein
- Created: 2019-12-26T20:14:50.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T01:01:41.000Z (about 3 years ago)
- Last Synced: 2025-04-01T10:49:17.748Z (10 months ago)
- Topics: api, nodejs, rules-engine, rulesengine
- Language: JavaScript
- Homepage: https://3lihn11xl3.execute-api.us-east-2.amazonaws.com/Prod
- Size: 1.44 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hein.RulesEngine-v3
Dynamic Rules Engine that applies defined logic to payload
Link of working Demo here => https://3lihn11xl3.execute-api.us-east-2.amazonaws.com/Prod/
## What makes it special
### Rule Creation/Updates
Admin's (use an admin tool [for demo purposes the ui is added to this repo]) create rules using some basic IF/ELSE IF/ELSE conditions in a `Visual Basic` fashion.
```visualbasic
IF [EventId] = 8000
[IsStatus] = true
ELSE
[IsStatus] = false
ENDIF
```
Rules Engine converts this Visual Basic code to appliable javascript code (what I call engine code):
```javascript
if (values["EventId"] == 8000) {
values["IsStatus"] = true;
}
else {
values["IsStatus"] = false;
}
```
And saves both Admin and Engine to the rule definition stored in a datastore.
### Rule Execution
When applications want to apply rules... it should generate the payload, with a ruleset name for RulesEngine to get the correct rule definition.
* 'rule' = rule definition for rules engine to apply
* 'values' = parameters for rules engine to apply logic too
```json
{
"rule": "is_event_id_a_status",
"values": {
"EventId": 9580
}
}
```
That application will post to the `~/Execute` endpoint for rules engine to apply the rule logic against the payload
And in return, based on the logic inside the rule, will return the same payload with updated values/parameters
```json
{
"rule": "is_event_id_a_status",
"values": {
"EventId": 9580,
"IsStatus": false
}
}
```