Added a database

This commit is contained in:
Leon Mika 2026-02-19 22:29:44 +11:00
parent ebaec3d296
commit 8136655336
35 changed files with 925 additions and 134 deletions

16
models/ctx.go Normal file
View file

@ -0,0 +1,16 @@
package models
import "context"
type userKeyType struct{}
var userKey = userKeyType{}
func WithUser(ctx context.Context, user User) context.Context {
return context.WithValue(ctx, userKey, user)
}
func GetUser(ctx context.Context) (User, bool) {
user, ok := ctx.Value(userKey).(User)
return user, ok
}

6
models/errors.go Normal file
View file

@ -0,0 +1,6 @@
package models
import "emperror.dev/errors"
var UserRequiredError = errors.New("user required")
var PermissionError = errors.New("permission denied")

View file

@ -1,8 +1,11 @@
package models
type PublishTargetType int
const (
PublishTargetTypeNone int = iota
PublishTargetTypeNetlify
PublishTargetTypeNone PublishTargetType = 0
PublishTargetTypeLocalFS PublishTargetType = 1
PublishTargetTypeNetlify PublishTargetType = 2
)
type Site struct {
@ -15,12 +18,13 @@ type Site struct {
}
type SitePublishTarget struct {
ID int64
SiteID int64
PublishTargetType int
BaseURL string
TargetSiteID string
TargetPublishKey string
ID int64
SiteID int64
BaseURL string
TargetType PublishTargetType
TargetRef string
TargetKey string
}
/*