add server api get and update service control endpoints
This commit is contained in:
@@ -24,6 +24,7 @@ type RouteGroups struct {
|
||||
Lookup fiber.Router
|
||||
StateHistory fiber.Router
|
||||
Membership fiber.Router
|
||||
System fiber.Router
|
||||
}
|
||||
|
||||
func CheckError(err error) {
|
||||
|
||||
@@ -13,14 +13,16 @@ var (
|
||||
Secret string
|
||||
SecretCode string
|
||||
EncryptionKey string
|
||||
AccessKey string
|
||||
)
|
||||
|
||||
func init() {
|
||||
func Init() {
|
||||
godotenv.Load()
|
||||
// Fail fast if critical environment variables are missing
|
||||
Secret = getEnvRequired("APP_SECRET")
|
||||
SecretCode = getEnvRequired("APP_SECRET_CODE")
|
||||
EncryptionKey = getEnvRequired("ENCRYPTION_KEY")
|
||||
AccessKey = getEnvRequired("ACCESS_KEY")
|
||||
|
||||
if len(EncryptionKey) != 32 {
|
||||
log.Fatal("ENCRYPTION_KEY must be exactly 32 bytes long for AES-256")
|
||||
|
||||
@@ -35,7 +35,7 @@ func Migrate(db *gorm.DB) {
|
||||
|
||||
// Run GORM AutoMigrate for all models
|
||||
err := db.AutoMigrate(
|
||||
&model.ApiModel{},
|
||||
&model.ServiceControlModel{},
|
||||
&model.Config{},
|
||||
&model.Track{},
|
||||
&model.CarModel{},
|
||||
@@ -55,7 +55,7 @@ func Migrate(db *gorm.DB) {
|
||||
// Don't panic, just log the error as custom migrations may have handled this
|
||||
}
|
||||
|
||||
db.FirstOrCreate(&model.ApiModel{Api: "Works"})
|
||||
db.FirstOrCreate(&model.ServiceControlModel{ServiceControl: "Works"})
|
||||
|
||||
Seed(db)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ type Claims struct {
|
||||
}
|
||||
|
||||
// init initializes the JWT secret key from environment variable
|
||||
func init() {
|
||||
func Init() {
|
||||
jwtSecret := os.Getenv("JWT_SECRET")
|
||||
if jwtSecret == "" {
|
||||
log.Fatal("JWT_SECRET environment variable is required and cannot be empty")
|
||||
|
||||
Reference in New Issue
Block a user