Rest-a-culous
An opinionated ExpressJs based REST API generator.
Installation
To use the generator simply install it globally using NPM:
npm install -g restaculous
Features
The generator produces a fully functional REST API based on NodeJs, ExpressJs and MongoDB.
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
- Authentication
- Authorization
- Wizard to generate
settings.json
file - Logging Integration
-
.env
Integration - Microservices Setup
Structure
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
settings.json
file
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 settings.json
file.
Important:
- 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.
createdAt
andupdatedAt
are 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.json
file is given below:
DON'T FORGET TO REPLACE [app-name]