A progressive Node.js framework for building efficient and scalable server-side applications.
Template based on NestJS with Fastify and SWC compiler
-
🐳 Fully dockerized service ready for development and production environments with the best practices for docker, trying to provide a performance and small image just with the code we really need in your environments.
-
👷 Use SWC for compiling and running the tests of the service. As commented in the own NestJS docs, this is approximately x20 times faster than default typescript compiler that is the one that comes by default in NestJS.
-
🗂️ Separate tests over production code. By default, NestJS is combining in the same folder, the
src, the unit tests and the code we are developing for production. This is something I personally don't like so here I am separating this and having a dedicated folder for the unit tests. -
🤜🤛 Combine unit and e2e test coverage. In the services we may have both type of tests, unit and e2e tests, and usually we would like to see what is the combined test coverage, so we can see the full picture.
First, we will need to create our .env file, we can create a copy from the example one:
cp .env.example .envThe project is fully dockerized 🐳, if we want to start the app in development mode, we just need to run:
docker-compose up -d app-devThis development mode with work with hot-reload and exposing a debug port, the 9229, so later we can connect from our editor to it.
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"
}
]
}Also, if you want to run the production mode, you can run:
docker-compose up -d app-productionThis service is providing just a health endpoint which you can call to verify the service is working as expected:
curl --request GET \
--url http://localhost:3000/healthIf you want to stop developing, you can stop the service running:
docker-compose downnpm run buildThe service provide different scripts for running the tests, to run all of them you can run:
npm run testIf you are interested just in the unit tests, you can run:
npm run test:unitOr if you want e2e tests, you can execute:
npm run test:e2eTo run the linter you can execute:
npm run lintAnd for trying to fix lint issues automatically, you can run:
npm run lint:fix- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.