Files
internship_node/day3
2022-02-06 22:32:46 -05:00
..
2022-02-06 20:59:48 -05:00
2022-02-06 22:32:46 -05:00
2022-02-06 20:59:48 -05:00
2022-02-06 20:59:48 -05:00
2022-02-06 21:41:19 -05:00
2022-02-06 20:59:48 -05:00
2022-02-06 20:59:48 -05:00
2022-02-06 20:59:48 -05:00
2022-02-06 20:59:48 -05:00
2022-02-06 20:59:48 -05:00

day 3

Instructions

rules
- id
- name
- condition
- action
- created_at
- updated_at

variable
- id
- name
- type (STRING, FLOAT, INTEGER)
- created_at
- updated_at
  • Make the CRUD API for these tables
GET /api/v1/rules (get all)
GET /api/v1/rules/:id (get one)
POST /api/v1/rules/:id (add one)
PUT /api/v1/rules/:id (update one)
DELETE /api/v1/rules/:id (delete one)

GET /api/v1/variables (get all)
GET /api/v1/variables/:id (get one)
POST /api/v1/variables/:id (add one)
PUT /api/v1/variables/:id (update one)
DELETE /api/v1/variables/:id (delete one)

GET /api/v1/evaluation?variable=base64
(
  the variable payload is json that base64 encoded. You need to decode it before using it.
  variable = {
    'a': 1,
    'b': 2,
    'c': 'TEST'
  }

  When you decode variable, you query all the rules.

  Then you evaluate the condition field and substitute in the variables provided.
  If variable does not exist in variable table, ignore it.
  Cast all variable type in payload to match the db version.

  return result like the following if rule condition is satisfied:
  [
    {
      rule_id: 1,
      result: (the rules action value if rule condition is true)
    }
  ]
)

  • Everything must be done by end of date