- Add comprehensive root README with badges, architecture diagram, and setup guide - Update backend README with security middlewares and endpoint documentation - Update frontend README with design system and page structure - Update seeder-api README with generated data and credentials - Add internal module READMEs (middleware, handlers, components) - Document Clean Architecture layers and request flow - Add environment variables reference table
47 lines
1.2 KiB
Go
Executable file
47 lines
1.2 KiB
Go
Executable file
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
"github.com/rede5/gohorsejobs/backend/internal/database"
|
|
"github.com/rede5/gohorsejobs/backend/internal/router"
|
|
)
|
|
|
|
// @title GoHorseJobs API
|
|
// @version 1.0
|
|
// @description API for GoHorseJobs recruitment platform.
|
|
// @host localhost:8080
|
|
// @BasePath /
|
|
func main() {
|
|
// Load .env file
|
|
if err := godotenv.Load(); err != nil {
|
|
log.Println("No .env file found or error loading it")
|
|
}
|
|
|
|
// Validate JWT_SECRET strength (must be at least 32 characters / 256 bits)
|
|
jwtSecret := os.Getenv("JWT_SECRET")
|
|
if jwtSecret == "" || len(jwtSecret) < 32 {
|
|
log.Println("⚠️ WARNING: JWT_SECRET is empty or too short (< 32 chars). Use a strong secret in production!")
|
|
if os.Getenv("ENV") == "production" {
|
|
log.Fatal("FATAL: Cannot start in production without strong JWT_SECRET")
|
|
}
|
|
}
|
|
|
|
database.InitDB()
|
|
database.RunMigrations()
|
|
|
|
handler := router.NewRouter()
|
|
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
log.Println("Starting server on :" + port)
|
|
if err := http.ListenAndServe(":"+port, handler); err != nil {
|
|
log.Fatalf("Server failed to start: %v", err)
|
|
}
|
|
}
|