yagyesh-bobde / GenAI-Projects

A wide curration of open-source projects and applications in the emerging field of generative AI.
MIT License
94 stars 51 forks source link

Update index.js #58

Closed tushargupta1504 closed 10 months ago

tushargupta1504 commented 10 months ago

Improvements and additions:

Port Configuration: Use the ' process.env.PORT ' environment variable for the port, making it more flexible.

Error Handling: Added better error handling with try-catch blocks and appropriate HTTP status codes.

Input Validation: Check if the required parameter text_to_summarize is present in the request body and return a 400 Bad Request if not.

Async/Await: Use async/await for better readability and to handle promises more efficiently.

Health Check Endpoint: Added a simple health check endpoint (/health) to verify the server's status.