Adds a new empty controller to a LoopBack application.
: Type of the controller.
Valid types are BASIC
and REST
. BASIC
corresponds to an empty controller,whereas REST
corresponds to REST controller with CRUD methods.Standard options
-h, —help
- Print the generator’s options and usage.
—skip-cache
- Do not automatically install dependencies. Default is false.
-c, —config
- JSON file name or value to configure options
—format
- Format generated code using
npm run lint:fix
For example,
-y, —yes
- Skip all confirmation prompts with default or provided value
The tool will prompt you for:
- Type of the controller. You can select from the following types:
- Empty Controller - An empty controller definition
- REST Controller with CRUD Methods - A controller wired up to a model andrepository definition, with pre-defined CRUD methods.
Empty Controller
If you select the Empty Controller, it will generate a nearly-empty templatebased on the given name:
REST Controller with CRUD Methods
If you select the REST Controller with CRUD Methods type, you will then be askedto select:
- The model to use for the CRUD function definitions
- The repository for this model that provides datasource connectivity
src/repositories/*.repository.ts
src/models/*.model.js
Files that match these patterns will then be identified based on the stringbefore the first.
separator. For example, filemodels/product.model.ts
isidentified as a source ofProduct
model.
Note:
Please note that the model and repository typing information will be based onhow the model/repository files are named; the CLI tooling does not read theactual artifact class names inside the files.
Here’s an example of what the template will produce given a Todo
model and a: