To begin, clone the repository using SSH, then install all necessary dependencies by running:
npm install
Create a .env
file by duplicating the .env.example
file provided in the repository. Add your MongoDB credentials and update the URL
as needed.
For development, use the following command:
npm run dev
This command runs the project with node --watch
, allowing hot-reloading during development, similar to nodemon
.
For production builds, start the application with:
npm start
To check for code quality using linters, run:
npm run lint
For automatic linting fixes, use:
npm run lint-fix
To run tests, use the following command:
npm test
To populate the database with sample data, run:
npm run populate <FileName>
To add logs to your application, use the logger
object provided in the config/logger.js
file. The logger is configured to write logs to the console and a file in the logs
directory. There are five log levels available:
error
warn
info
http
verbose
debug
You can log messages adding the following code to your methods:
logger.error('This is an error message');
logger.http('Incoming HTTP request', {
method: 'GET',
url: '/api/appointments',
userUid: 'a71b0cbd-7edd-4ae1-919b-403a33fba2eb',
params: { date: '2024-11-04', status: 'confirmed' }
});
To run the application in a Docker container:
- Modify the
/workdir
setting in theDockerfile
to match the corresponding microservice directory. - Update the
deploy-docker
workflow to deploy the correct microservice.
Once these changes are made, ensure Docker is installed and running on your system, then build and start the container with:
docker compose up -d
This command launches your deployed Docker image in detached mode.