Skip to content

Refactor SMS sender app to use async httpx and improved validation #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Manodeepray
Copy link

This PR refactors the SMS sender FastAPI app for improved performance, validation, and error handling. Key changes:

An overal summary

  • Migrated from synchronous requests to asynchronous httpx.AsyncClient
  • Added input validation using pydantic.Field
  • Introduced async lifespan() for modern startup/shutdown handling
  • Improved error handling with detailed logs and structured JSONResponse
  • Updated requirements.txt

Changes i made

✅ Replaced requests.post with httpx.AsyncClient
✅ Updated endpoint to async def
✅ Added phone number pattern validation (+91... etc.)
✅ Introduced lifespan() for lifecycle management
✅ Added proper error responses with status codes
✅ Updated logging for Twilio and HTTP errors
✅ Created requirements.txt with minimal necessary deps

@pratik-mahalle
Copy link

Thank you for raising the pr, Our team will review the pr soon before that please make sure to sign the DCO.

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.

2 participants