Home  /  Generators  /  RESTful API Generator

RESTful API Generator

This tool generates typical CRUD RESTful API for a database table; to be added to Node++ project. Requires also adding compatible DAO/ORM class to the project.

Authorization

You can define up to 4 levels of authorization. Middle levels can have further restrictions if column is defined: only the records belonging to the current user will be accessible. For example, the table may have columns sales_rep and cust_id. These columns can be specified for the Middle and Low levels, respectively. Then the sales rep will be able to access only the records belonging to their customers, that is records with sales_rep=<user ID>, and the customer will only be able to access theirs.

In order for authorization to work properly, the table has to have single column as a primary key – either integer or string – and it needs to be the first column in the table definition.

Changing authorization rules after the files have been generated

Session levels and access permissions can easily be changed at any time by defining macros outside the generated files (see generated *.h file). On the other hand, binding columns affect generated logic so in the case change is required, re-generating will be better than manually changing previously generated code.

Filtering

As apparently there's no standard for filtering URLs, I decided to optimize it for clarity and shortness. I tried to avoid special characters that would force ugly URL encoding. Here's the summary:

------------------------------------------------- URI SQL ------------------------------------------------- *** strings *** name=john name LIKE '%john%' name_eq=john name = 'john' name_sw=john name LIKE 'john%' name_neq=john name != 'john' name_in=john,johnny name IN ('john', 'johnny') name_nin=john,johnny name NOT IN ('john', 'johnny') *** numbers *** price=123 price = 123 price_eq=123 price = 123 price_neq=123 price != 123 price_lt=123 price < 123 price_lte=123 price <= 123 price_gt=123 price > 123 price_gte=123 price >= 123 price_in=123,222 price IN (123, 222) price_nin=123,222 price NOT IN (123, 222)

Order can be specified by o parameter, i.e.:

products?o=name products?quantity_lte=100&o=name,price

Descending order is indicated by od parameter, i.e.:

products?od=price products?quantity_lte=100&od=quantity

Generator

Generator v.2.1.2, last update 2024-03-05 (Single char null handling)

Paste the CREATE TABLE statement or  
Primary key needs to be defined:

Highest level:

Sessions with auth_levelAUTH_LEVEL_ADMIN will always have full access.

Middle level:

Session level ≥   UID column:

Low level:

Session level ≥   UID column:

All other – including not logged in – sessions: