This project provides a backend service to manage user creation, retrieval, and updates. The application uses Docker for containerization and includes migrations for database setup.
To build and run the application, use the following command:
docker-compose up --build
This command will:
- Build the Docker images as defined in the
docker-compose.yml
file. - Start the application and its services (e.g., database).
To apply database migrations, run:
make migrateup
This will execute the migration scripts to set up or update the database schema.
To create a new user, send a POST request to:
POST localhost:8080/users
With the following JSON payload:
{
"name": "testName",
"surname": "testSurname",
"email": "test@gmail.com",
"password": "testest"
}
To retrieve all users, send a GET request to:
GET localhost:8080/users
To update a user by their ID, send a PUT request to:
PUT localhost:8080/users/{id}
Replace {id}
with the user’s ID (e.g., 1
).
Update multiple fields:
{
"name": "newName",
"surname": "newSurname"
}
Update a single field:
{
"name": "newName"
}
- Ensure the application is running before making API requests.
- Use tools like
curl
, Postman, or any HTTP client to interact with the API. - The application validates inputs and ensures data consistency (e.g., unique email addresses).
- Stop and Remove Containers:
docker-compose down
- Rebuild Containers:
docker-compose up --build
- Clean Up Resources:
docker system prune -a