Skip to content
This repository was archived by the owner on Jul 11, 2026. It is now read-only.
This repository was archived by the owner on Jul 11, 2026. It is now read-only.

[Feature]: Improve server/index.js with better error handling, security, and configuration #48

Description

@gssi962

Where are you from?

GSSOC'25
OSCI'25

Description of the Feature

Currently, the server/index.js file works fine, but it can be improved to make the backend more secure, flexible, and easier to maintain. I propose the following improvements:

Configurable CORS origins: Right now, the CORS origin is hardcoded to http://localhost:5173. This can cause issues when deploying to other environments. By moving allowed origins to an .env variable, it becomes easy to update without changing the code.

404 route handler: Currently, unknown routes fall into the generic error handler. Adding a 404 middleware will return a clear JSON response when someone hits an undefined route.

Improved error handler: The current error handler always returns status 500. It should respect the err.statusCode when available, so API errors can return the correct status codes.

Enhanced /api/health endpoint: Currently, it only returns the current time. By including database connection status and server uptime, it becomes more useful for monitoring and debugging.

Security middlewares: Adding helmet and express-rate-limit will protect the API from common attacks and prevent abuse.

Request logging: Using morgan to log requests makes it easier to debug and monitor API usage.

Estimated time to implement the feature

I need 3–4 days to implement and test the changes before submitting a PR

Additional context

These changes will make the server easier to use, safer, and ready for production.

It will help the server work in different environments.

Debugging and monitoring will be easier with better logging and health checks.

Errors will be clearer and security will be stronger.

Metadata

Metadata

Assignees

Labels

2⭐⭐MediumGSSoC'25Part of GSSoC'25 programOSCI'25Part of open source connect - 2025enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions