main

Function main 

Source
pub(crate) fn main()
Expand description

Main application entry point.

Initializes the server by:

  1. Loading environment variables from .env file
  2. Establishing database connection pool to PostgreSQL
  3. Configuring CORS policy for cross-origin requests
  4. Creating the router with create_router containing all endpoints
  5. Starting HTTP server on port 8001

§Server Configuration

  • Binds to 0.0.0.0:8001 (all network interfaces)
  • Allows: GET, POST, PATCH, DELETE methods
  • Allows credentials and custom headers
  • CORS origin configured from Env

§State Setup

Creates shared AppState wrapped in Arc and passes to all routes

§Panics

  • If environment loading fails
  • If database connection fails