2025-08-29 20:01:47 +02:00
|
|
|
-- src/main.lua
|
2025-09-05 19:25:02 +02:00
|
|
|
-- Furt API-Gateway - Application Entry Point
|
2025-06-17 20:40:40 +02:00
|
|
|
-- Dragons@Work Digital Sovereignty Project
|
|
|
|
|
|
2025-09-05 19:25:02 +02:00
|
|
|
-- Load HTTP Server Core
|
|
|
|
|
local FurtServer = require("src.http_server")
|
2025-06-17 20:40:40 +02:00
|
|
|
|
2025-09-05 19:25:02 +02:00
|
|
|
-- Load Route Modules
|
2025-06-24 22:01:38 +02:00
|
|
|
local MailRoute = require("src.routes.mail")
|
|
|
|
|
local AuthRoute = require("src.routes.auth")
|
2025-09-05 19:25:02 +02:00
|
|
|
local HealthRoute = require("src.routes.health")
|
2025-06-24 22:01:38 +02:00
|
|
|
|
2025-06-17 20:40:40 +02:00
|
|
|
-- Load configuration
|
|
|
|
|
local config = require("config.server")
|
|
|
|
|
|
2025-09-05 19:25:02 +02:00
|
|
|
-- Initialize server
|
2025-06-17 20:40:40 +02:00
|
|
|
local server = FurtServer:new()
|
|
|
|
|
|
2025-09-05 19:25:02 +02:00
|
|
|
-- Register public routes (no authentication required)
|
|
|
|
|
server:add_route("GET", "/health", HealthRoute.handle_health)
|
2025-06-17 20:40:40 +02:00
|
|
|
|
2025-08-29 20:01:47 +02:00
|
|
|
-- Test endpoint for development (configurable via furt.conf)
|
|
|
|
|
if config.security and config.security.enable_test_endpoint then
|
2025-09-05 19:25:02 +02:00
|
|
|
server:add_route("POST", "/test", HealthRoute.handle_test)
|
2025-08-29 20:01:47 +02:00
|
|
|
print("[WARN] Test endpoint enabled via configuration")
|
2025-06-24 22:01:38 +02:00
|
|
|
end
|
2025-06-19 09:52:15 +02:00
|
|
|
|
2025-09-05 19:25:02 +02:00
|
|
|
-- Register protected routes (require authentication)
|
2025-06-24 22:01:38 +02:00
|
|
|
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)
|
2025-06-17 20:40:40 +02:00
|
|
|
|
|
|
|
|
-- Start server
|
|
|
|
|
server:start()
|
|
|
|
|
|