Skip to content

Feature Tweet#2

Merged
espenia merged 9 commits intomainfrom
feature/tweet
May 25, 2025
Merged

Feature Tweet#2
espenia merged 9 commits intomainfrom
feature/tweet

Conversation

@espenia
Copy link
Copy Markdown
Owner

@espenia espenia commented May 25, 2025

Add Tweet Entity and Related Functionality

Overview

This pull request introduces a new Tweet entity along with the necessary components to support tweet creation. It also includes Docker configuration updates and CI implementation with GitHub Actions.

Key Changes

New Tweet Entity

  • Added the Tweet domain model with associated properties:
    • id (String)
    • userId (String)
    • content (String) - limited to 280 characters
    • createdAt (Date)
    • likeCount (long)
  • Created MongoDB document model (TweetDocument)
  • Implemented MapStruct mappers for entity-domain conversions

New Tweet Endpoints

Create Tweet Endpoint

Request:

curl -X POST http://localhost:8090/api/tweets \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user123",
    "content": "This is my first tweet!"
  }'

Response Schema:

{
  "id": "string",
  "userId": "string",
  "content": "string",
  "createdAt": "date-time",
  "likeCount": 0
}

Status Codes:

  • 201 Created - Tweet successfully created
  • 422 Unprocessable Entity - Validation error (e.g., content exceeds 280 characters)
  • 404 Not Found - User ID not found

Docker Setup

  • Updated Dockerfile with optimizations:
    • Multi-stage build for smaller final image
    • Proper handling of line ending issues (CRLF to LF conversion)
    • Fixed permissions on gradlew script
  • Enhanced docker-compose.yml:
    • Configured MongoDB initialization with proper user permissions
    • Added environment variables for connection details
    • Set up volume mounts for data persistence
    • Configured proper container dependencies and restart policies

CI/CD Integration

  • Added GitHub Actions workflow for Java CI with Gradle
  • Implemented build pipeline with the following steps:
    • JDK 17 setup
    • Gradle build configuration
    • Dependencies caching for faster builds
    • Test execution with reporting

Dependencies

  • MongoDB for tweet data storage
  • MapStruct for object mapping
  • Spring Boot validation for request validation

Testing

  • Added unit tests for the Tweet entity and related components
  • Created integration tests for the TweetController endpoints
  • Verified Docker setup works correctly

Deployment

The service can be deployed using Docker Compose:

docker-compose up -d

Related Issues

N/A

@espenia espenia merged commit fcecda6 into main May 25, 2025
0 of 2 checks passed
@espenia
Copy link
Copy Markdown
Owner Author

espenia commented May 25, 2025

Github actions va a fallar porque necesita una db corriendo no esta configurado embedd in memory db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant