This project is a RESTful API for managing user data, including creating, reading, updating, and deleting user information. The application is containerized using Docker and utilizes PostgreSQL as the database backend.
- Clone the repository:
git clone https://github.com/os-ct/user-express.git- Change to the project directory:
cd user-express- Build the Docker images:
docker-compose buildTo run the application with Docker and docker-compose, follow these steps:
- Start the services:
docker-compose up -dThis command will start the application and database services.
- Access the API endpoints:
The API will be available at http://localhost:3000. Use a tool like Postman or curl to interact with the API endpoints.
Postman collection to import: user-express.postman_collection.json
The following API endpoints are available:
- Endpoint:
POST /api/users - Request Body:
{ "first_name": "string", "last_name": "string", "phone": "string" } - Response:
- Status Code:
201 Created - Body: The newly created user object
- Status Code:
- Endpoint:
GET /api/users/:id - Path Parameters:
id: The user's ID
- Response:
- Status Code:
200 OK - Body: The user object with the specified ID
- Status Code:
- Endpoint:
GET /api/users - Response:
- Status Code:
200 OK - Body: The users object list with the specified IDs
- Status Code:
-
Endpoint:
PUT /api/users/:id -
Request Body:
{ "first_name": "string", "last_name": "string", "phone": "string" } -
Response:
- Status Code:
200 OK - Body: The newly updated user object
- Status Code:
-
Endpoint:
DELETE /api/users/:id -
Path Parameters:
id: The user's ID
-
Response:
- Status Code:
200 OK - Body:
User deleted successfullymessage
- Status Code:
- Stop the services:
docker-compose downThis command will stop and remove containers, networks