This project is a Node.js-based HTTP server that provides an endpoint to generate letter combinations for a given phone number. The application is containerized using Docker for easy deployment.
- Accepts a phone number (digits 2-9) via a POST request.
- Returns all possible letter combinations based on the standard phone number to letter mapping.
- Fully Dockerized for deployment on any Docker-compatible server.
- Docker installed.
- Access to a Docker Ubuntu server (for deployment).
git clone https://github.com/f4r6d/Mafioso-Backend-Developer-Task.git
cd Mafioso-Backend-Developer-Task/backend
npm install
node app.js
The server will run on http://localhost:8080
.
Use cURL or Postman to test the /combinations
endpoint:
curl -X POST -H "Content-Type: application/json" \
-d '{"phoneNumber": "23"}' \
http://localhost:8080/combinations
Expected response:
{
"combinations": ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]
}
docker build -t phone-combinations .
docker run -d -p 8080:8080 --name phone-combinations phone-combinations
The application will be accessible at http://localhost:8080
.
Check if the container is running:
docker ps
Use scp
to copy the project to the server:
scp -r phone-combinations user@server-ip:/path/to/deploy
Replace user
with your server username, server-ip
with the server’s IP address, and /path/to/deploy
with the desired directory.
ssh user@server-ip
cd /path/to/deploy/phone-combinations
docker build -t phone-combinations .
docker run -d -p 8080:8080 --name phone-combinations --restart unless-stopped phone-combinations
Ensure the container is running:
docker ps
From your local machine, test the endpoint using the server’s IP address:
curl -X POST -H "Content-Type: application/json" \
-d '{"phoneNumber": "23"}' \
http://server-ip:8080/combinations
Replace server-ip
with the actual IP address of your server.
If the application is not working as expected, view the container logs:
docker logs phone-combinations
If you make changes to the code, rebuild the Docker image:
docker build -t phone-combinations .