A progressive Node.js framework for building efficient and scalable server-side applications.
Personal Template for Building Projects with My Team, Based on NestJS Best Practices
This template was created to streamline the development of projects with my team, making it easier and more comfortable to kick-start new services. It is based on a NestJS template and modified to fit our specific needs. It includes essential tools like Docker, ESLint, Husky for linting, and a flexible directory structure for rapid development.
This template was inspired by the work of Albert Hernandez, whose video and repository helped guide the creation of this project. Modifications include using Express, adding Yarn as a package manager, and making adjustments to the database configuration for personal convenience and flexibility.
This project is based on the work of Albert Hernandez. The original template was modified to use Express, added Yarn as a package manager, and adjusted configurations for the database. All credit goes to the original creator.
Before starting, make sure you have the following installed:
$ yarn install- Clone the
.env.templatefile and rename it according to the environment:
- For development:
.env.development - For production:
.env.production - For testing:
.env.testing - Or use a general:
.env
-
Fill in the file with the corresponding values for each environment
-
Make sure not to commit
.envfiles to the repository (they should be included in.gitignore)
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod- For the initial creation, we will always use the
--buildcommand, for example:docker-compose up --buildordocker-compose build. - For detached mode, we will add the
-dflag at the end of the command, for example:docker-compose up --build -d. - If the
--buildhas already been done, to start the project, we only need to usedocker-compose up. - If we want to remove everything, we will use
docker-compose down.
You can run the project with or without the database depending on your needs:
-
To run only the backend (without the database):
docker-compose up backend-dev
-
To run the database (without the backend):
docker compose --env-file 'your .env path' up template_db -
To run everything together (both backend and database):
docker compose --env-file 'your .env path' up backend-dev template_db -
To run everything (without profiles)
docker-compose up
To choose the environment in which the application will run, use the following commands:
# Development Mode
$ docker-compose --env-file .env.development up
# Production Mode
$ docker-compose --env-file .env.production up
# Test Mode
$ docker-compose --env-file .env.testing up# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:covThis development mode will work with hot-reload and expose a debug port, port 9229, so later we can connect to it from our editor.
Now, you should be able to start debugging configuring using your IDE. For example, if you are using vscode, you can create a .vscode/launch.json file with the following configuration:
{
"version": "0.1.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to docker",
"restart": true,
"port": 9229,
"remoteRoot": "/app"
}
]
}