feat: implement license platform business flows and delivery tooling
Some checks failed
Check / delivery-static (push) Has been cancelled
Check / api (push) Has been cancelled
Check / web (push) Has been cancelled

Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
2026-10-09 15:33:22 +08:00
parent 3ab651d3a8
commit 54c318c615
142 changed files with 11105 additions and 178 deletions

View File

@@ -0,0 +1,47 @@
package httpapi
import (
"context"
"database/sql"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
const RequiredSchemaVersion = 10
func RegisterReadiness(r *gin.Engine, db *sql.DB) {
r.GET("/api/v1/health/ready", func(c *gin.Context) {
ctx, cancel := context.WithTimeout(c.Request.Context(), 2*time.Second)
defer cancel()
if err := CheckSchema(ctx, db); err != nil {
c.JSON(http.StatusServiceUnavailable, gin.H{"status": "not_ready"})
return
}
c.JSON(http.StatusOK, gin.H{"status": "ready"})
})
}
func CheckSchema(ctx context.Context, db *sql.DB) error {
if db == nil {
return sql.ErrConnDone
}
var version uint64
var dirty bool
rows, err := db.QueryContext(ctx, "SELECT version, dirty FROM schema_migrations")
if err != nil {
return err
}
defer rows.Close()
if !rows.Next() {
return sql.ErrNoRows
}
if err := rows.Scan(&version, &dirty); err != nil {
return err
}
if rows.Next() || rows.Err() != nil || version != RequiredSchemaVersion || dirty {
return sql.ErrNoRows
}
return nil
}