Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIKey ¶
type APIKey struct {
Key string `gorm:"primarykey;type:varchar(64)"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
// Paste-related limits and permissions
MaxFileSize int64 // 10MB default
RateLimit int // Requests per hour
AllowPrivate bool `gorm:"default:true"`
AllowUpdates bool `gorm:"default:true"`
// URL shortening permissions
AllowShortlinks bool `gorm:"default:true"` // Whether this key can create shortlinks
ShortlinkQuota int `gorm:"default:0"` // 0 = unlimited
ShortlinkPrefix string `gorm:"type:varchar(16)"` // Optional custom prefix for shortened URLs
// Optional user information
Email string `gorm:"type:varchar(255)"`
Name string `gorm:"type:varchar(255)"`
// Usage tracking
LastUsedAt *time.Time
UsageCount int64
// Verification
Verified bool `gorm:"default:false"`
VerifyToken string `gorm:"type:varchar(64)"`
VerifyExpiry time.Time
IsReset bool `json:"is_reset" gorm:"default:false"`
}
type AnalyticsEvent ¶
type AnalyticsEvent struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
// Event information
EventType EventType `gorm:"type:varchar(32);index;not null"`
// Resource information (what the event is about)
ResourceID string `gorm:"type:varchar(16);index;not null"` // ID of the shortlink or paste
ResourceType string `gorm:"type:varchar(32);index;not null"` // "shortlink" or "paste"
// Request information
UserAgent string `gorm:"type:text"`
IPAddress string `gorm:"type:varchar(45)"` // IPv6 addresses can be up to 45 chars
RefererURL string `gorm:"type:text"`
Browser string `gorm:"type:varchar(32)"`
OS string `gorm:"type:varchar(32)"`
Device string `gorm:"type:varchar(32)"`
// Location information
City string `gorm:"type:varchar(255)"`
Region string `gorm:"type:varchar(255)"`
ZipCode string `gorm:"type:varchar(10)"`
Country string `gorm:"type:varchar(2)"`
// Additional data
Metadata JSON `gorm:"type:jsonb"`
}
AnalyticsEvent represents a single analytics event
type EventType ¶
type EventType string
EventType represents different types of events that can be tracked
type JSON ¶
type JSON json.RawMessage
JSON custom type to handle both PostgreSQL JSONB and SQLite TEXT
func (JSON) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface
type Paste ¶
type Paste struct {
ID string `gorm:"primarykey;type:varchar(16)"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
// Content information
Filename string `gorm:"type:varchar(255)"`
MimeType string `gorm:"type:varchar(255)"`
Size int64
Extension string `gorm:"type:varchar(32)"`
// Storage information
StoragePath string `gorm:"type:varchar(512)"`
StorageType string `gorm:"type:varchar(32)"` // "local" or "s3"
StorageName string `gorm:"type:varchar(64)"` // Name of the storage config
// Access control
Private bool
DeleteKey string `gorm:"type:varchar(32)"`
APIKey string `gorm:"type:varchar(64);index"` // If created with an API key
// Expiration
ExpiresAt *time.Time `gorm:"index"`
// Optional metadata
Metadata JSON `gorm:"type:jsonb"` // For PostgreSQL, will fallback to JSON string for SQLite
}
type Shortlink ¶
type Shortlink struct {
ID string `gorm:"primarykey;type:varchar(8)"` // Shorter IDs for URLs
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
// URL information
TargetURL string `gorm:"type:text;not null"`
Title string `gorm:"type:varchar(255)"` // Optional, can be fetched from target
// Access control
APIKey string `gorm:"type:varchar(64);not null;index"` // Required for creation
DeleteKey string `gorm:"type:varchar(32);not null"`
ExpiresAt *time.Time `gorm:"index"`
// Optional metadata (referrer stats, etc.)
Metadata JSON `gorm:"type:jsonb"`
}
Click to show internal directories.
Click to hide internal directories.