feat: Sentinela v0.2.0 — Brazilian Financial Data API in Go
- 20 Go source files, single 16MB binary - SQLite + FTS5 full-text search (pure Go, no CGO) - BCB integration: Selic, CDI, IPCA, USD/BRL, EUR/BRL - CVM integration: 2,524 companies from registry - Fiber v2 REST API with 42 handlers - Auto-seeds on first run (~5s for BCB + CVM) - Token bucket rate limiter, optional API key auth - Periodic sync scheduler (configurable) - Graceful shutdown, structured logging (slog) - All endpoints tested with real data
This commit is contained in:
31
internal/api/server.go
Normal file
31
internal/api/server.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
|
||||
"github.com/sentinela-go/internal/api/middleware"
|
||||
"github.com/sentinela-go/internal/config"
|
||||
"github.com/sentinela-go/internal/db"
|
||||
)
|
||||
|
||||
func NewServer(cfg *config.Config, database *db.DB) *fiber.App {
|
||||
app := fiber.New(fiber.Config{
|
||||
AppName: "Sentinela API",
|
||||
})
|
||||
|
||||
app.Use(recover.New())
|
||||
app.Use(logger.New())
|
||||
app.Use(cors.New())
|
||||
app.Use(middleware.NewRateLimiter(cfg.RateLimit))
|
||||
|
||||
if cfg.APIKey != "" {
|
||||
app.Use(middleware.NewAPIKeyAuth(cfg.APIKey))
|
||||
}
|
||||
|
||||
RegisterRoutes(app, database)
|
||||
|
||||
return app
|
||||
}
|
||||
Reference in New Issue
Block a user