feat: add Sense device inventory and credential boundary (#23)

This commit is contained in:
QiuSW
2026-08-12 17:10:13 +08:00
parent b9416ebc08
commit 5b8f4a4c8c
14 changed files with 704 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package sense
import (
"os"
"yovision.local/sense/app/sense/device"
"yovision.local/sense/internal/platform"
)
func init() {
registerModule(func(app *platform.App) error {
memory := app.Config().DatabaseMode == platform.DatabaseModeMemory
vault, err := device.NewCredentialVault(os.Getenv("SENSE_CREDENTIAL_KEY"), memory)
if err != nil {
return err
}
var store device.Store
if memory {
store = device.NewMemoryStore()
} else {
store = device.NewPostgresStore(app.Database())
}
app.RegisterMigration(platform.Migration{Version: 2026081202, Name: "sense_device", SQL: device.MigrationSQL})
device.NewModule(device.NewService(store, vault)).Register(app)
return nil
})
}