Skip to content

Implement Basic Express Server Setup with Configurable Port#4

Open
souravg77 wants to merge 8 commits intoac1b4def-e6b6-46ff-b94c-6aa773429112from
express-server-basic-setup-1749667906
Open

Implement Basic Express Server Setup with Configurable Port#4
souravg77 wants to merge 8 commits intoac1b4def-e6b6-46ff-b94c-6aa773429112from
express-server-basic-setup-1749667906

Conversation

@souravg77
Copy link
Copy Markdown
Owner

@souravg77 souravg77 commented Jun 11, 2025

Implement Basic Express Server Setup with Configurable Port

Description

Task

Implement basic Express server setup that can listen on a configurable port and provides a basic server structure.

Acceptance Criteria

  • Server can start on a configurable port
  • Supports environment variable port configuration
  • Provides a health check endpoint
  • Implements proper error handling
  • Supports module and direct script execution

Summary of Work

This pull request implements a robust and flexible Express server setup with the following key features:

Changes Made

  • Created modular server configuration with createApp() and startServer() functions
  • Implemented environment-based port configuration
  • Added a basic health check endpoint
  • Supported both direct script execution and module import
  • Integrated dotenv for environment variable management

Implementation Details

  • createApp(): Initializes Express application with a default health check route
  • startServer():
    • Supports optional port specification
    • Falls back to environment PORT or default 3000
    • Provides Promise-based server startup
    • Implements error handling for server initialization

Configuration

  • Uses .env for configuration
  • Defaults to port 3000 if no port specified
  • Logs server startup information
  • Gracefully handles server startup errors

Testing Approach

  • Modular functions allow for easy unit testing
  • Health check endpoint provides basic server verification
  • Error handling prevents silent failures during server startup

Acceptance Criteria Met

✓ Configurable port support
✓ Environment variable integration
✓ Basic server structure
✓ Error handling
✓ Logging mechanism
✓ Flexible import and execution methods

Changes Made

  • Created modular server configuration functions
  • Implemented environment-based port selection
  • Added health check endpoint
  • Integrated dotenv for environment variable management
  • Added error handling for server startup

Tests

  • Verify server starts on specified port
  • Check health endpoint returns 200 status
  • Validate environment variable port configuration
  • Ensure error handling works correctly

Signatures

Staking Key

DFCjj8EJFatpP9w7RhDZvaHHPEqXb3drCAf141nKXisp: UpSnTypm8BDLwn5HJipsrG89M13LadDmsgY8Ns2wHGgyCg8DZmu3Qyr7U61Tv22uoPWewXCrTaJDtsfvcNK2pqgVZY2mk3XyMbLofcaZdQ5xucU5JCg2deJQ2VxVLCP3Bx4rneFzAjNDMy3CYkAZM3omTCGtDe9o1bXwVbPNdVYiSBiBZ24BnA5xRJsyTjhhcxKDxCMNzN8g7EwmexFpD28XE3YMKcxK13cQudmhaNSckjpDodz7WE1MY9nVkXcAh8PSpf71MxjR1H8dUSog1djeqoGx5sV4wmsYc42WdV54ErWNWYV6d167jpHaGskmZXy8zDX2h7oebJfPHQ4YXvDZNoWsy3sXtKsEYNg3RV9MDZamrLA5gzagJmdY7KZMNiZFAP9W5NPTMonHocigthGgVGQ7bCRjT2

Public Key

2fvqh7n4ZNKctPDZoSiZKmgXJEKdpBqZoNpG86KDH2ku: Qd77S8mAUP5aP9JMPQ1uTUhry5ETKfZQo6ar24HNgGpivymUGjk6wWxqahF8h6hYkzZ75U8EjeJNYQwLDaJKepTqhQEuESVGUwSVunwAyD92jdToD34nGsmmqqJYCaMGo2GzoFTGDGSnBZygnxJ7rZkrZ7Uoq7L8v8KXAsnokMqMJxzUYLqNxnuHF5MhP47rHf79H5SVAvjqeAFdvyfbFc64rbiEEWYXNbZJzDojzNYC3kUAJ63dXWe9vVbfe6eKFsWJwd2P5MHag6bKzhBisop2tqYTrcWJu6zxLGdoKm8udz3S3MJds67Ns68AaPmQxCJW6prSifGktkvTa95BdduyBifcNQymQNXKnYBV61AsLA5eyJ4yHKPB2gr1kCVUgVbP9osg5faycRVxSjYgFcrnjdCESq1xZa

@souravg77 souravg77 changed the title [WIP] Initial Express Server Setup with Configurable Port Implement Basic Express Server Setup with Configurable Port Jun 11, 2025
@souravg77 souravg77 marked this pull request as ready for review June 11, 2025 18:56
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