clean-scaffold v1.5.1
Clean Architecture Scaffold
This CLI creates the structure of a NodeJs and TypeScript project based on clean architecture to build REST full APIs, it comes with the initial configuration of an Express application as a NodeJs framework and this is located in the application layer
.
Implementation of the plugin
We install the plugin globally in our computer, to be able to access the commands that generate the tasks. the tasks.
npm i -g clean-scaffold
Tasks
Project Generation
- We generate the project structure with the command
scaffold init
, which receives one parameter--name
.
scaffold init --name=[project name]
Plugin generated structure:
Database Generation
We generate the adapter with the initial database configuration for database managers like MongoDB, MySQL or Postgres with the command
scaffold create:database
, receives a parameter--database
, this is required.--database
= Database manager namemongo, mysql, postgres
.
scaffold create:database --database=[manager name]
Plugin generated structure:
Model Generation
The
scaffold create:entity
command will generate a model and an interface in thedomain layer [models]
, this task has--name
as parameter and this is required. The name must have a middle hyphen in case it is compound.Example:
--name=user, --name=user-detail, --name=post-comments-user.
scaffold create:entity --name=[model name]
Task generating structure:
Interface Generation
- The
scaffold create:interface
command generates an interface, the location of the file is according to the component where it is required. where it is required. The name must have a hyphen in case it is a compound name.
Example: --name=user, --name=user-detail, --name=post-comments-user.
scaffold create:interface --name=user-detail --path=model
scaffold create:interface --name=user-detail --path=service
scaffold create:interface --name=user-detail --path=infra
Service Generation
The
scaffold create:service
command will generate the interface and the service that implements it in thedomain layer [use-cases]
.domain layer [use-cases]
, this task has--name
as parameter and this is required. The name must have a hyphen in case it is a compound name.Example:
--name=user, --name=user-detail, --name=post-comments-user.
scaffold create:service --name=[service name]
Structure that generates the task:
This configuration must be done manually.
Adapter Generation
The
scaffold create:adapter
command will generate an adapter in theinfrastructure layer
, this task has--name
and--database
as parameters this is required. The name of the--database
parameter corresponds to the database manager. After the adapter is generated, the provider must be included in the app.ts file and then the name of the provider in the corresponding service must be passed through the constructor.Example:
--name=user --database=mongo
scaffold create:adapter --name=[adapter name] --database=[database manager]
Structure that generates the task:
- This command generates two files, the class that communicates with the service through the gateway and the provider resolves the dependencies of this communication.
This configuration must be done manually.
Service configuration.
app.ts configuration.
Controller Generation
The
scaffold create:controller
command will generate a controller in theinfrastructure layer
, this task has--name
as parameter and this is required. The name must have a hyphen in case it is a compound name.Example:
--name=user, --name=user-detail, --name=post-comments-user.
scaffold create:controller --name=[controller name]
Structure that generates the task:
This configuration must be done manually.
app.ts configuration.
- The naming convention must be applied between the service and the controller to generate the Dependency Injection in the controller and an endpoint to enter the application.