- Extract health routes to src/routes/health.lua (80 lines) - Extract HTTP server core to src/http_server.lua (256 lines) - Reduce main.lua to pure orchestration (342 → 27 lines) - Preserve all functionality and API compatibility - Add proper module separation following existing patterns - Enable future service self-registration architecture Closes #96
34 lines
1.1 KiB
Lua
34 lines
1.1 KiB
Lua
-- src/main.lua
|
|
-- Furt API-Gateway - Application Entry Point
|
|
-- Dragons@Work Digital Sovereignty Project
|
|
|
|
-- Load HTTP Server Core
|
|
local FurtServer = require("src.http_server")
|
|
|
|
-- Load Route Modules
|
|
local MailRoute = require("src.routes.mail")
|
|
local AuthRoute = require("src.routes.auth")
|
|
local HealthRoute = require("src.routes.health")
|
|
|
|
-- Load configuration
|
|
local config = require("config.server")
|
|
|
|
-- Initialize server
|
|
local server = FurtServer:new()
|
|
|
|
-- Register public routes (no authentication required)
|
|
server:add_route("GET", "/health", HealthRoute.handle_health)
|
|
|
|
-- Test endpoint for development (configurable via furt.conf)
|
|
if config.security and config.security.enable_test_endpoint then
|
|
server:add_route("POST", "/test", HealthRoute.handle_test)
|
|
print("[WARN] Test endpoint enabled via configuration")
|
|
end
|
|
|
|
-- Register protected routes (require authentication)
|
|
server:add_protected_route("POST", "/v1/mail/send", "mail:send", MailRoute.handle_mail_send)
|
|
server:add_protected_route("GET", "/v1/auth/status", nil, AuthRoute.handle_auth_status)
|
|
|
|
-- Start server
|
|
server:start()
|
|
|