Skip to content

Initial Hero API Server Configuration and Startup#22

Open
AlternateIf wants to merge 8 commits intoHermanL0201:e76a0895-0a2b-426e-b43b-059fa02aee8ffrom
AlternateIf:feature-hero-api-server-setup-1749258913
Open

Initial Hero API Server Configuration and Startup#22
AlternateIf wants to merge 8 commits intoHermanL0201:e76a0895-0a2b-426e-b43b-059fa02aee8ffrom
AlternateIf:feature-hero-api-server-setup-1749258913

Conversation

@AlternateIf
Copy link
Copy Markdown

@AlternateIf AlternateIf commented Jun 7, 2025

Initial Hero API Server Configuration and Startup

Description

Task

Create initial server setup for hero API

Acceptance Criteria

  • Server can be created and started dynamically
  • Basic middleware is in place
  • Health check endpoint is functional
  • Error handling middleware is implemented
  • Port configuration supports environment-based settings

Summary of Work

This pull request sets up the base Express server configuration for the Hero API, establishing a robust and flexible server initialization process.

Key Implementation Details

Server Configuration (src/config/server.ts)

  • Created a modular server creation function createServer()
  • Implemented essential middleware:
    • JSON body parsing
    • URL-encoded data parsing
    • Request logging middleware
  • Added a basic health check endpoint at /health
  • Implemented a global error handling middleware
  • Created a startServer() function for flexible server initialization

Server Startup (src/index.ts)

  • Imported server creation and startup functions
  • Added dynamic port configuration from environment variables
  • Implemented server startup with fallback to default port 3000

Notes

  • Default port is set to 3000 if not specified in environment
  • Logging captures request method, path, and timestamp
  • Global error handler provides a generic error response

Next Steps

  • Add more specific route handlers
  • Implement more detailed logging
  • Configure environment-specific settings

Changes Made

  • Created src/config/server.ts with server creation and startup functions
  • Implemented middleware in server configuration
  • Added health check endpoint
  • Created global error handling middleware
  • Configured dynamic port selection in src/index.ts

Tests

  • Verify server can start successfully
  • Check health endpoint returns 200 status
  • Validate middleware functionality
  • Test error handling middleware
  • Confirm port configuration works with environment variables

Signatures

Staking Key

H7r2wcPMQAoVQDhFfXCBoCitU7xVZACxm4zNg6ZgNHHJ: 2gjYTUibNDzuHCD83PBbyTyhtECXuHsbAFBV1iw6xbPhyNu9ePTKYD2PQfbZ5H159ygSkLYGFSXJNronJVsrzbhppcYGrViDWycwaqxGivZmgyfYUWXW11v3ziuixHsC6hW7yux4YxiTJqhDJiU4UUqfryG4WokUY9vQRkQ1TJCc93bWJafzmVEawAY6SjYU4nn2zNq8244RnsHRUU2t31geT1obPqT269vG3NLJWD5uwqeM7QvJ3qd9wLkbR8Tu5SUwBQjwrGCqRVBGytaozj7tYXV8xQ5AfbPjuiKieyLXcjB3jm7p65iz4oFLXnVH9vxEUAYaF3zsbVFrRmxZ8ikWCmf5M79pknsf4JaqpwxHu4fvNKb2Jirdks5rpzVXqUAZSff8dMxCR6KSePcnJbm11h6TzMNPCSQC

Public Key

HH1nKqRT8fPCKakAiTU85WYtyEgqSSJpWUiYFugzUvxB: 2eixFsUWbaPccnESEqzTU4UTFA2e9pvn2M75pxmVGZthV4KSGueZtBEabJS31dgcXJMmDv7USSrU4uFSpMHyoS8YroBA2HCx5pNCsg14gEfn6hxRfePkrQ1LP7HmFM4LpwnXdxtcMSFaQPDZhU784x2PGKtUBhUP1GjUmk81SsX2hG9fqDtZ87DLg4sqeYfo52bBS9RSiF6qXRxUHmdCUK2D1ZQBZJHvy1Qpbnv7BkeXUgGgVwmYgZavmqcNtZVGKkLn3Xuj1747MLRvNhSLPAcdPXcJuBnbWW2qsAHpa1JrCsLin3qnHd8RZCZTFySami1oKwHNcuYPu4wprwTPSabhKLAbSUwhdbGQqqDL6KRRqGp6fCKNmjKQwyJd4dd7yDPC3WAD9YnvRS8Mnznsr8wqYDHUvb2HM1yE

@AlternateIf AlternateIf changed the title [WIP] Setup Initial Express Server for Hero API Initial Hero API Server Configuration and Startup Jun 7, 2025
@AlternateIf AlternateIf marked this pull request as ready for review June 7, 2025 01:18
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