Remediate all P0-S priority findings from cross-platform architecture audit: - Add input validation and authorization checks across handlers - Harden social auth (Apple/Google) token validation - Add document ownership verification and file type validation - Add rate limiting config and CORS origin restrictions - Add subscription tier enforcement in handlers - Add OpenAPI 3.0.3 spec (81 schemas, 104 operations) - Add URL-level contract test (KMP API routes match spec paths) - Add model-level contract test (65 schemas, 464 fields validated) - Add CI workflow for backend tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
145 lines
3.1 KiB
Makefile
145 lines
3.1 KiB
Makefile
.PHONY: build run test contract-test clean deps lint docker-build docker-up docker-down migrate
|
|
|
|
# Binary names
|
|
API_BINARY=casera-api
|
|
WORKER_BINARY=casera-worker
|
|
ADMIN_BINARY=casera-admin
|
|
|
|
# Build flags
|
|
LDFLAGS=-ldflags "-s -w"
|
|
|
|
# Default target
|
|
all: build
|
|
|
|
# Install dependencies
|
|
deps:
|
|
go mod download
|
|
go mod tidy
|
|
|
|
# Build the API binary
|
|
build:
|
|
go build $(LDFLAGS) -o bin/$(API_BINARY) ./cmd/api
|
|
|
|
# Build the worker binary
|
|
build-worker:
|
|
go build $(LDFLAGS) -o bin/$(WORKER_BINARY) ./cmd/worker
|
|
|
|
# Build the admin binary
|
|
build-admin:
|
|
go build $(LDFLAGS) -o bin/$(ADMIN_BINARY) ./cmd/admin
|
|
|
|
# Build all binaries
|
|
build-all: build build-worker build-admin
|
|
|
|
# Run the API server
|
|
run:
|
|
go run ./cmd/api
|
|
|
|
# Run the worker
|
|
run-worker:
|
|
go run ./cmd/worker
|
|
|
|
# Run the admin
|
|
run-admin:
|
|
go run ./cmd/admin
|
|
|
|
# Run tests
|
|
test:
|
|
go test -v -race -cover ./...
|
|
|
|
# Run contract validation tests (routes + KMP vs OpenAPI spec)
|
|
contract-test:
|
|
go test -v -run "TestRouteSpecContract|TestKMPSpecContract" ./internal/integration/
|
|
|
|
# Run tests with coverage
|
|
test-coverage:
|
|
go test -v -race -coverprofile=coverage.out ./...
|
|
go tool cover -html=coverage.out -o coverage.html
|
|
|
|
# Run linter
|
|
lint:
|
|
golangci-lint run ./...
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
rm -rf bin/
|
|
rm -f coverage.out coverage.html
|
|
|
|
# Format code
|
|
fmt:
|
|
go fmt ./...
|
|
|
|
# Vet code
|
|
vet:
|
|
go vet ./...
|
|
|
|
# Docker commands
|
|
docker-build:
|
|
docker-compose build
|
|
|
|
docker-up:
|
|
docker-compose up -d
|
|
|
|
docker-down:
|
|
docker-compose down
|
|
|
|
docker-logs:
|
|
docker-compose logs -f
|
|
|
|
docker-dev:
|
|
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build
|
|
|
|
docker-restart:
|
|
docker-compose down && docker-compose up -d
|
|
|
|
# Database migrations
|
|
migrate-up:
|
|
migrate -path migrations -database "$(DATABASE_URL)" up
|
|
|
|
migrate-down:
|
|
migrate -path migrations -database "$(DATABASE_URL)" down
|
|
|
|
migrate-create:
|
|
migrate create -ext sql -dir migrations -seq $(name)
|
|
|
|
# Development helpers
|
|
dev: deps run
|
|
|
|
# Generate swagger docs (if using swag)
|
|
swagger:
|
|
swag init -g cmd/api/main.go -o docs/swagger
|
|
|
|
# Help
|
|
help:
|
|
@echo "Casera API Go - Available targets:"
|
|
@echo ""
|
|
@echo "Build:"
|
|
@echo " deps - Install dependencies"
|
|
@echo " build - Build API binary"
|
|
@echo " build-all - Build all binaries (API, Worker, Admin)"
|
|
@echo " clean - Clean build artifacts"
|
|
@echo ""
|
|
@echo "Run:"
|
|
@echo " run - Run API server"
|
|
@echo " run-worker - Run background worker"
|
|
@echo " run-admin - Run admin panel"
|
|
@echo ""
|
|
@echo "Test & Lint:"
|
|
@echo " test - Run tests"
|
|
@echo " test-coverage - Run tests with coverage"
|
|
@echo " lint - Run linter"
|
|
@echo " fmt - Format code"
|
|
@echo " vet - Vet code"
|
|
@echo ""
|
|
@echo "Docker:"
|
|
@echo " docker-build - Build Docker images"
|
|
@echo " docker-up - Start Docker containers"
|
|
@echo " docker-down - Stop Docker containers"
|
|
@echo " docker-logs - View Docker logs"
|
|
@echo " docker-dev - Start in development mode"
|
|
@echo " docker-restart- Restart all containers"
|
|
@echo ""
|
|
@echo "Database:"
|
|
@echo " migrate-up - Run database migrations"
|
|
@echo " migrate-down - Rollback database migrations"
|