Easy Contabil questions
Easy Contabil questions with ESC-Question.
Install dependencies
yarnGenerate the archive .env and change the connection of Redis and MongoDB
cp .env.example .env && cp .env.example .env.testingTo run E2E and Unit tests without logs
yarn testTo run E2E and Unit tests with debug logs
yarn test:debugTo run the application in development mode without debug logs
yarn start:devTo run the application in development mode with debug logs
yarn start:debug:devThe heart of the project is within start/kernel.ts, app/AppModule.ts and providers/ApplicationProvider. start/kernel.ts is where an array of imports is created to be used within NestJS, this array is always called in the imports of the AppModule, and he loads some of the config/*.ts files from the project.
providers/ApplicationProvider load all the providers (services, repositories, models, guards, middlewares, pipes and controllers) from the application, AppModule will call ApplicationProvider as a Singleton and constructor will execute all the boot methods inside it and creating arrays to use inside AppModule providers and controllers. Basically if you need to create a new controller or service, you don't need to pass it into the AppModule, just create the file and let ApplicationProvider take care of the rest.
🛑 Is extremely important to follow this project structure to providers/ApplicationProvider works. 🛑
app
├── Contracts
│ ├── Dtos
│ ├── *Contract.ts
├── Http
│ ├── Filters
│ ├── Guards
│ ├── Interceptors
│ ├── Middlewares
│ ├── *Controller.ts
├── Validators
│ ├── *Validator.ts
├── Decorators
| ├── Http
| ├── Validators
│ ├── *.ts
├── Models
│ ├── *.ts
├── Pipes
│ ├── *Pipe.ts
├── Repositories
│ ├── *Repository.ts
├── Services
│ ├── Api
│ ├── Collections
│ ├── Utils
├── AppModule.ts
config
├── *.ts
database
├── *.ts
├── *.sql
providers
├── *.ts
├── ApplicationProvider.ts
start
├── chalk.ts
├── debug.ts
├── env.ts
├── kernel.ts
├── main.ts
test
├── E2E
│ ├── Resource Name
├── Unit
│ ├── Resource Name
├── Utils
│ ├── App.ts
│ ├── Database.ts
First, install Yeoman and SecJS Generator using npm.
npm install -g yo
npm install -g generator-secjs@1.1.0Then generate your CRUD using the generateCrud.sh and your resource name, in this case Foo, 🛑 please put your terminal at the root of the project and run: 🛑
./.github/generateCrud.sh Foo😎🎉 Foo CRUD has been created, and the files has been moved to the correct folders to work with providers/ApplicationProvider.ts
Now start implementing your methods inside Model, Dto, Validator, Controller and Service!
Just run the project and enter inside ${your.url}/portal/swagger in your browser to see the Swagger Collections.
This project is under MIT license. See the archive LICENSE for more details.
Made with 🖤 by jlenon7 👋