# Jobs Scraper API Makefile

# Variables
APP_NAME=jobs-scraper
API_DIR=./api
DOCS_DIR=./docs
BIN_DIR=./bin
MAIN_FILE=$(API_DIR)/main.go

# Default target

# NATS server with JetStream
nats-server:
	@echo "Starting NATS server with JetStream..."
	docker run --rm -p 4222:4222 -p 8222:8222 nats:latest -js

.DEFAULT_GOAL := run

.PHONY: run
run: ## Run the application
	@echo "Running $(APP_NAME)..."
	@go run $(MAIN_FILE)

.PHONY: clean
clean: ## Clean build artifacts
	@echo "Cleaning build artifacts..."
	@rm -rf $(BIN_DIR)
	@echo "Clean complete"

# Swagger documentation
.PHONY: swagger
swagger: ## Generate Swagger documentation
	@echo "Generating Swagger documentation..."
	@go run github.com/swaggo/swag/cmd/swag@latest init -g $(MAIN_FILE) -o $(DOCS_DIR)
	@echo "Swagger documentation generated in $(DOCS_DIR)/"

# Docker operations (if needed in the future)
.PHONY: docker-build
docker-build: ## Build Docker image
	@echo "Building Docker image..."
	@docker build -t $(APP_NAME) .
	@echo "Docker image built: $(APP_NAME)"

.PHONY: docker-run
docker-run: ## Run Docker container
	@echo "Running Docker container..."
	@docker run -p 8080:8080 $(APP_NAME)

