Pozol CLI
Pozoljs is a package to initialize your node-express project with typescript or javascript and create full components to develop your backend apps faster.
Pozoljs will helps you to get a node-express project more escalable with a good estructure for folders and files.
Pozoljs is not a framework.
Getting start
Installing the CLI
Global installation.
npm install -g pozoljs
yarn global add pozoljs
Local installation.
npm install pozoljs
yarn add pozoljs
When the package is installed, you will can use pozoljs command.
The CLI
Some concepts
- Component is a small folder that contains the principal modules of an endpoint. For example, you will develop endpoints about users, so in the users folder you will have controller, service, routes files (and interface if it is a typescript project).
- Service connect with the database or return data that you need. In other words, the service provides data to the controller. In the start, the service file implements find, save, update and delete methods.
- Controller manipulate the data that obtains of the service or of the route. The controller call service methods through dependency injection.
- Routes about your component like GET, POST, PUT or DELETE.
- Interface is using in typescript like a data type.
Build your project using pozoljs
Create a new node-express projects with an initial structure.
pozoljs new <name> [options]
Options available
| Name | Alias | Description |
|---|---|---|
| --skip-install | -i | If you do not to install initial dependencies. |
| --skip-git | -g | If you do not to initialize for git repositorie. |
| --language | -l | Typescript is the default language. You can choose javascript. Just type javascript, js, typescript or ts. |
| --directory | Destination directory. Must be a relative path. | |
| --yarn | Use yarn instead npm. | |
| --help | For more information. |
Files Structure
Pozoljs builds a node-express project with an initial structure. This one helps you to develop faster and escalable code. The initial structure is:
├────src
│ ├───api
│ │ └───component
│ │ │ ├───component.controller.ts/js
│ │ │ ├───component.interface.ts
│ │ │ ├───component.routes.ts/js
│ │ │ └───component.service.ts/js
│ │ └───index.ts/js
│ ├───global
│ │ ├───helpers
│ │ │ └───abstract.api-routes.ts
│ │ │ └───abstract.routes.ts
│ │ │ └───abstract.service.ts
│ │ ├───config.ts/js
│ │ ├───interfaces.ts
│ │ └───utils.ts/js
│ │ └───variables.ts/js
│ ├───middlewares
│ ├───database.ts/js
│ ├───index.ts/js
│ └───server.ts/js
├───.editorconfig
├───.env
├───.env.example
├───.gitignore
├───package.json
├───pozoljs.config.json
├───package-lock.json/yarn.lock
└───tsconfig.json
Schematics
All commands have the full type and abreviation type.
pozoljs g <schematic> [name]
Schematics availables
| Name | Alias | Description |
|---|---|---|
| component | cp | Create controller, service, routes and interface file in the api folder by default. |
| controller | ct | Create controller file and create the folder if does not exists. |
| service | sv | Create service file and create the folder if does not exists. |
| routes | rt | Create controller file and create the folder if does not exists. |
| interface | ic | Create interface file and create the folder if does not exists. |
About the project created
The project created using pozoljs is to get an initial and generic structure of all your node projects.
In the package.json there are 3 commands:
- Run
npm run dev/yarn devto execute the project in development mode. - Run
npm run build/yarn buildto create the production project (just for typescript). - Run
npm run start/yarn startto execute the project in the production mode.
For more information, you can execute: pozoljs --help