webapp
Some checks failed
Docker Build and Publish / publish (push) Failing after 1m33s

This commit is contained in:
Eugene Howe
2026-02-17 09:47:30 -05:00
parent af09672ee3
commit b0957bfa49
102 changed files with 4213 additions and 378 deletions

View File

@@ -0,0 +1,36 @@
package views_api
import (
"log"
"net/http"
"clintonambulance.com/calculate_negative_points/internal/api/middleware"
"clintonambulance.com/calculate_negative_points/internal/api/requests/negative_points_processor"
"clintonambulance.com/calculate_negative_points/internal/api/requests/users"
"clintonambulance.com/calculate_negative_points/internal/config"
"github.com/go-chi/chi/v5"
"github.com/go-chi/cors"
"github.com/swaggest/rest/nethttp"
"github.com/swaggest/rest/web"
"go.uber.org/zap"
)
func MountInternalApiEndpoints(e *web.Service, config *config.ApplicationConfig, logger *zap.Logger) {
e.Route("/api", func(r chi.Router) {
r.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{"http://localhost:3000"},
AllowedMethods: []string{"GET", "POST", "OPTIONS"},
AllowedHeaders: []string{"*"},
AllowCredentials: true,
}))
currentUserMiddlware, err := middleware.CurrentUserMiddleware(config)
if err != nil {
log.Fatal(err)
}
r.Use(currentUserMiddlware)
r.Method(http.MethodGet, "/users/current", nethttp.NewHandler(users.GetCurrentUser()))
r.Method(http.MethodPost, "/process", nethttp.NewHandler(negative_points_processor.NegativePointsProcessor(config, logger)))
r.With(middleware.Logout(config)).Method(http.MethodDelete, "/users/current", nethttp.NewHandler(users.Logout()))
})
}