Skip to content

Added api endpoints and response formatter#2

Open
AireshBhat wants to merge 1 commit intomainfrom
feature/webapp-server
Open

Added api endpoints and response formatter#2
AireshBhat wants to merge 1 commit intomainfrom
feature/webapp-server

Conversation

@AireshBhat
Copy link

This pull request introduces a comprehensive web chat API to the server, including new endpoints for chat sessions and messaging, and adds robust, standardized response formatting utilities. It also improves middleware setup, error handling, and server lifecycle management for reliability and maintainability.

Web Chat API Integration:

  • Added a new WebChatController and a suite of REST API endpoints under /api/chat/sessions for managing chat sessions, sending/receiving messages, streaming responses via Server-Sent Events, and providing API documentation and health checks. [1] [2]
  • Introduced periodic cleanup of inactive streams and graceful shutdown procedures to ensure resource management and server stability.

Middleware and Configuration Enhancements:

  • Improved CORS configuration for secure cross-origin requests and set up body parsing with increased payload limits. Also, enabled Express's trust proxy for proper client IP detection.
  • Added static file serving and reorganized middleware loading order for better clarity and maintainability.

Standardized API Response Formatting:

  • Added a new utils/responseFormatter.js utility, providing consistent response formats for success, error, chat messages, sessions, health checks, streaming events, validation errors, and rate limiting.
  • Implemented global error and 404 handlers using the new formatter utilities for uniform API error responses. [1] [2] [3]

Development and Maintenance Improvements:

  • On startup (in non-production), the server now clears all chat sessions for a clean development environment.
  • Added logging for server startup, API endpoints, and AI provider configuration for better observability.

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