This project is a Node.js application with a PostgreSQL database, containerized using Docker and Docker Compose.
Make sure you have the following installed on your system:
- Docker
- Docker Compose
- Node.js and npm (for local development)
To build and start the entire application using Docker Compose, run the following command:
docker-compose up --buildIf you prefer to run the database container separately, you can follow these steps:
-
Navigate to the
databasedirectory:cd database -
Build the PostgreSQL Docker image:
docker build -t enpal-coding-challenge-db . -
Run the PostgreSQL container:
docker run --name enpal-coding-challenge-db -p 5432:5432 -d enpal-coding-challenge-db
This will run the PostgreSQL container in the background and expose it on port 5432.
To run the tests for the Node.js application after starting the PostgreSQL database, follow these steps:
-
Navigate to the
test-appdirectory:cd test-app -
Install the dependencies:
npm install
-
Start the Node.js server:
npm start
The server will now be running on http://localhost:3000/ and making POST Request on http://localhost:3000/calendar/query and will communicate with the PostgreSQL database.
The following type of query is accepted by the application:
{
"date": "2024-05-04",
"products": ["Heatpumps","SolarPanels"],
"language": "English",
"rating": "Silver"
}-
Run the tests in new terminal:
npm test
The tests will now run, and you'll see the output of your tests in the terminal.
.env file is included in the project for simplification.
When both services are when started in docker-compose communicate using private network