Skip to content

Feature/amins assignment - #8

Closed
aminagah7 wants to merge 20 commits into
AUT-SE1:mainfrom
Amirhosein-shoorizadeh:feature/amins-assignment
Closed

aminagah7 wants to merge 20 commits into
AUT-SE1:mainfrom
Amirhosein-shoorizadeh:feature/amins-assignment

Conversation

@aminagah7

Copy link
Copy Markdown
  • Added GET /ready endpoint in HealthController according to GEN-10 requirement.
  • Implemented PostgreSQL readiness check using DataSource validation with a 2-second timeout.
  • Returns 200 OK with {"status": "UP", "database": "UP"} when healthy.
  • Returns 503 SERVICE_UNAVAILABLE when database is unreachable.
  • Added @crossorigin support for frontend integration.

@Amirhosein-shoorizadeh

Copy link
Copy Markdown

suggestion: When the database check fails and returns 503 SERVICE_UNAVAILABLE, let's make sure the response bodyeither delegates to our GlobalExceptionHandler or returns the standard RFC 9457 application/problem+json structure with "code": "SERVICE_UNAVAILABLE" so it stays consistent with GEN-06.

@Amirhosein-shoorizadeh

Copy link
Copy Markdown

also script is not okay

@Amirhosein-shoorizadeh Amirhosein-shoorizadeh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change for some rhing that i requested

@aminagah7

Copy link
Copy Markdown
Author

also script is not okay

suggestion: When the database check fails and returns 503 SERVICE_UNAVAILABLE, let's make sure the response bodyeither delegates to our GlobalExceptionHandler or returns the standard RFC 9457 application/problem+json structure with "code": "SERVICE_UNAVAILABLE" so it stays consistent with GEN-06.

The correction has been made.

@aminagah7

Copy link
Copy Markdown
Author

also script is not okay

What & Why

This PR implements the database readiness probe (GET /ready) in HealthController in compliance with GEN-10 and enables CORS for frontend integration.

  • Added GET /ready endpoint in HealthController to report downstream dependency (PostgreSQL) readiness.
  • Implemented DataSource connection validation with a 2-second timeout.
  • Returns HTTP 200 OK with {"status": "UP", "database": "UP"} when PostgreSQL is reachable.
  • Returns HTTP 503 SERVICE_UNAVAILABLE when the database is unreachable or times out.
  • Added @crossorigin annotation to support requests from the React/Vite frontend.

Jira Issue

  • Issue Key: S5-XX

How It Was Tested

  1. Healthy State: With s5-postgres container running in Docker, called GET http://localhost:8085/ready -> Received 200 OK with {"status": "UP", "database": "UP"}.
  2. Unhealthy State: Stopped the PostgreSQL container (docker stop s5-postgres) and called GET http://localhost:8085/ready -> Received 503 Service Unavailable within 2 seconds.
  3. CORS Check: Verified that browser fetch requests from the Vite frontend succeed without CORS errors.

@Amirhosein-shoorizadeh Amirhosein-shoorizadeh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Everything looks clean and well-structured!

  • Verified that GET /ready accurately checks the PostgreSQL DataSource connection with a 2-second timeout per GEN-10.
  • Tested both 200 OK (when the DB container is up) and 503 SERVICE_UNAVAILABLE (when the DB is stopped), as well as CORS headers for the frontend.
    Ready to squash and merge!

@aminagah7 aminagah7 closed this Oct 25, 2026
@Amirhosein-shoorizadeh
Amirhosein-shoorizadeh deleted the feature/amins-assignment branch November 7, 2026 21:56
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.

3 participants