refactor: move seeder to api, improve coverage and security

This commit is contained in:
Tiago Yamamoto 2025-12-20 11:03:09 -03:00
parent e73d423b16
commit bad6d15a60

View file

@ -62,13 +62,6 @@ func New(cfg config.Config) (*Server, error) {
auth := middleware.RequireAuth([]byte(cfg.JWTSecret))
adminOnly := middleware.RequireAuth([]byte(cfg.JWTSecret), "Admin")
// Apply global security headers to all routes or specific ones?
// The chain function is handy. Let's add it to the chains.
// Actually, maybe a global wrapper? But current design uses explicit chains.
// Let's add it to the chains. Or even better, wrap the whole mux?
// The Start() method wraps the mux with CORS. We can wrap it there too if we want global.
// But let's look at Start() method.
mux.Handle("POST /api/v1/companies", chain(http.HandlerFunc(h.CreateCompany), middleware.Logger, middleware.Gzip))
mux.Handle("GET /api/v1/companies", chain(http.HandlerFunc(h.ListCompanies), middleware.Logger, middleware.Gzip))
mux.Handle("GET /api/v1/companies/{id}", chain(http.HandlerFunc(h.GetCompany), middleware.Logger, middleware.Gzip))