Files
sentinela-go/internal/api/routes.go
Rainbow a2b0db8f3f feat: tiered API plans (Free/Bronze/Gold/Platinum)
- Free: $0, 30 req/min, market data only
- Bronze: $29/mo, 100 req/min, + companies & search
- Gold: $99/mo, 500 req/min, + filings & historical
- Platinum: $299/mo, 2000 req/min, all features + priority
- Plan-aware rate limiting per API key (or per IP for free)
- Usage tracking with daily aggregation
- GET /api/v1/plans — plan listing
- POST /api/v1/plans/register — instant free API key
- GET /api/v1/plans/usage — usage stats
- /pricing — dark-themed HTML pricing page
- X-RateLimit-* and X-Plan headers on every response
- Restricted endpoints return upgrade prompt
- Updated OpenAPI spec with security scheme
- 53 handlers, compiles clean
2026-02-10 12:55:45 -03:00

49 lines
1.2 KiB
Go

package api
import (
"github.com/gofiber/fiber/v2"
"github.com/sentinela-go/internal/api/handlers"
"github.com/sentinela-go/internal/db"
)
func RegisterRoutes(app *fiber.App, database *db.DB) {
h := handlers.New(database)
app.Get("/health", h.Health)
app.Get("/pricing", h.PricingPage)
v1 := app.Group("/api/v1")
// Plans endpoints (accessible to all)
v1.Get("/plans", h.ListPlans)
v1.Get("/plans/usage", h.PlanUsage)
v1.Post("/plans/register", h.RegisterPlan)
// Companies
v1.Get("/companies", h.ListCompanies)
v1.Get("/companies/search", h.SearchCompanies)
v1.Get("/companies/:id", h.GetCompany)
v1.Get("/companies/:id/filings", h.CompanyFilings)
// Filings
v1.Get("/filings", h.ListFilings)
v1.Get("/filings/search", h.SearchFilings)
v1.Get("/filings/recent", h.RecentFilings)
v1.Get("/filings/:id", h.GetFiling)
// Market
v1.Get("/market/selic", h.ListSelic)
v1.Get("/market/selic/current", h.CurrentSelic)
v1.Get("/market/cdi", h.ListCDI)
v1.Get("/market/cdi/current", h.CurrentCDI)
v1.Get("/market/ipca", h.ListIPCA)
v1.Get("/market/ipca/current", h.CurrentIPCA)
v1.Get("/market/fx", h.ListFX)
v1.Get("/market/fx/current", h.CurrentFX)
v1.Get("/market/overview", h.MarketOverview)
// Search
v1.Get("/search", h.GlobalSearch)
}