├── internal ├── pkg │ ├── constants │ │ └── error.go │ ├── utils │ │ ├── hash.go │ │ └── validator.go │ └── sessionmanager │ │ └── session.go ├── apps │ └── account │ │ ├── handlers │ │ ├── h_home.go │ │ ├── handler.go │ │ ├── h_login.go │ │ └── h_register.go │ │ ├── routes │ │ └── route.go │ │ ├── repositories │ │ ├── repository_mock.go │ │ └── repository.go │ │ ├── models │ │ ├── session.go │ │ └── user.go │ │ └── services │ │ ├── service.go │ │ └── service_test.go ├── database │ ├── autoMigrateModels.go │ ├── gorm.go │ ├── database_test.go │ └── database.go └── server │ ├── server.go │ ├── routes_test.go │ └── routes.go ├── Dockerfile ├── .gitignore ├── .air.toml ├── docker-compose.yml ├── Makefile ├── cmd └── api │ └── main.go ├── README.md ├── go.mod ├── docs ├── swagger.yaml ├── swagger.json └── docs.go ├── go.sum └── LICENSE /internal/pkg/constants/error.go: -------------------------------------------------------------------------------- 1 | package constants 2 | 3 | import "errors" 4 | 5 | var ( 6 | ErrUserAlreadyExist = errors.New("User already exist") 7 | ErrUserNotFound = errors.New("User is not found") 8 | ErrInternalServer = errors.New("Unexpected error happened. Please try again!") 9 | ) 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.23-alpine AS build 2 | 3 | WORKDIR /app 4 | 5 | COPY go.mod go.sum ./ 6 | RUN go mod download 7 | 8 | COPY . . 9 | 10 | RUN go build -o main cmd/api/main.go 11 | 12 | FROM alpine:3.20.1 AS prod 13 | WORKDIR /app 14 | COPY --from=build /app/main /app/main 15 | EXPOSE ${PORT} 16 | CMD ["./main"] 17 | 18 | 19 | -------------------------------------------------------------------------------- /internal/pkg/utils/hash.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import "golang.org/x/crypto/bcrypt" 4 | 5 | const cost int = 14 6 | 7 | func HashPassword(password string) (string, error) { 8 | bytes, err := bcrypt.GenerateFromPassword([]byte(password), cost) 9 | return string(bytes), err 10 | } 11 | 12 | func CheckPasswordHash(password, hash string) bool { 13 | err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /internal/apps/account/handlers/h_home.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "time" 7 | 8 | "github.com/gofiber/fiber/v2" 9 | ) 10 | 11 | func (s *accountHandler) AccountHomeHandler(c *fiber.Ctx) error { 12 | ctx, cancel := context.WithTimeout(c.UserContext(), 1*time.Second) 13 | defer cancel() 14 | 15 | users, err := s.service.FindUsers(ctx) 16 | if err != nil { 17 | return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to fetch users"}) 18 | } 19 | 20 | return c.JSON(fiber.Map{"users": users}) 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with "go test -c" 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ 16 | 17 | # Go workspace file 18 | go.work 19 | tmp/ 20 | 21 | # IDE specific files 22 | .vscode 23 | .idea 24 | 25 | # .env file 26 | .env 27 | 28 | # Project build 29 | main 30 | *templ.go 31 | 32 | # OS X generated file 33 | .DS_Store 34 | 35 | -------------------------------------------------------------------------------- /internal/database/autoMigrateModels.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/models" 5 | "log/slog" 6 | 7 | "gorm.io/gorm" 8 | ) 9 | 10 | var modelList = map[string]interface{}{ 11 | "users": &models.User{}, 12 | } 13 | 14 | func autoMigrateModels(DB *gorm.DB) { 15 | for name, model := range modelList { 16 | slog.Info("Migrating start for", 17 | "entity", name, 18 | ) 19 | 20 | err := DB.AutoMigrate(model) 21 | if err != nil { 22 | slog.Error("Migrating error for", 23 | "entity", name, 24 | "err", err, 25 | ) 26 | continue 27 | } 28 | 29 | slog.Info("Migrating done for", 30 | "entity", name, 31 | ) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /internal/apps/account/handlers/handler.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/services" 5 | "Kaho_BaaS/internal/pkg/sessionmanager" 6 | "Kaho_BaaS/internal/pkg/utils" 7 | 8 | "github.com/gofiber/fiber/v2" 9 | ) 10 | 11 | type AccountHandler interface { 12 | AccountHomeHandler(c *fiber.Ctx) error 13 | LoginHandler(c *fiber.Ctx) error 14 | RegisterHandler(c *fiber.Ctx) error 15 | } 16 | 17 | type accountHandler struct { 18 | service services.AccountService 19 | session *sessionmanager.SessionManager 20 | validator *utils.Validator 21 | } 22 | 23 | func NewAccountHandler(service services.AccountService, sessionManager *sessionmanager.SessionManager) AccountHandler { 24 | return &accountHandler{ 25 | service: service, 26 | session: sessionManager, 27 | validator: utils.NewValidator(), 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /internal/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/gofiber/fiber/v2" 5 | 6 | "Kaho_BaaS/internal/database" 7 | "Kaho_BaaS/internal/pkg/sessionmanager" 8 | ) 9 | 10 | type FiberServer struct { 11 | *fiber.App 12 | 13 | db database.Service 14 | gormDB database.ServiceGorm 15 | sessionmanager *sessionmanager.SessionManager 16 | } 17 | 18 | func New() *FiberServer { 19 | gormDB, err := database.ConnectDatabase() 20 | if err != nil { 21 | return nil 22 | } 23 | 24 | server := &FiberServer{ 25 | App: fiber.New(fiber.Config{ 26 | ServerHeader: "Kaho_BaaS", 27 | AppName: "Kaho_BaaS", 28 | StrictRouting: true, 29 | CaseSensitive: true, 30 | }), 31 | 32 | db: database.New(), 33 | gormDB: gormDB, 34 | sessionmanager: sessionmanager.NewSessionManager(), 35 | } 36 | 37 | return server 38 | } 39 | -------------------------------------------------------------------------------- /internal/apps/account/routes/route.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/handlers" 5 | "Kaho_BaaS/internal/apps/account/repositories" 6 | "Kaho_BaaS/internal/apps/account/services" 7 | "Kaho_BaaS/internal/pkg/sessionmanager" 8 | 9 | "github.com/gofiber/fiber/v2" 10 | "gorm.io/gorm" 11 | ) 12 | 13 | func RegisterRoutes(router fiber.Router, db *gorm.DB, sessionManager *sessionmanager.SessionManager) { 14 | accountGroup := router.Group("/account") 15 | accountRepository := repositories.NewAccountRepository(db) 16 | accountService := services.NewAccountService(accountRepository) 17 | accountHandler := handlers.NewAccountHandler(accountService, sessionManager) 18 | 19 | accountGroup.Get("/", accountHandler.AccountHomeHandler) 20 | accountGroup.Post("/sessions/login", accountHandler.LoginHandler) 21 | accountGroup.Post("/sessions/register", accountHandler.RegisterHandler) 22 | } 23 | -------------------------------------------------------------------------------- /internal/apps/account/repositories/repository_mock.go: -------------------------------------------------------------------------------- 1 | package repositories 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/models" 5 | "context" 6 | 7 | "github.com/stretchr/testify/mock" 8 | "gorm.io/gorm" 9 | ) 10 | 11 | type AccountRepositoryMock struct { 12 | Mock mock.Mock 13 | } 14 | 15 | func (ar *AccountRepositoryMock) FindUsers(ctx context.Context) ([]models.User, error) { 16 | return []models.User{}, nil 17 | } 18 | 19 | func (ar *AccountRepositoryMock) FindUserByEmail(ctx context.Context, email string) (*models.User, error) { 20 | args := ar.Mock.Called(email) 21 | 22 | if args.Get(0) == nil { 23 | return nil, gorm.ErrRecordNotFound 24 | } 25 | 26 | user := args.Get(0).(models.User) 27 | 28 | return &user, nil 29 | } 30 | 31 | func (ar *AccountRepositoryMock) Create(ctx context.Context, data *models.Register) (*models.User, error) { 32 | user := models.User{ 33 | Email: data.Email, 34 | Password: data.Password, 35 | Name: data.Name, 36 | } 37 | 38 | return &user, nil 39 | } 40 | -------------------------------------------------------------------------------- /.air.toml: -------------------------------------------------------------------------------- 1 | root = "." 2 | testdata_dir = "testdata" 3 | tmp_dir = "tmp" 4 | 5 | [build] 6 | args_bin = [] 7 | bin = "./main" 8 | cmd = "make build" 9 | delay = 1000 10 | exclude_dir = ["assets", "tmp", "vendor", "testdata", "node_modules"] 11 | exclude_file = [] 12 | exclude_regex = ["_test.go"] 13 | exclude_unchanged = false 14 | follow_symlink = false 15 | full_bin = "" 16 | include_dir = [] 17 | include_ext = ["go", "tpl", "tmpl", "html"] 18 | include_file = [] 19 | kill_delay = "0s" 20 | log = "build-errors.log" 21 | poll = false 22 | poll_interval = 0 23 | post_cmd = [] 24 | pre_cmd = [] 25 | rerun = false 26 | rerun_delay = 500 27 | send_interrupt = false 28 | stop_on_error = false 29 | 30 | [color] 31 | app = "" 32 | build = "yellow" 33 | main = "magenta" 34 | runner = "green" 35 | watcher = "cyan" 36 | 37 | [log] 38 | main_only = false 39 | time = false 40 | 41 | [misc] 42 | clean_on_exit = false 43 | 44 | [screen] 45 | clear_on_rebuild = false 46 | keep_scroll = true 47 | -------------------------------------------------------------------------------- /internal/pkg/sessionmanager/session.go: -------------------------------------------------------------------------------- 1 | package sessionmanager 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "github.com/gofiber/fiber/v2/middleware/session" 8 | ) 9 | 10 | // SessionManager struct 11 | type SessionManager struct { 12 | cache map[string]*session.Store 13 | } 14 | 15 | // NewSessionManager untuk membuat instance SessionManager 16 | func NewSessionManager() *SessionManager { 17 | return &SessionManager{ 18 | cache: make(map[string]*session.Store), 19 | } 20 | } 21 | 22 | // GetSessionInstance mengembalikan instance session berdasarkan Project ID 23 | func (s *SessionManager) GetSessionInstance(projectID string) *session.Store { 24 | // Cek apakah sudah ada session untuk project ini 25 | if sess, exists := s.cache[projectID]; exists { 26 | return sess 27 | } 28 | 29 | // Jika belum ada, buat session baru 30 | newSession := session.New(session.Config{ 31 | KeyLookup: fmt.Sprintf("cookie:kaho_session_%s", projectID), 32 | Expiration: 24 * time.Hour, 33 | }) 34 | 35 | // Simpan ke cache 36 | s.cache[projectID] = newSession 37 | 38 | return newSession 39 | } 40 | -------------------------------------------------------------------------------- /internal/server/routes_test.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/gofiber/fiber/v2" 5 | "io" 6 | "net/http" 7 | "testing" 8 | ) 9 | 10 | func TestHandler(t *testing.T) { 11 | // Create a Fiber app for testing 12 | app := fiber.New() 13 | // Inject the Fiber app into the server 14 | s := &FiberServer{App: app} 15 | // Define a route in the Fiber app 16 | app.Get("/", s.HelloWorldHandler) 17 | // Create a test HTTP request 18 | req, err := http.NewRequest("GET", "/", nil) 19 | if err != nil { 20 | t.Fatalf("error creating request. Err: %v", err) 21 | } 22 | // Perform the request 23 | resp, err := app.Test(req) 24 | if err != nil { 25 | t.Fatalf("error making request to server. Err: %v", err) 26 | } 27 | // Your test assertions... 28 | if resp.StatusCode != http.StatusOK { 29 | t.Errorf("expected status OK; got %v", resp.Status) 30 | } 31 | expected := "{\"message\":\"Hello World\"}" 32 | body, err := io.ReadAll(resp.Body) 33 | if err != nil { 34 | t.Fatalf("error reading response body. Err: %v", err) 35 | } 36 | if expected != string(body) { 37 | t.Errorf("expected response body to be %v; got %v", expected, string(body)) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /internal/server/routes.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | _ "Kaho_BaaS/docs" 5 | accountroutes "Kaho_BaaS/internal/apps/account/routes" 6 | 7 | "github.com/gofiber/fiber/v2" 8 | "github.com/gofiber/fiber/v2/middleware/cors" 9 | "github.com/gofiber/fiber/v2/middleware/logger" 10 | "github.com/gofiber/swagger" 11 | ) 12 | 13 | func (s *FiberServer) RegisterFiberRoutes() { 14 | // Apply CORS middleware 15 | s.App.Use(cors.New(cors.Config{ 16 | AllowOrigins: "*", 17 | AllowMethods: "GET,POST,PUT,DELETE,OPTIONS,PATCH", 18 | AllowHeaders: "Accept,Authorization,Content-Type", 19 | AllowCredentials: false, // credentials require explicit origins 20 | MaxAge: 300, 21 | })) 22 | 23 | s.App.Use(logger.New()) 24 | 25 | s.App.Get("/docs/*", swagger.HandlerDefault) 26 | 27 | v1 := s.App.Group("/v1") 28 | 29 | // Register routes 30 | accountroutes.RegisterRoutes(v1, s.gormDB.DB(), s.sessionmanager) 31 | 32 | s.App.Get("/", s.HelloWorldHandler) 33 | 34 | s.App.Get("/health", s.healthHandler) 35 | 36 | } 37 | 38 | func (s *FiberServer) HelloWorldHandler(c *fiber.Ctx) error { 39 | resp := fiber.Map{ 40 | "message": "Hello World", 41 | } 42 | 43 | return c.JSON(resp) 44 | } 45 | 46 | func (s *FiberServer) healthHandler(c *fiber.Ctx) error { 47 | return c.JSON(s.db.Health()) 48 | } 49 | -------------------------------------------------------------------------------- /internal/pkg/utils/validator.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | 7 | "github.com/go-playground/validator/v10" 8 | ) 9 | 10 | type Validator struct { 11 | validate *validator.Validate 12 | } 13 | 14 | func NewValidator() *Validator { 15 | return &Validator{ 16 | validate: validator.New(validator.WithRequiredStructEnabled()), 17 | } 18 | } 19 | 20 | func (v *Validator) Validate(data any) map[string]string { 21 | err := v.validate.Struct(data) 22 | if err == nil { 23 | return nil 24 | } 25 | 26 | validationErrs := make(map[string]string, 0) 27 | for _, v := range err.(validator.ValidationErrors) { 28 | var e error 29 | switch v.Tag() { 30 | case "required": 31 | e = fmt.Errorf("Field '%s' cannot be empty", v.Field()) 32 | case "email": 33 | e = fmt.Errorf("Field '%s' must be a valid email address", v.Field()) 34 | case "len": 35 | e = fmt.Errorf("Field '%s' must be exactly %v characters long", v.Field(), v.Param()) 36 | case "min": 37 | e = fmt.Errorf("Field '%s' must at least '%v' characters long", v.Field(), v.Param()) 38 | case "max": 39 | e = fmt.Errorf("Field '%s' must not exceed '%v' characters long", v.Field(), v.Param()) 40 | default: 41 | e = fmt.Errorf("Field '%s' must satisfy '%s' '%v' criteria", v.Field(), v.Tag(), v.Param()) 42 | } 43 | 44 | validationErrs[strings.ToLower(v.Field())] = e.Error() 45 | } 46 | 47 | return validationErrs 48 | } 49 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app: 3 | build: 4 | context: . 5 | dockerfile: Dockerfile 6 | target: prod 7 | restart: unless-stopped 8 | ports: 9 | - ${PORT}:${PORT} 10 | environment: 11 | APP_ENV: ${APP_ENV} 12 | PORT: ${PORT} 13 | BLUEPRINT_DB_HOST: ${BLUEPRINT_DB_HOST} 14 | BLUEPRINT_DB_PORT: ${BLUEPRINT_DB_PORT} 15 | BLUEPRINT_DB_DATABASE: ${BLUEPRINT_DB_DATABASE} 16 | BLUEPRINT_DB_USERNAME: ${BLUEPRINT_DB_USERNAME} 17 | BLUEPRINT_DB_PASSWORD: ${BLUEPRINT_DB_PASSWORD} 18 | BLUEPRINT_DB_SCHEMA: ${BLUEPRINT_DB_SCHEMA} 19 | depends_on: 20 | psql_bp: 21 | condition: service_healthy 22 | networks: 23 | - blueprint 24 | psql_bp: 25 | image: postgres:latest 26 | restart: unless-stopped 27 | environment: 28 | POSTGRES_DB: ${BLUEPRINT_DB_DATABASE} 29 | POSTGRES_USER: ${BLUEPRINT_DB_USERNAME} 30 | POSTGRES_PASSWORD: ${BLUEPRINT_DB_PASSWORD} 31 | ports: 32 | - "${BLUEPRINT_DB_PORT}:5432" 33 | volumes: 34 | - psql_volume_bp:/var/lib/postgresql/data 35 | healthcheck: 36 | test: ["CMD-SHELL", "sh -c 'pg_isready -U ${BLUEPRINT_DB_USERNAME} -d ${BLUEPRINT_DB_DATABASE}'"] 37 | interval: 5s 38 | timeout: 5s 39 | retries: 3 40 | start_period: 15s 41 | networks: 42 | - blueprint 43 | 44 | volumes: 45 | psql_volume_bp: 46 | networks: 47 | blueprint: 48 | -------------------------------------------------------------------------------- /internal/apps/account/repositories/repository.go: -------------------------------------------------------------------------------- 1 | package repositories 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/models" 5 | "context" 6 | 7 | "gorm.io/gorm" 8 | ) 9 | 10 | type AccountRepository interface { 11 | FindUsers(ctx context.Context) ([]models.User, error) 12 | FindUserByEmail(ctx context.Context, email string) (*models.User, error) 13 | Create(ctx context.Context, data *models.Register) (*models.User, error) 14 | } 15 | 16 | type accountRepository struct { 17 | db *gorm.DB 18 | } 19 | 20 | func NewAccountRepository(db *gorm.DB) AccountRepository { 21 | return &accountRepository{ 22 | db: db, 23 | } 24 | } 25 | 26 | // FindUsers implements AccountRepository. 27 | func (as *accountRepository) FindUsers(ctx context.Context) ([]models.User, error) { 28 | var users []models.User 29 | 30 | result := as.db.WithContext(ctx).Debug().Find(&users) 31 | 32 | return users, result.Error 33 | } 34 | 35 | // FindUserByEmail implements AccountService. 36 | func (as *accountRepository) FindUserByEmail(ctx context.Context, email string) (*models.User, error) { 37 | var user models.User 38 | 39 | result := as.db.WithContext(ctx).Debug().First(&user) 40 | 41 | return &user, result.Error 42 | } 43 | 44 | // Create implements AccountService. 45 | func (as *accountRepository) Create(ctx context.Context, data *models.Register) (*models.User, error) { 46 | user := models.User{ 47 | Email: data.Email, 48 | Password: data.Password, 49 | Name: data.Name, 50 | } 51 | 52 | result := as.db.WithContext(ctx).Debug().Create(&user) 53 | 54 | return &user, result.Error 55 | } 56 | -------------------------------------------------------------------------------- /internal/database/gorm.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "log/slog" 7 | "os" 8 | "sync" 9 | 10 | "gorm.io/driver/postgres" 11 | "gorm.io/gorm" 12 | ) 13 | 14 | type ServiceGorm interface { 15 | DB() *gorm.DB 16 | } 17 | 18 | type serviceGorm struct { 19 | db *gorm.DB 20 | } 21 | 22 | func (s *serviceGorm) DB() *gorm.DB { 23 | return s.db 24 | } 25 | 26 | var ( 27 | instance *serviceGorm 28 | once sync.Once 29 | ) 30 | 31 | // ConnectDatabase menggunakan pola Singleton agar koneksi database tidak dibuat berulang kali 32 | func ConnectDatabase() (*serviceGorm, error) { 33 | var err error 34 | once.Do(func() { 35 | // Pastikan semua environment variable ada 36 | host := os.Getenv("DB_HOST") 37 | user := os.Getenv("DB_USERNAME") 38 | pass := os.Getenv("DB_PASSWORD") 39 | dbname := os.Getenv("DB_DATABASE") 40 | port := os.Getenv("DB_PORT") 41 | 42 | if host == "" || user == "" || pass == "" || dbname == "" || port == "" { 43 | log.Println("Database configuration is missing required environment variables") 44 | err = fmt.Errorf("missing database configuration") 45 | return 46 | } 47 | 48 | dsn := fmt.Sprintf( 49 | "host=%s user=%s password=%s dbname=%s port=%s sslmode=disable", 50 | host, user, pass, dbname, port, 51 | ) 52 | 53 | DB, dbErr := gorm.Open(postgres.Open(dsn), &gorm.Config{}) 54 | if dbErr != nil { 55 | log.Println("Failed to connect to database:", dbErr) 56 | err = dbErr 57 | return 58 | } 59 | sqlDB, _ := DB.DB() 60 | 61 | slog.Info("Success connected to database", 62 | "stats", sqlDB.Stats(), 63 | ) 64 | 65 | autoMigrateModels(DB) 66 | 67 | instance = &serviceGorm{db: DB} 68 | }) 69 | 70 | return instance, err 71 | } 72 | -------------------------------------------------------------------------------- /internal/apps/account/models/session.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "time" 4 | 5 | type Session struct { 6 | ID string `json:"$id"` 7 | CreatedAt time.Time `json:"$createdAt"` 8 | UpdatedAt time.Time `json:"$updatedAt"` 9 | UserID string `json:"userId"` 10 | Expire time.Time `json:"expire"` 11 | Provider string `json:"provider"` 12 | ProviderUid string `json:"providerUid"` 13 | ProviderAccessToken string `json:"providerAccessToken"` 14 | ProviderAccessTokenExpiry time.Time `json:"providerAccessTokenExpiry"` 15 | ProviderRefreshToken string `json:"providerRefreshToken"` 16 | IP string `json:"ip"` 17 | OSCode string `json:"osCode"` 18 | OSName string `json:"osName"` 19 | OSVersion string `json:"osVersion"` 20 | ClientType string `json:"clientType"` 21 | ClientCode string `json:"clientCode"` 22 | ClientName string `json:"clientName"` 23 | ClientVersion string `json:"clientVersion"` 24 | ClientEngine string `json:"clientEngine"` 25 | ClientEngineVersion string `json:"clientEngineVersion"` 26 | DeviceName string `json:"deviceName"` 27 | DeviceBrand string `json:"deviceBrand"` 28 | DeviceModel string `json:"deviceModel"` 29 | CountryCode string `json:"countryCode"` 30 | CountryName string `json:"countryName"` 31 | Current bool `json:"current"` 32 | Factors []string `json:"factors"` 33 | Secret string `json:"secret"` 34 | MFAUpdatedAt time.Time `json:"mfaUpdatedAt"` 35 | } 36 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Simple Makefile for a Go project 2 | 3 | # Build the application 4 | all: build test 5 | 6 | build: 7 | @echo "Building..." 8 | 9 | 10 | @go build -o main cmd/api/main.go 11 | 12 | # Run the application 13 | run: 14 | @go run cmd/api/main.go 15 | # Create DB container 16 | docker-run: 17 | @if docker compose up --build 2>/dev/null; then \ 18 | : ; \ 19 | else \ 20 | echo "Falling back to Docker Compose V1"; \ 21 | docker-compose up --build; \ 22 | fi 23 | 24 | # Shutdown DB container 25 | docker-down: 26 | @if docker compose down 2>/dev/null; then \ 27 | : ; \ 28 | else \ 29 | echo "Falling back to Docker Compose V1"; \ 30 | docker-compose down; \ 31 | fi 32 | 33 | # Test the application 34 | test: 35 | @echo "Testing..." 36 | @go test ./... -v 37 | # Integrations Tests for the application 38 | itest: 39 | @echo "Running integration tests..." 40 | @go test ./internal/database -v 41 | 42 | # Clean the binary 43 | clean: 44 | @echo "Cleaning..." 45 | @rm -f main 46 | 47 | # Live Reload 48 | watch: 49 | @if command -v air > /dev/null; then \ 50 | air; \ 51 | echo "Watching...";\ 52 | else \ 53 | read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \ 54 | if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \ 55 | go install github.com/air-verse/air@latest; \ 56 | air; \ 57 | echo "Watching...";\ 58 | else \ 59 | echo "You chose not to install air. Exiting..."; \ 60 | exit 1; \ 61 | fi; \ 62 | fi 63 | 64 | .PHONY: all build run test clean watch docker-run docker-down itest 65 | 66 | swagger: 67 | @echo "Generating Swagger documentation..." 68 | @swag init -g cmd/api/main.go 69 | 70 | swagger-fmt: 71 | @echo "Formatting Swagger documentation..." 72 | @swag fmt 73 | -------------------------------------------------------------------------------- /cmd/api/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "Kaho_BaaS/internal/server" 5 | "context" 6 | "fmt" 7 | "log" 8 | "os" 9 | "os/signal" 10 | "strconv" 11 | "syscall" 12 | "time" 13 | 14 | _ "Kaho_BaaS/docs" 15 | _ "github.com/joho/godotenv/autoload" 16 | ) 17 | 18 | func gracefulShutdown(fiberServer *server.FiberServer, done chan bool) { 19 | // Create context that listens for the interrupt signal from the OS. 20 | ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) 21 | defer stop() 22 | 23 | // Listen for the interrupt signal. 24 | <-ctx.Done() 25 | 26 | log.Println("shutting down gracefully, press Ctrl+C again to force") 27 | 28 | // The context is used to inform the server it has 5 seconds to finish 29 | // the request it is currently handling 30 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) 31 | defer cancel() 32 | if err := fiberServer.ShutdownWithContext(ctx); err != nil { 33 | log.Printf("Server forced to shutdown with error: %v", err) 34 | } 35 | 36 | log.Println("Server exiting") 37 | 38 | // Notify the main goroutine that the shutdown is complete 39 | done <- true 40 | } 41 | 42 | // @title Kaho BaaS API Documentation 43 | // @version 1.0 44 | // @description API documentation for Kaho BaaS 45 | // @BasePath /v1 46 | func main() { 47 | 48 | server := server.New() 49 | 50 | server.RegisterFiberRoutes() 51 | 52 | // Create a done channel to signal when the shutdown is complete 53 | done := make(chan bool, 1) 54 | 55 | go func() { 56 | port, _ := strconv.Atoi(os.Getenv("PORT")) 57 | err := server.Listen(fmt.Sprintf(":%d", port)) 58 | if err != nil { 59 | panic(fmt.Sprintf("http server error: %s", err)) 60 | } 61 | }() 62 | 63 | // Run graceful shutdown in a separate goroutine 64 | go gracefulShutdown(server, done) 65 | 66 | // Wait for the graceful shutdown to complete 67 | <-done 68 | log.Println("Graceful shutdown complete.") 69 | } 70 | -------------------------------------------------------------------------------- /internal/apps/account/handlers/h_login.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/models" 5 | "context" 6 | "log/slog" 7 | "net/http" 8 | "time" 9 | 10 | "github.com/gofiber/fiber/v2" 11 | ) 12 | 13 | // LoginHandler godoc 14 | // 15 | // @Summary Login user for a project 16 | // @Description Authenticate user credentials and start a user session. 17 | // @Tags account 18 | // @Accept application/x-www-form-urlencoded 19 | // @Produce json 20 | // @Param X-Kaho-Project header string true "Project ID" 21 | // @Param email formData string true "User Email" 22 | // @Param password formData string true "User Password" 23 | // @Success 200 {object} string "Login success response" 24 | // @Failure 400 {object} map[string]string "X-Kaho-Project is required" 25 | // @Failure 401 {object} map[string]string "Invalid credentials" 26 | // @Failure 500 {object} map[string]interface{} "Server error" 27 | // @Router /account/sessions/login [post] 28 | func (h *accountHandler) LoginHandler(c *fiber.Ctx) error { 29 | ctx, cancel := context.WithTimeout(c.UserContext(), 1*time.Second) 30 | defer cancel() 31 | 32 | projectID := c.Get("X-Kaho-Project") 33 | if projectID == "" { 34 | return c.Status(http.StatusBadRequest).JSON(fiber.Map{"error": "X-Kaho-Project is required"}) 35 | } 36 | 37 | data := new(models.Login) 38 | if err := c.BodyParser(data); err != nil { 39 | slog.Error("Failed parsing request body", 40 | "err", err, 41 | ) 42 | 43 | return c.Status(http.StatusUnprocessableEntity).JSON(fiber.Map{"error": "Request body invalid"}) 44 | } 45 | 46 | if errs := h.validator.Validate(data); errs != nil && len(errs) > 0 { 47 | slog.Error("Request body contain invalid data") 48 | 49 | return c.Status(http.StatusUnprocessableEntity).JSON(fiber.Map{"error": errs}) 50 | } 51 | 52 | user, err := h.service.Login(ctx, data) 53 | if err != nil { 54 | return c.Status(http.StatusBadRequest).JSON(fiber.Map{"error": err.Error()}) 55 | } 56 | 57 | sess, err := h.session.GetSessionInstance(projectID).Get(c) 58 | if err != nil { 59 | return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"error": "Session error"}) 60 | } 61 | 62 | // Simpan session 63 | sess.Set("user_id", user.ID) 64 | sess.Set("project_id", projectID) 65 | sess.Save() 66 | 67 | return c.JSON(fiber.Map{"message": "Login Success", "project": projectID}) 68 | } 69 | -------------------------------------------------------------------------------- /internal/database/database_test.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "context" 5 | "log" 6 | "testing" 7 | "time" 8 | 9 | "github.com/testcontainers/testcontainers-go" 10 | "github.com/testcontainers/testcontainers-go/modules/postgres" 11 | "github.com/testcontainers/testcontainers-go/wait" 12 | ) 13 | 14 | func mustStartPostgresContainer() (func(context.Context, ...testcontainers.TerminateOption) error, error) { 15 | var ( 16 | dbName = "database" 17 | dbPwd = "password" 18 | dbUser = "user" 19 | ) 20 | 21 | dbContainer, err := postgres.Run( 22 | context.Background(), 23 | "postgres:latest", 24 | postgres.WithDatabase(dbName), 25 | postgres.WithUsername(dbUser), 26 | postgres.WithPassword(dbPwd), 27 | testcontainers.WithWaitStrategy( 28 | wait.ForLog("database system is ready to accept connections"). 29 | WithOccurrence(2). 30 | WithStartupTimeout(5*time.Second)), 31 | ) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | database = dbName 37 | password = dbPwd 38 | username = dbUser 39 | 40 | dbHost, err := dbContainer.Host(context.Background()) 41 | if err != nil { 42 | return dbContainer.Terminate, err 43 | } 44 | 45 | dbPort, err := dbContainer.MappedPort(context.Background(), "5432/tcp") 46 | if err != nil { 47 | return dbContainer.Terminate, err 48 | } 49 | 50 | host = dbHost 51 | port = dbPort.Port() 52 | 53 | return dbContainer.Terminate, err 54 | } 55 | 56 | func TestMain(m *testing.M) { 57 | teardown, err := mustStartPostgresContainer() 58 | if err != nil { 59 | log.Fatalf("could not start postgres container: %v", err) 60 | } 61 | 62 | m.Run() 63 | 64 | if teardown != nil && teardown(context.Background()) != nil { 65 | log.Fatalf("could not teardown postgres container: %v", err) 66 | } 67 | } 68 | 69 | func TestNew(t *testing.T) { 70 | srv := New() 71 | if srv == nil { 72 | t.Fatal("New() returned nil") 73 | } 74 | } 75 | 76 | func TestHealth(t *testing.T) { 77 | srv := New() 78 | 79 | stats := srv.Health() 80 | 81 | if stats["status"] != "up" { 82 | t.Fatalf("expected status to be up, got %s", stats["status"]) 83 | } 84 | 85 | if _, ok := stats["error"]; ok { 86 | t.Fatalf("expected error not to be present") 87 | } 88 | 89 | if stats["message"] != "It's healthy" { 90 | t.Fatalf("expected message to be 'It's healthy', got %s", stats["message"]) 91 | } 92 | } 93 | 94 | func TestClose(t *testing.T) { 95 | srv := New() 96 | 97 | if srv.Close() != nil { 98 | t.Fatalf("expected Close() to return nil") 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /internal/apps/account/handlers/h_register.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/models" 5 | "context" 6 | "log/slog" 7 | "net/http" 8 | "time" 9 | 10 | "github.com/gofiber/fiber/v2" 11 | ) 12 | 13 | // RegisterHandler godoc 14 | // 15 | // @Summary Register user for a project 16 | // @Description Authenticate user credentials and start a user session. 17 | // @Tags account 18 | // @Accept application/x-www-form-urlencoded 19 | // @Produce json 20 | // @Param X-Kaho-Project header string true "Project ID" 21 | // @Param email formData string true "User Email" 22 | // @Param password formData string true "User Password" 23 | // @Param name formData string true "User Name" 24 | // @Success 200 {object} string "Login success response" 25 | // @Success 201 {object} models.Session "Login success response" 26 | // @Failure 400 {object} map[string]string "X-Kaho-Project is required" 27 | // @Failure 401 {object} map[string]string "Invalid credentials" 28 | // @Failure 500 {object} map[string]interface{} "Server error" 29 | // @Router /account/sessions/register [post] 30 | func (h *accountHandler) RegisterHandler(c *fiber.Ctx) error { 31 | //NOTE: use 2 secs because got timeout when using 1 sec 32 | ctx, cancel := context.WithTimeout(c.UserContext(), 2*time.Second) 33 | defer cancel() 34 | 35 | projectID := c.Get("X-Kaho-Project") // Ambil project ID dari header 36 | if projectID == "" { 37 | return c.Status(400).JSON(fiber.Map{"error": "X-Kaho-Project is required"}) 38 | } 39 | 40 | data := new(models.Register) 41 | if err := c.BodyParser(data); err != nil { 42 | slog.Error("Failed parsing request body", 43 | "err", err, 44 | ) 45 | 46 | return c.Status(http.StatusUnprocessableEntity).JSON(fiber.Map{"error": "Request body invalid"}) 47 | } 48 | 49 | if errs := h.validator.Validate(data); errs != nil && len(errs) > 0 { 50 | slog.Error("Request body contain invalid data") 51 | 52 | return c.Status(http.StatusUnprocessableEntity).JSON(fiber.Map{"error": errs}) 53 | } 54 | 55 | user, err := h.service.Register(ctx, data) 56 | if err != nil { 57 | return c.Status(http.StatusBadRequest).JSON(fiber.Map{"error": err.Error()}) 58 | } 59 | 60 | sess, err := h.session.GetSessionInstance(projectID).Get(c) 61 | if err != nil { 62 | return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"error": "Session error"}) 63 | } 64 | 65 | // Simpan session 66 | sess.Set("user_id", user.ID) 67 | sess.Set("project_id", projectID) 68 | sess.Save() 69 | 70 | return c.Status(http.StatusCreated).JSON(fiber.Map{"message": "Register Success", "project": projectID, "user": user}) 71 | } 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kaho BaaS - Open-Source Backend as a Service 2 | 3 | Kaho BaaS is a high-performance, open-source **Backend as a Service (BaaS)** built with Go. It provides authentication, database management, real-time sync, and serverless functions—so you can focus on building great applications while Kaho handles the backend. Scalable, flexible, and cloud-ready! 🚀 4 | 5 | ## ✨ Features 6 | 7 | ✅ **Authentication & Authorization** – Secure user authentication with JWT, OAuth, and more. 8 | ✅ **Database Management** – Scalable and easy-to-use database solutions. 9 | ✅ **Real-Time & Offline Sync** – Keep your data in sync across devices seamlessly. 10 | ✅ **Serverless Functions** – Deploy custom backend logic without managing servers. 11 | ✅ **REST & GraphQL API** – Access your data effortlessly with modern API support. 12 | ✅ **Self-Hosted & Cloud Ready** – Deploy anywhere, from local setups to cloud platforms. 13 | 14 | --- 15 | 16 | ## 🚀 Getting Started 17 | 18 | ### Prerequisites 19 | - Go (latest version recommended) 20 | - Docker (optional, for containerized deployment) 21 | - PostgreSQL (or any supported database backend) 22 | 23 | ### Installation 24 | 25 | 1. **Clone the Repository** 26 | ```bash 27 | git clone https://github.com/kantorhosting/kaho-baas.git 28 | cd kaho-baas 29 | ``` 30 | 31 | 2. **Install Dependencies** 32 | ```bash 33 | go mod tidy 34 | ``` 35 | 36 | 3. **Run the Server** 37 | ```bash 38 | go run cmd/api/main.go 39 | ``` 40 | 41 | 4. **Access the API** 42 | The server runs on `http://localhost:8080` by default. You can access API endpoints using cURL, Postman, or a frontend client. 43 | 44 | --- 45 | 46 | ## 📖 Documentation 47 | 48 | Full documentation is available at **[Kaho BaaS Docs](#)** (coming soon). 49 | 50 | --- 51 | 52 | ## 🤝 Contributing 53 | 54 | We welcome contributions! To contribute: 55 | 1. Fork this repository. 56 | 2. Create a new branch (`git checkout -b feature-branch`). 57 | 3. Commit your changes (`git commit -m "Add new feature"`). 58 | 4. Push to the branch (`git push origin feature-branch`). 59 | 5. Open a Pull Request. 60 | 61 | --- 62 | 63 | ## 🛠 Configuration 64 | 65 | Environment variables for configuring Kaho BaaS: 66 | ```env 67 | PORT=8080 68 | APP_ENV=local 69 | BLUEPRINT_DB_HOST=psql_bp 70 | BLUEPRINT_DB_PORT=5432 71 | BLUEPRINT_DB_DATABASE=blueprint 72 | BLUEPRINT_DB_USERNAME=melkey 73 | BLUEPRINT_DB_PASSWORD=password1234 74 | BLUEPRINT_DB_SCHEMA=public 75 | ``` 76 | 77 | --- 78 | 79 | ## 📜 License 80 | 81 | Kaho BaaS is released under the **MIT License**. See [LICENSE](LICENSE) for details. 82 | 83 | --- 84 | 85 | ## ⭐ Support the Project 86 | 87 | If you find Kaho BaaS useful, consider giving us a ⭐ on GitHub! 😊 88 | -------------------------------------------------------------------------------- /internal/apps/account/models/user.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "time" 4 | 5 | type HashOptions struct { 6 | Type string `gorm:"type:varchar(255)" json:"type"` 7 | MemoryCost int `gorm:"type:int" json:"memoryCost"` 8 | TimeCost int `gorm:"type:int" json:"timeCost"` 9 | Threads int `gorm:"type:int" json:"threads"` 10 | } 11 | 12 | type Target struct { 13 | ID string `gorm:"primaryKey;column:$id;type:uuid;default:gen_random_uuid()" json:"$id"` 14 | CreatedAt time.Time `gorm:"column:$createdAt" json:"$createdAt"` 15 | UpdatedAt time.Time `gorm:"column:$updatedAt" json:"$updatedAt"` 16 | Name string `gorm:"type:varchar(255)" json:"name"` 17 | UserID string `gorm:"type:uuid" json:"userId"` 18 | ProviderID string `gorm:"type:varchar(255)" json:"providerId"` 19 | ProviderType string `gorm:"type:varchar(255)" json:"providerType"` 20 | Identifier string `gorm:"type:varchar(255)" json:"identifier"` 21 | Expired bool `gorm:"type:boolean" json:"expired"` 22 | } 23 | 24 | type User struct { 25 | ID string `gorm:"primaryKey;column:$id;type:uuid;default:gen_random_uuid()" json:"$id"` 26 | CreatedAt time.Time `gorm:"column:$createdAt" json:"$createdAt"` 27 | UpdatedAt time.Time `gorm:"column:$updatedAt" json:"$updatedAt"` 28 | DeletedAt time.Time `gorm:"column:$deletedAt" json:"$deletedAt"` 29 | Name string `gorm:"type:varchar(255)" json:"name"` 30 | Password string `gorm:"type:text" json:"password"` 31 | Hash string `gorm:"type:varchar(255)" json:"hash"` 32 | HashOptions HashOptions `gorm:"embedded" json:"hashOptions"` 33 | Registration time.Time `gorm:"type:timestamp" json:"registration"` 34 | Status bool `gorm:"type:boolean" json:"status"` 35 | Labels []string `gorm:"type:text[]" json:"labels"` 36 | PasswordUpdate time.Time `gorm:"type:timestamp" json:"passwordUpdate"` 37 | Email string `gorm:"type:varchar(255)" json:"email"` 38 | Phone string `gorm:"type:varchar(255)" json:"phone"` 39 | EmailVerification bool `gorm:"type:boolean" json:"emailVerification"` 40 | PhoneVerification bool `gorm:"type:boolean" json:"phoneVerification"` 41 | MFA bool `gorm:"type:boolean" json:"mfa"` 42 | Prefs interface{} `gorm:"type:jsonb" json:"prefs"` 43 | Targets []Target `gorm:"foreignKey:UserID" json:"targets"` 44 | AccessedAt time.Time `gorm:"type:timestamp" json:"accessedAt"` 45 | } 46 | 47 | type Login struct { 48 | Email string `json:"email" form:"email" validate:"required,email"` 49 | Password string `json:"password" form:"password" validate:"required,min=8,max=72"` 50 | } 51 | 52 | type Register struct { 53 | Email string `json:"email" form:"email" validate:"required,email"` 54 | Password string `json:"password" form:"password" validate:"required,min=8,max=72"` 55 | Name string `json:"name" form:"name" validate:"required"` 56 | } 57 | -------------------------------------------------------------------------------- /internal/apps/account/services/service.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/models" 5 | "Kaho_BaaS/internal/apps/account/repositories" 6 | "Kaho_BaaS/internal/pkg/constants" 7 | "Kaho_BaaS/internal/pkg/utils" 8 | "context" 9 | "errors" 10 | "fmt" 11 | "log/slog" 12 | 13 | "gorm.io/gorm" 14 | ) 15 | 16 | type AccountService interface { 17 | FindUsers(ctx context.Context) ([]models.User, error) 18 | FindUserByEmail(ctx context.Context, email string) (*models.User, error) 19 | Register(ctx context.Context, data *models.Register) (*models.User, error) 20 | Login(ctx context.Context, data *models.Login) (*models.User, error) 21 | } 22 | 23 | type accountService struct { 24 | repository repositories.AccountRepository 25 | } 26 | 27 | func NewAccountService(repository repositories.AccountRepository) AccountService { 28 | return &accountService{ 29 | repository: repository, 30 | } 31 | } 32 | 33 | // FindUsers implements AccountService. 34 | func (as *accountService) FindUsers(ctx context.Context) ([]models.User, error) { 35 | users, err := as.repository.FindUsers(ctx) 36 | if err != nil { 37 | slog.Error("Retrieve all users", 38 | "err", err, 39 | ) 40 | 41 | return []models.User{}, err 42 | } 43 | 44 | return users, nil 45 | } 46 | 47 | // FindUserByEmail implements AccountService. 48 | func (as *accountService) FindUserByEmail(ctx context.Context, email string) (*models.User, error) { 49 | user, err := as.repository.FindUserByEmail(ctx, email) 50 | if err != nil { 51 | slog.Error("Retrieve user", 52 | "email", email, 53 | "err", err, 54 | ) 55 | return nil, err 56 | } 57 | 58 | return user, nil 59 | } 60 | 61 | // Create implements AccountService. 62 | func (as *accountService) Register(ctx context.Context, data *models.Register) (*models.User, error) { 63 | user, err := as.repository.FindUserByEmail(ctx, data.Email) 64 | if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { 65 | slog.Error("Failed retrieve user", 66 | "email", data.Email, 67 | "err", err, 68 | ) 69 | 70 | return nil, constants.ErrInternalServer 71 | } 72 | 73 | if user != nil { 74 | slog.Error("User already exist", 75 | "email", data.Email) 76 | 77 | return nil, constants.ErrUserAlreadyExist 78 | } 79 | 80 | hashedPassword, err := utils.HashPassword(data.Password) 81 | if err != nil { 82 | slog.Error("Failed hashing password", 83 | "err", err, 84 | ) 85 | 86 | return nil, constants.ErrInternalServer 87 | } 88 | 89 | data.Password = hashedPassword 90 | user, err = as.repository.Create(ctx, data) 91 | if err != nil { 92 | slog.Error("Failed creating user", 93 | "err", err, 94 | ) 95 | 96 | return nil, constants.ErrInternalServer 97 | } 98 | 99 | return user, nil 100 | } 101 | 102 | // Login implements AccountService. 103 | func (as *accountService) Login(ctx context.Context, data *models.Login) (*models.User, error) { 104 | user, err := as.repository.FindUserByEmail(ctx, data.Email) 105 | if err != nil { 106 | slog.Error("Failed retrieve user", 107 | "email", data.Email, 108 | "err", err, 109 | ) 110 | if errors.Is(err, gorm.ErrRecordNotFound) { 111 | return nil, constants.ErrUserNotFound 112 | } 113 | 114 | return nil, constants.ErrInternalServer 115 | } 116 | 117 | isMatch := utils.CheckPasswordHash(data.Password, user.Password) 118 | if !isMatch { 119 | return nil, fmt.Errorf("Invalid credentials") 120 | } 121 | 122 | return user, nil 123 | } 124 | -------------------------------------------------------------------------------- /internal/database/database.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "context" 5 | "database/sql" 6 | "fmt" 7 | "log" 8 | "os" 9 | "strconv" 10 | "time" 11 | 12 | _ "github.com/jackc/pgx/v5/stdlib" 13 | _ "github.com/joho/godotenv/autoload" 14 | ) 15 | 16 | // Service represents a service that interacts with a database. 17 | type Service interface { 18 | // Health returns a map of health status information. 19 | // The keys and values in the map are service-specific. 20 | Health() map[string]string 21 | 22 | // Close terminates the database connection. 23 | // It returns an error if the connection cannot be closed. 24 | Close() error 25 | } 26 | 27 | type service struct { 28 | db *sql.DB 29 | } 30 | 31 | var ( 32 | database = os.Getenv("BLUEPRINT_DB_DATABASE") 33 | password = os.Getenv("BLUEPRINT_DB_PASSWORD") 34 | username = os.Getenv("BLUEPRINT_DB_USERNAME") 35 | port = os.Getenv("BLUEPRINT_DB_PORT") 36 | host = os.Getenv("BLUEPRINT_DB_HOST") 37 | schema = os.Getenv("BLUEPRINT_DB_SCHEMA") 38 | dbInstance *service 39 | ) 40 | 41 | func New() Service { 42 | // Reuse Connection 43 | if dbInstance != nil { 44 | return dbInstance 45 | } 46 | connStr := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable&search_path=%s", username, password, host, port, database, schema) 47 | db, err := sql.Open("pgx", connStr) 48 | if err != nil { 49 | log.Fatal(err) 50 | } 51 | dbInstance = &service{ 52 | db: db, 53 | } 54 | return dbInstance 55 | } 56 | 57 | // Health checks the health of the database connection by pinging the database. 58 | // It returns a map with keys indicating various health statistics. 59 | func (s *service) Health() map[string]string { 60 | ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) 61 | defer cancel() 62 | 63 | stats := make(map[string]string) 64 | 65 | // Ping the database 66 | err := s.db.PingContext(ctx) 67 | if err != nil { 68 | stats["status"] = "down" 69 | stats["error"] = fmt.Sprintf("db down: %v", err) 70 | log.Fatalf("db down: %v", err) // Log the error and terminate the program 71 | return stats 72 | } 73 | 74 | // Database is up, add more statistics 75 | stats["status"] = "up" 76 | stats["message"] = "It's healthy" 77 | 78 | // Get database stats (like open connections, in use, idle, etc.) 79 | dbStats := s.db.Stats() 80 | stats["open_connections"] = strconv.Itoa(dbStats.OpenConnections) 81 | stats["in_use"] = strconv.Itoa(dbStats.InUse) 82 | stats["idle"] = strconv.Itoa(dbStats.Idle) 83 | stats["wait_count"] = strconv.FormatInt(dbStats.WaitCount, 10) 84 | stats["wait_duration"] = dbStats.WaitDuration.String() 85 | stats["max_idle_closed"] = strconv.FormatInt(dbStats.MaxIdleClosed, 10) 86 | stats["max_lifetime_closed"] = strconv.FormatInt(dbStats.MaxLifetimeClosed, 10) 87 | 88 | // Evaluate stats to provide a health message 89 | if dbStats.OpenConnections > 40 { // Assuming 50 is the max for this example 90 | stats["message"] = "The database is experiencing heavy load." 91 | } 92 | 93 | if dbStats.WaitCount > 1000 { 94 | stats["message"] = "The database has a high number of wait events, indicating potential bottlenecks." 95 | } 96 | 97 | if dbStats.MaxIdleClosed > int64(dbStats.OpenConnections)/2 { 98 | stats["message"] = "Many idle connections are being closed, consider revising the connection pool settings." 99 | } 100 | 101 | if dbStats.MaxLifetimeClosed > int64(dbStats.OpenConnections)/2 { 102 | stats["message"] = "Many connections are being closed due to max lifetime, consider increasing max lifetime or revising the connection usage pattern." 103 | } 104 | 105 | return stats 106 | } 107 | 108 | // Close closes the database connection. 109 | // It logs a message indicating the disconnection from the specific database. 110 | // If the connection is successfully closed, it returns nil. 111 | // If an error occurs while closing the connection, it returns the error. 112 | func (s *service) Close() error { 113 | log.Printf("Disconnected from database: %s", database) 114 | return s.db.Close() 115 | } 116 | -------------------------------------------------------------------------------- /internal/apps/account/services/service_test.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "Kaho_BaaS/internal/apps/account/models" 5 | "Kaho_BaaS/internal/apps/account/repositories" 6 | "Kaho_BaaS/internal/pkg/constants" 7 | "Kaho_BaaS/internal/pkg/utils" 8 | "context" 9 | "errors" 10 | "testing" 11 | 12 | "github.com/stretchr/testify/assert" 13 | "github.com/stretchr/testify/mock" 14 | "gorm.io/gorm" 15 | ) 16 | 17 | var repository = &repositories.AccountRepositoryMock{Mock: mock.Mock{}} 18 | var service = accountService{repository: repository} 19 | 20 | func TestFindUserByEmail_NotFound(t *testing.T) { 21 | email := "test123@demo.com" 22 | repository.Mock.On("FindUserByEmail", email).Return(nil) 23 | 24 | user, err := service.FindUserByEmail(context.TODO(), email) 25 | 26 | assert.NotNil(t, err) 27 | assert.EqualValues(t, gorm.ErrRecordNotFound, err) 28 | assert.Nil(t, user) 29 | } 30 | 31 | func TestFindUserByEmail_Found(t *testing.T) { 32 | email := "john123@demo.com" 33 | repository.Mock.On("FindUserByEmail", email).Return(models.User{ 34 | Email: email, 35 | }) 36 | 37 | user, err := service.FindUserByEmail(context.TODO(), email) 38 | 39 | assert.Nil(t, err) 40 | assert.NotNil(t, user) 41 | assert.Equal(t, email, user.Email) 42 | } 43 | 44 | func TestLogin_NotFound(t *testing.T) { 45 | data := models.Login{ 46 | Email: "abc123@demo.com", 47 | Password: "john123!@#", 48 | } 49 | 50 | repository.Mock.On("FindUserByEmail", data.Email).Return(nil) 51 | 52 | user, err := service.Login(context.TODO(), &data) 53 | 54 | assert.NotNil(t, err) 55 | assert.EqualValues(t, constants.ErrUserNotFound, err) 56 | assert.Nil(t, user) 57 | } 58 | 59 | func TestLogin_InvalidCred(t *testing.T) { 60 | data := models.Login{ 61 | Email: "john123@demo.com", 62 | Password: "john123!@#", 63 | } 64 | 65 | repository.Mock.On("FindUserByEmail", data.Email).Return(models.User{ 66 | Email: data.Email, 67 | }) 68 | 69 | user, err := service.Login(context.TODO(), &data) 70 | 71 | assert.NotNil(t, err) 72 | assert.EqualValues(t, errors.New("Invalid credentials"), err) 73 | assert.Nil(t, user) 74 | 75 | } 76 | 77 | func TestLogin_Success(t *testing.T) { 78 | data := models.Login{ 79 | Email: "johndoes123@demo.com", 80 | Password: "john123!@#", 81 | } 82 | 83 | hashedPassword, _ := utils.HashPassword(data.Password) 84 | repository.Mock.On("FindUserByEmail", data.Email).Return(models.User{ 85 | Email: data.Email, 86 | Password: hashedPassword, 87 | }) 88 | 89 | user, err := service.Login(context.TODO(), &data) 90 | 91 | assert.Nil(t, err) 92 | assert.NotNil(t, user) 93 | assert.EqualValues(t, data.Email, user.Email) 94 | } 95 | 96 | func TestRegister_UserAlreadyExist(t *testing.T) { 97 | data := models.Register{ 98 | Email: "john123@demo.com", 99 | Password: "john123!@#", 100 | } 101 | 102 | repository.Mock.On("FindUserByEmail", data.Email).Return(models.User{ 103 | Email: data.Email, 104 | }) 105 | repository.Mock.On("Create", data).Return(nil) 106 | 107 | user, err := service.Register(context.TODO(), &data) 108 | 109 | assert.NotNil(t, err) 110 | assert.EqualValues(t, constants.ErrUserAlreadyExist, err) 111 | assert.Nil(t, user) 112 | } 113 | 114 | func TestRegister_PasswordTooLong(t *testing.T) { 115 | data := models.Register{ 116 | Email: "johndoe123@demo.com", 117 | Password: "1234567812345678123456781234567812345678123456781234567812345678123456789", // exceed 72 char 118 | } 119 | 120 | repository.Mock.On("FindUserByEmail", data.Email).Return(nil) 121 | repository.Mock.On("Create", data).Return(nil) 122 | 123 | user, err := service.Register(context.TODO(), &data) 124 | 125 | assert.NotNil(t, err) 126 | assert.EqualValues(t, constants.ErrInternalServer, err) 127 | assert.Nil(t, user) 128 | } 129 | 130 | func TestRegister_Success(t *testing.T) { 131 | data := models.Register{ 132 | Email: "johndoe123@demo.com", 133 | Password: "johndoes123!@#", 134 | } 135 | 136 | repository.Mock.On("FindUserByEmail", data.Email).Return(nil) 137 | repository.Mock.On("Create", data).Return(models.User{ 138 | Email: data.Email, 139 | }) 140 | 141 | user, err := service.Register(context.TODO(), &data) 142 | 143 | assert.Nil(t, err) 144 | assert.NotNil(t, user) 145 | assert.EqualValues(t, data.Email, user.Email) 146 | } 147 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module Kaho_BaaS 2 | 3 | go 1.23.4 4 | 5 | require ( 6 | github.com/gofiber/fiber/v2 v2.52.6 7 | github.com/gofiber/swagger v1.1.1 8 | github.com/jackc/pgx/v5 v5.7.2 9 | github.com/joho/godotenv v1.5.1 10 | github.com/stretchr/testify v1.9.0 11 | github.com/swaggo/swag v1.16.4 12 | github.com/testcontainers/testcontainers-go v0.35.0 13 | github.com/testcontainers/testcontainers-go/modules/postgres v0.35.0 14 | golang.org/x/crypto v0.32.0 15 | gorm.io/driver/postgres v1.5.11 16 | gorm.io/gorm v1.25.12 17 | ) 18 | 19 | require ( 20 | dario.cat/mergo v1.0.0 // indirect 21 | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect 22 | github.com/KyleBanks/depth v1.2.1 // indirect 23 | github.com/Microsoft/go-winio v0.6.2 // indirect 24 | github.com/PuerkitoBio/purell v1.1.1 // indirect 25 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 26 | github.com/andybalholm/brotli v1.1.1 // indirect 27 | github.com/cenkalti/backoff/v4 v4.2.1 // indirect 28 | github.com/containerd/containerd v1.7.18 // indirect 29 | github.com/containerd/log v0.1.0 // indirect 30 | github.com/containerd/platforms v0.2.1 // indirect 31 | github.com/cpuguy83/dockercfg v0.3.2 // indirect 32 | github.com/davecgh/go-spew v1.1.1 // indirect 33 | github.com/distribution/reference v0.6.0 // indirect 34 | github.com/docker/docker v27.1.1+incompatible // indirect 35 | github.com/docker/go-connections v0.5.0 // indirect 36 | github.com/docker/go-units v0.5.0 // indirect 37 | github.com/felixge/httpsnoop v1.0.4 // indirect 38 | github.com/gabriel-vasile/mimetype v1.4.8 // indirect 39 | github.com/go-logr/logr v1.4.1 // indirect 40 | github.com/go-logr/stdr v1.2.2 // indirect 41 | github.com/go-ole/go-ole v1.2.6 // indirect 42 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 43 | github.com/go-openapi/jsonreference v0.19.6 // indirect 44 | github.com/go-openapi/spec v0.20.4 // indirect 45 | github.com/go-openapi/swag v0.19.15 // indirect 46 | github.com/go-playground/locales v0.14.1 // indirect 47 | github.com/go-playground/universal-translator v0.18.1 // indirect 48 | github.com/go-playground/validator/v10 v10.25.0 // indirect 49 | github.com/gogo/protobuf v1.3.2 // indirect 50 | github.com/google/uuid v1.6.0 // indirect 51 | github.com/jackc/pgpassfile v1.0.0 // indirect 52 | github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect 53 | github.com/jackc/puddle/v2 v2.2.2 // indirect 54 | github.com/jinzhu/inflection v1.0.0 // indirect 55 | github.com/jinzhu/now v1.1.5 // indirect 56 | github.com/josharian/intern v1.0.0 // indirect 57 | github.com/klauspost/compress v1.17.11 // indirect 58 | github.com/leodido/go-urn v1.4.0 // indirect 59 | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect 60 | github.com/magiconair/properties v1.8.7 // indirect 61 | github.com/mailru/easyjson v0.7.6 // indirect 62 | github.com/mattn/go-colorable v0.1.14 // indirect 63 | github.com/mattn/go-isatty v0.0.20 // indirect 64 | github.com/mattn/go-runewidth v0.0.16 // indirect 65 | github.com/moby/docker-image-spec v1.3.1 // indirect 66 | github.com/moby/patternmatcher v0.6.0 // indirect 67 | github.com/moby/sys/sequential v0.5.0 // indirect 68 | github.com/moby/sys/user v0.1.0 // indirect 69 | github.com/moby/term v0.5.0 // indirect 70 | github.com/morikuni/aec v1.0.0 // indirect 71 | github.com/opencontainers/go-digest v1.0.0 // indirect 72 | github.com/opencontainers/image-spec v1.1.0 // indirect 73 | github.com/pkg/errors v0.9.1 // indirect 74 | github.com/pmezard/go-difflib v1.0.0 // indirect 75 | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect 76 | github.com/rivo/uniseg v0.4.7 // indirect 77 | github.com/shirou/gopsutil/v3 v3.23.12 // indirect 78 | github.com/shoenig/go-m1cpu v0.1.6 // indirect 79 | github.com/sirupsen/logrus v1.9.3 // indirect 80 | github.com/stretchr/objx v0.5.2 // indirect 81 | github.com/swaggo/files/v2 v2.0.2 // indirect 82 | github.com/tklauser/go-sysconf v0.3.12 // indirect 83 | github.com/tklauser/numcpus v0.6.1 // indirect 84 | github.com/valyala/bytebufferpool v1.0.0 // indirect 85 | github.com/valyala/fasthttp v1.58.0 // indirect 86 | github.com/valyala/tcplisten v1.0.0 // indirect 87 | github.com/yusufpapurcu/wmi v1.2.3 // indirect 88 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect 89 | go.opentelemetry.io/otel v1.24.0 // indirect 90 | go.opentelemetry.io/otel/metric v1.24.0 // indirect 91 | go.opentelemetry.io/otel/trace v1.24.0 // indirect 92 | golang.org/x/net v0.34.0 // indirect 93 | golang.org/x/sync v0.10.0 // indirect 94 | golang.org/x/sys v0.30.0 // indirect 95 | golang.org/x/text v0.21.0 // indirect 96 | golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect 97 | gopkg.in/yaml.v2 v2.4.0 // indirect 98 | gopkg.in/yaml.v3 v3.0.1 // indirect 99 | ) 100 | -------------------------------------------------------------------------------- /docs/swagger.yaml: -------------------------------------------------------------------------------- 1 | basePath: /v1 2 | definitions: 3 | models.Session: 4 | properties: 5 | $createdAt: 6 | type: string 7 | $id: 8 | type: string 9 | $updatedAt: 10 | type: string 11 | clientCode: 12 | type: string 13 | clientEngine: 14 | type: string 15 | clientEngineVersion: 16 | type: string 17 | clientName: 18 | type: string 19 | clientType: 20 | type: string 21 | clientVersion: 22 | type: string 23 | countryCode: 24 | type: string 25 | countryName: 26 | type: string 27 | current: 28 | type: boolean 29 | deviceBrand: 30 | type: string 31 | deviceModel: 32 | type: string 33 | deviceName: 34 | type: string 35 | expire: 36 | type: string 37 | factors: 38 | items: 39 | type: string 40 | type: array 41 | ip: 42 | type: string 43 | mfaUpdatedAt: 44 | type: string 45 | osCode: 46 | type: string 47 | osName: 48 | type: string 49 | osVersion: 50 | type: string 51 | provider: 52 | type: string 53 | providerAccessToken: 54 | type: string 55 | providerAccessTokenExpiry: 56 | type: string 57 | providerRefreshToken: 58 | type: string 59 | providerUid: 60 | type: string 61 | secret: 62 | type: string 63 | userId: 64 | type: string 65 | type: object 66 | info: 67 | contact: {} 68 | description: API documentation for Kaho BaaS 69 | title: Kaho BaaS API Documentation 70 | version: "1.0" 71 | paths: 72 | /account/sessions/login: 73 | post: 74 | consumes: 75 | - application/x-www-form-urlencoded 76 | description: Authenticate user credentials and start a user session. 77 | parameters: 78 | - description: Project ID 79 | in: header 80 | name: X-Kaho-Project 81 | required: true 82 | type: string 83 | - description: User Email 84 | in: formData 85 | name: email 86 | required: true 87 | type: string 88 | - description: User Password 89 | in: formData 90 | name: password 91 | required: true 92 | type: string 93 | produces: 94 | - application/json 95 | responses: 96 | "200": 97 | description: Login success response 98 | schema: 99 | type: string 100 | "400": 101 | description: X-Kaho-Project is required 102 | schema: 103 | additionalProperties: 104 | type: string 105 | type: object 106 | "401": 107 | description: Invalid credentials 108 | schema: 109 | additionalProperties: 110 | type: string 111 | type: object 112 | "500": 113 | description: Server error 114 | schema: 115 | additionalProperties: true 116 | type: object 117 | summary: Login user for a project 118 | tags: 119 | - account 120 | /account/sessions/register: 121 | post: 122 | consumes: 123 | - application/x-www-form-urlencoded 124 | description: Authenticate user credentials and start a user session. 125 | parameters: 126 | - description: Project ID 127 | in: header 128 | name: X-Kaho-Project 129 | required: true 130 | type: string 131 | - description: User Email 132 | in: formData 133 | name: email 134 | required: true 135 | type: string 136 | - description: User Password 137 | in: formData 138 | name: password 139 | required: true 140 | type: string 141 | - description: User Name 142 | in: formData 143 | name: name 144 | required: true 145 | type: string 146 | produces: 147 | - application/json 148 | responses: 149 | "200": 150 | description: Login success response 151 | schema: 152 | type: string 153 | "201": 154 | description: Login success response 155 | schema: 156 | $ref: '#/definitions/models.Session' 157 | "400": 158 | description: X-Kaho-Project is required 159 | schema: 160 | additionalProperties: 161 | type: string 162 | type: object 163 | "401": 164 | description: Invalid credentials 165 | schema: 166 | additionalProperties: 167 | type: string 168 | type: object 169 | "500": 170 | description: Server error 171 | schema: 172 | additionalProperties: true 173 | type: object 174 | summary: Register user for a project 175 | tags: 176 | - account 177 | swagger: "2.0" 178 | -------------------------------------------------------------------------------- /docs/swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "description": "API documentation for Kaho BaaS", 5 | "title": "Kaho BaaS API Documentation", 6 | "contact": {}, 7 | "version": "1.0" 8 | }, 9 | "basePath": "/v1", 10 | "paths": { 11 | "/account/sessions/login": { 12 | "post": { 13 | "description": "Authenticate user credentials and start a user session.", 14 | "consumes": [ 15 | "application/x-www-form-urlencoded" 16 | ], 17 | "produces": [ 18 | "application/json" 19 | ], 20 | "tags": [ 21 | "account" 22 | ], 23 | "summary": "Login user for a project", 24 | "parameters": [ 25 | { 26 | "type": "string", 27 | "description": "Project ID", 28 | "name": "X-Kaho-Project", 29 | "in": "header", 30 | "required": true 31 | }, 32 | { 33 | "type": "string", 34 | "description": "User Email", 35 | "name": "email", 36 | "in": "formData", 37 | "required": true 38 | }, 39 | { 40 | "type": "string", 41 | "description": "User Password", 42 | "name": "password", 43 | "in": "formData", 44 | "required": true 45 | } 46 | ], 47 | "responses": { 48 | "200": { 49 | "description": "Login success response", 50 | "schema": { 51 | "type": "string" 52 | } 53 | }, 54 | "400": { 55 | "description": "X-Kaho-Project is required", 56 | "schema": { 57 | "type": "object", 58 | "additionalProperties": { 59 | "type": "string" 60 | } 61 | } 62 | }, 63 | "401": { 64 | "description": "Invalid credentials", 65 | "schema": { 66 | "type": "object", 67 | "additionalProperties": { 68 | "type": "string" 69 | } 70 | } 71 | }, 72 | "500": { 73 | "description": "Server error", 74 | "schema": { 75 | "type": "object", 76 | "additionalProperties": true 77 | } 78 | } 79 | } 80 | } 81 | }, 82 | "/account/sessions/register": { 83 | "post": { 84 | "description": "Authenticate user credentials and start a user session.", 85 | "consumes": [ 86 | "application/x-www-form-urlencoded" 87 | ], 88 | "produces": [ 89 | "application/json" 90 | ], 91 | "tags": [ 92 | "account" 93 | ], 94 | "summary": "Register user for a project", 95 | "parameters": [ 96 | { 97 | "type": "string", 98 | "description": "Project ID", 99 | "name": "X-Kaho-Project", 100 | "in": "header", 101 | "required": true 102 | }, 103 | { 104 | "type": "string", 105 | "description": "User Email", 106 | "name": "email", 107 | "in": "formData", 108 | "required": true 109 | }, 110 | { 111 | "type": "string", 112 | "description": "User Password", 113 | "name": "password", 114 | "in": "formData", 115 | "required": true 116 | }, 117 | { 118 | "type": "string", 119 | "description": "User Name", 120 | "name": "name", 121 | "in": "formData", 122 | "required": true 123 | } 124 | ], 125 | "responses": { 126 | "200": { 127 | "description": "Login success response", 128 | "schema": { 129 | "type": "string" 130 | } 131 | }, 132 | "201": { 133 | "description": "Login success response", 134 | "schema": { 135 | "$ref": "#/definitions/models.Session" 136 | } 137 | }, 138 | "400": { 139 | "description": "X-Kaho-Project is required", 140 | "schema": { 141 | "type": "object", 142 | "additionalProperties": { 143 | "type": "string" 144 | } 145 | } 146 | }, 147 | "401": { 148 | "description": "Invalid credentials", 149 | "schema": { 150 | "type": "object", 151 | "additionalProperties": { 152 | "type": "string" 153 | } 154 | } 155 | }, 156 | "500": { 157 | "description": "Server error", 158 | "schema": { 159 | "type": "object", 160 | "additionalProperties": true 161 | } 162 | } 163 | } 164 | } 165 | } 166 | }, 167 | "definitions": { 168 | "models.Session": { 169 | "type": "object", 170 | "properties": { 171 | "$createdAt": { 172 | "type": "string" 173 | }, 174 | "$id": { 175 | "type": "string" 176 | }, 177 | "$updatedAt": { 178 | "type": "string" 179 | }, 180 | "clientCode": { 181 | "type": "string" 182 | }, 183 | "clientEngine": { 184 | "type": "string" 185 | }, 186 | "clientEngineVersion": { 187 | "type": "string" 188 | }, 189 | "clientName": { 190 | "type": "string" 191 | }, 192 | "clientType": { 193 | "type": "string" 194 | }, 195 | "clientVersion": { 196 | "type": "string" 197 | }, 198 | "countryCode": { 199 | "type": "string" 200 | }, 201 | "countryName": { 202 | "type": "string" 203 | }, 204 | "current": { 205 | "type": "boolean" 206 | }, 207 | "deviceBrand": { 208 | "type": "string" 209 | }, 210 | "deviceModel": { 211 | "type": "string" 212 | }, 213 | "deviceName": { 214 | "type": "string" 215 | }, 216 | "expire": { 217 | "type": "string" 218 | }, 219 | "factors": { 220 | "type": "array", 221 | "items": { 222 | "type": "string" 223 | } 224 | }, 225 | "ip": { 226 | "type": "string" 227 | }, 228 | "mfaUpdatedAt": { 229 | "type": "string" 230 | }, 231 | "osCode": { 232 | "type": "string" 233 | }, 234 | "osName": { 235 | "type": "string" 236 | }, 237 | "osVersion": { 238 | "type": "string" 239 | }, 240 | "provider": { 241 | "type": "string" 242 | }, 243 | "providerAccessToken": { 244 | "type": "string" 245 | }, 246 | "providerAccessTokenExpiry": { 247 | "type": "string" 248 | }, 249 | "providerRefreshToken": { 250 | "type": "string" 251 | }, 252 | "providerUid": { 253 | "type": "string" 254 | }, 255 | "secret": { 256 | "type": "string" 257 | }, 258 | "userId": { 259 | "type": "string" 260 | } 261 | } 262 | } 263 | } 264 | } -------------------------------------------------------------------------------- /docs/docs.go: -------------------------------------------------------------------------------- 1 | // Package docs Code generated by swaggo/swag. DO NOT EDIT 2 | package docs 3 | 4 | import "github.com/swaggo/swag" 5 | 6 | const docTemplate = `{ 7 | "schemes": {{ marshal .Schemes }}, 8 | "swagger": "2.0", 9 | "info": { 10 | "description": "{{escape .Description}}", 11 | "title": "{{.Title}}", 12 | "contact": {}, 13 | "version": "{{.Version}}" 14 | }, 15 | "host": "{{.Host}}", 16 | "basePath": "{{.BasePath}}", 17 | "paths": { 18 | "/account/sessions/login": { 19 | "post": { 20 | "description": "Authenticate user credentials and start a user session.", 21 | "consumes": [ 22 | "application/x-www-form-urlencoded" 23 | ], 24 | "produces": [ 25 | "application/json" 26 | ], 27 | "tags": [ 28 | "account" 29 | ], 30 | "summary": "Login user for a project", 31 | "parameters": [ 32 | { 33 | "type": "string", 34 | "description": "Project ID", 35 | "name": "X-Kaho-Project", 36 | "in": "header", 37 | "required": true 38 | }, 39 | { 40 | "type": "string", 41 | "description": "User Email", 42 | "name": "email", 43 | "in": "formData", 44 | "required": true 45 | }, 46 | { 47 | "type": "string", 48 | "description": "User Password", 49 | "name": "password", 50 | "in": "formData", 51 | "required": true 52 | } 53 | ], 54 | "responses": { 55 | "200": { 56 | "description": "Login success response", 57 | "schema": { 58 | "type": "string" 59 | } 60 | }, 61 | "400": { 62 | "description": "X-Kaho-Project is required", 63 | "schema": { 64 | "type": "object", 65 | "additionalProperties": { 66 | "type": "string" 67 | } 68 | } 69 | }, 70 | "401": { 71 | "description": "Invalid credentials", 72 | "schema": { 73 | "type": "object", 74 | "additionalProperties": { 75 | "type": "string" 76 | } 77 | } 78 | }, 79 | "500": { 80 | "description": "Server error", 81 | "schema": { 82 | "type": "object", 83 | "additionalProperties": true 84 | } 85 | } 86 | } 87 | } 88 | }, 89 | "/account/sessions/register": { 90 | "post": { 91 | "description": "Authenticate user credentials and start a user session.", 92 | "consumes": [ 93 | "application/x-www-form-urlencoded" 94 | ], 95 | "produces": [ 96 | "application/json" 97 | ], 98 | "tags": [ 99 | "account" 100 | ], 101 | "summary": "Register user for a project", 102 | "parameters": [ 103 | { 104 | "type": "string", 105 | "description": "Project ID", 106 | "name": "X-Kaho-Project", 107 | "in": "header", 108 | "required": true 109 | }, 110 | { 111 | "type": "string", 112 | "description": "User Email", 113 | "name": "email", 114 | "in": "formData", 115 | "required": true 116 | }, 117 | { 118 | "type": "string", 119 | "description": "User Password", 120 | "name": "password", 121 | "in": "formData", 122 | "required": true 123 | }, 124 | { 125 | "type": "string", 126 | "description": "User Name", 127 | "name": "name", 128 | "in": "formData", 129 | "required": true 130 | } 131 | ], 132 | "responses": { 133 | "200": { 134 | "description": "Login success response", 135 | "schema": { 136 | "type": "string" 137 | } 138 | }, 139 | "201": { 140 | "description": "Login success response", 141 | "schema": { 142 | "$ref": "#/definitions/models.Session" 143 | } 144 | }, 145 | "400": { 146 | "description": "X-Kaho-Project is required", 147 | "schema": { 148 | "type": "object", 149 | "additionalProperties": { 150 | "type": "string" 151 | } 152 | } 153 | }, 154 | "401": { 155 | "description": "Invalid credentials", 156 | "schema": { 157 | "type": "object", 158 | "additionalProperties": { 159 | "type": "string" 160 | } 161 | } 162 | }, 163 | "500": { 164 | "description": "Server error", 165 | "schema": { 166 | "type": "object", 167 | "additionalProperties": true 168 | } 169 | } 170 | } 171 | } 172 | } 173 | }, 174 | "definitions": { 175 | "models.Session": { 176 | "type": "object", 177 | "properties": { 178 | "$createdAt": { 179 | "type": "string" 180 | }, 181 | "$id": { 182 | "type": "string" 183 | }, 184 | "$updatedAt": { 185 | "type": "string" 186 | }, 187 | "clientCode": { 188 | "type": "string" 189 | }, 190 | "clientEngine": { 191 | "type": "string" 192 | }, 193 | "clientEngineVersion": { 194 | "type": "string" 195 | }, 196 | "clientName": { 197 | "type": "string" 198 | }, 199 | "clientType": { 200 | "type": "string" 201 | }, 202 | "clientVersion": { 203 | "type": "string" 204 | }, 205 | "countryCode": { 206 | "type": "string" 207 | }, 208 | "countryName": { 209 | "type": "string" 210 | }, 211 | "current": { 212 | "type": "boolean" 213 | }, 214 | "deviceBrand": { 215 | "type": "string" 216 | }, 217 | "deviceModel": { 218 | "type": "string" 219 | }, 220 | "deviceName": { 221 | "type": "string" 222 | }, 223 | "expire": { 224 | "type": "string" 225 | }, 226 | "factors": { 227 | "type": "array", 228 | "items": { 229 | "type": "string" 230 | } 231 | }, 232 | "ip": { 233 | "type": "string" 234 | }, 235 | "mfaUpdatedAt": { 236 | "type": "string" 237 | }, 238 | "osCode": { 239 | "type": "string" 240 | }, 241 | "osName": { 242 | "type": "string" 243 | }, 244 | "osVersion": { 245 | "type": "string" 246 | }, 247 | "provider": { 248 | "type": "string" 249 | }, 250 | "providerAccessToken": { 251 | "type": "string" 252 | }, 253 | "providerAccessTokenExpiry": { 254 | "type": "string" 255 | }, 256 | "providerRefreshToken": { 257 | "type": "string" 258 | }, 259 | "providerUid": { 260 | "type": "string" 261 | }, 262 | "secret": { 263 | "type": "string" 264 | }, 265 | "userId": { 266 | "type": "string" 267 | } 268 | } 269 | } 270 | } 271 | }` 272 | 273 | // SwaggerInfo holds exported Swagger Info so clients can modify it 274 | var SwaggerInfo = &swag.Spec{ 275 | Version: "1.0", 276 | Host: "", 277 | BasePath: "/v1", 278 | Schemes: []string{}, 279 | Title: "Kaho BaaS API Documentation", 280 | Description: "API documentation for Kaho BaaS", 281 | InfoInstanceName: "swagger", 282 | SwaggerTemplate: docTemplate, 283 | LeftDelim: "{{", 284 | RightDelim: "}}", 285 | } 286 | 287 | func init() { 288 | swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) 289 | } 290 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= 2 | dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= 3 | github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= 4 | github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= 5 | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= 6 | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= 7 | github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= 8 | github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= 9 | github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= 10 | github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= 11 | github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= 12 | github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= 14 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= 15 | github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= 16 | github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= 17 | github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= 18 | github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= 19 | github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao= 20 | github.com/containerd/containerd v1.7.18/go.mod h1:IYEk9/IO6wAPUz2bCMVUbsfXjzw5UNP5fLz4PsUygQ4= 21 | github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= 22 | github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= 23 | github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= 24 | github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= 25 | github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA= 26 | github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= 27 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 28 | github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= 29 | github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= 30 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 31 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 32 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 33 | github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= 34 | github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= 35 | github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY= 36 | github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= 37 | github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= 38 | github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= 39 | github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= 40 | github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= 41 | github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= 42 | github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= 43 | github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= 44 | github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= 45 | github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 46 | github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= 47 | github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= 48 | github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= 49 | github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= 50 | github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= 51 | github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= 52 | github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= 53 | github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= 54 | github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= 55 | github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= 56 | github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= 57 | github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= 58 | github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= 59 | github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= 60 | github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= 61 | github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= 62 | github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= 63 | github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= 64 | github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= 65 | github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= 66 | github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8= 67 | github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus= 68 | github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= 69 | github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= 70 | github.com/gofiber/swagger v1.1.1 h1:FZVhVQQ9s1ZKLHL/O0loLh49bYB5l1HEAgxDlcTtkRA= 71 | github.com/gofiber/swagger v1.1.1/go.mod h1:vtvY/sQAMc/lGTUCg0lqmBL7Ht9O7uzChpbvJeJQINw= 72 | github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= 73 | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= 74 | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 75 | github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 76 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 77 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 78 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= 79 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 80 | github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= 81 | github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= 82 | github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= 83 | github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= 84 | github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= 85 | github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= 86 | github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI= 87 | github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ= 88 | github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= 89 | github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= 90 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 91 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 92 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= 93 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 94 | github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 95 | github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 96 | github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= 97 | github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= 98 | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 99 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 100 | github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= 101 | github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= 102 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 103 | github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= 104 | github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= 105 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 106 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 107 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 108 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 109 | github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= 110 | github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= 111 | github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= 112 | github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= 113 | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= 114 | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= 115 | github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= 116 | github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= 117 | github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 118 | github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 119 | github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= 120 | github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= 121 | github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= 122 | github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= 123 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 124 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 125 | github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= 126 | github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 127 | github.com/mdelapenya/tlscert v0.1.0 h1:YTpF579PYUX475eOL+6zyEO3ngLTOUWck78NBuJVXaM= 128 | github.com/mdelapenya/tlscert v0.1.0/go.mod h1:wrbyM/DwbFCeCeqdPX/8c6hNOqQgbf0rUDErE1uD+64= 129 | github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= 130 | github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= 131 | github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= 132 | github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= 133 | github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= 134 | github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= 135 | github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= 136 | github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= 137 | github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= 138 | github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= 139 | github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= 140 | github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= 141 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= 142 | github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= 143 | github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= 144 | github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= 145 | github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= 146 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 147 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 148 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 149 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 150 | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= 151 | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= 152 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 153 | github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= 154 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 155 | github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= 156 | github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= 157 | github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= 158 | github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= 159 | github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= 160 | github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= 161 | github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= 162 | github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= 163 | github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= 164 | github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= 165 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 166 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 167 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 168 | github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= 169 | github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= 170 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 171 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 172 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 173 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 174 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 175 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 176 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= 177 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 178 | github.com/swaggo/files/v2 v2.0.2 h1:Bq4tgS/yxLB/3nwOMcul5oLEUKa877Ykgz3CJMVbQKU= 179 | github.com/swaggo/files/v2 v2.0.2/go.mod h1:TVqetIzZsO9OhHX1Am9sRf9LdrFZqoK49N37KON/jr0= 180 | github.com/swaggo/swag v1.16.4 h1:clWJtd9LStiG3VeijiCfOVODP6VpHtKdQy9ELFG3s1A= 181 | github.com/swaggo/swag v1.16.4/go.mod h1:VBsHJRsDvfYvqoiMKnsdwhNV9LEMHgEDZcyVYX0sxPg= 182 | github.com/testcontainers/testcontainers-go v0.35.0 h1:uADsZpTKFAtp8SLK+hMwSaa+X+JiERHtd4sQAFmXeMo= 183 | github.com/testcontainers/testcontainers-go v0.35.0/go.mod h1:oEVBj5zrfJTrgjwONs1SsRbnBtH9OKl+IGl3UMcr2B4= 184 | github.com/testcontainers/testcontainers-go/modules/postgres v0.35.0 h1:eEGx9kYzZb2cNhRbBrNOCL/YPOM7+RMJiy3bB+ie0/I= 185 | github.com/testcontainers/testcontainers-go/modules/postgres v0.35.0/go.mod h1:hfH71Mia/WWLBgMD2YctYcMlfsbnT0hflweL1dy8Q4s= 186 | github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= 187 | github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= 188 | github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= 189 | github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= 190 | github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= 191 | github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= 192 | github.com/valyala/fasthttp v1.58.0 h1:GGB2dWxSbEprU9j0iMJHgdKYJVDyjrOwF9RE59PbRuE= 193 | github.com/valyala/fasthttp v1.58.0/go.mod h1:SYXvHHaFp7QZHGKSHmoMipInhrI5StHrhDTYVEjK/Kw= 194 | github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= 195 | github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= 196 | github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= 197 | github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= 198 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 199 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 200 | github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= 201 | github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= 202 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= 203 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= 204 | go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= 205 | go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= 206 | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= 207 | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= 208 | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= 209 | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= 210 | go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= 211 | go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= 212 | go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= 213 | go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= 214 | go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= 215 | go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= 216 | go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= 217 | go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= 218 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 219 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 220 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 221 | golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= 222 | golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= 223 | golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= 224 | golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= 225 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 226 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 227 | golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= 228 | golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 229 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 230 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 231 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 232 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 233 | golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= 234 | golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= 235 | golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= 236 | golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= 237 | golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= 238 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 239 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 240 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 241 | golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= 242 | golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 243 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 244 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 245 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 246 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 247 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 248 | golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 249 | golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 250 | golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 251 | golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 252 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 253 | golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 254 | golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 255 | golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 256 | golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= 257 | golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 258 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 259 | golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= 260 | golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= 261 | golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= 262 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 263 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 264 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 265 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 266 | golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 267 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 268 | golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= 269 | golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 270 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 271 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 272 | golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 273 | golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 274 | golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= 275 | golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= 276 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 277 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 278 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 279 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 280 | google.golang.org/genproto v0.0.0-20230920204549-e6e6cdab5c13 h1:vlzZttNJGVqTsRFU9AmdnrcO1Znh8Ew9kCD//yjigk0= 281 | google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= 282 | google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= 283 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= 284 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= 285 | google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= 286 | google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= 287 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 288 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 289 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 290 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 291 | gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 292 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 293 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 294 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 295 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 296 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 297 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 298 | gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 299 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 300 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 301 | gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314= 302 | gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI= 303 | gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= 304 | gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= 305 | gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= 306 | gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= 307 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------