Skip to content

Improved backend server setup and error handling #62

@gar6307

Description

@gar6307

Description:

Updated the backend to make it more reliable and organized.
-Added a fallback for the server port.
-Added a check to ensure MONGO_URI is present before connecting.
-Implemented a global error handler for better error responses.
-Suggested a cleaner folder structure for better project management.

Solution:

-Fallback for PORT: Use process.env.PORT || 5002 so the server runs even if PORT isn’t set.
-Check MongoDB URI: Ensure MONGO_URI exists before connecting, to avoid runtime errors.
-Global Error Handler: Add one to catch unexpected errors and return proper messages.
-Organize Folder Structure: Keep Routes, middleware, and config folders separate for cleaner code.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions