An opinionated ExpressJs based REST API generator.
To use the generator simply install it globally using NPM:
npm install -g restaculous
The application generated has the following features:
- Fully tested API endpoints with CRUD operations
- Express-Validator Integration
- Automatically generate API documentation
- Linting of source to ensure proper code formatting
- Wizard to generate
- Logging Integration
- Microservices Setup
The generate application structure looks as follows.
.. . |--config/ # configuration settings |--controllers/ # controllers based on models |--dal/ # data access layer containing abstractions over models |--docs/ # Auto-generated documentation for API endpoints |--lib/ # utility library to do common tasks |--models/ # the underlying models of the system |--routes/ # REST-based API endpoints |--validators/ # Validators for API endpoints |--test/ # tests for the entire code base |--.gitignore # common file and folders to ignore by git |--app.js # the applications main entry point |--package.json # specifies modules/packages used in the app |--README.md # an introductory text about the application
Generate from a
You can generate an entire application by simply supplying a json settings file in the following format.
Note: For details on the Express Validator validators, please look at its documentation on GitHub.
Here is a Gist with an example
- The top level
authentication(Boolean) property adds token based authentication to the application.
- The model level
authentication(Array of Action Names) property specifies the API endpoints that require authentication to access. If you don't want authentication added, this key needs to be removed or left as an empty array.
- Timestamp attributes, i.e.
updatedAtare automatically added to all models.
- All settings fields in the above example are required except the ones identified as being optional. All configuration entries are mandatory; a starter
settings.jsonfile is given below:
DON'T FORGET TO REPLACE [app-name]