backend/internal/types/types.go
2025-06-15 12:53:27 +02:00

62 lines
1.7 KiB
Go

/*
Copyright (C) 2025 hexlocation (hex@iwakura.rip) & grngxd (grng@iwakura.rip)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package types
import (
"context"
"time"
"github.com/gin-gonic/gin"
"github.com/gofrs/uuid"
"github.com/minio/minio-go/v7"
"gorm.io/gorm"
"stereo.cat/backend/internal/auth/client"
)
type Route struct {
Path string
Method string
Exec func(cfg *StereoConfig) gin.HandlerFunc
}
type StereoConfig struct {
ImagePath string
Bucket string
MinioClient *minio.Client
Router *gin.Engine
Client client.Client
Database *gorm.DB
JWTSecret string
FrontendUri string
Domain string
Context context.Context
}
type File struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey"`
Name string `gorm:"not null;index"`
Owner string `gorm:"not null;index"`
Size int64 `gorm:"not null;type:bigint"`
CreatedAt time.Time `gorm:"autoCreateTime"`
Mime string
}
func (f *File) BeforeCreate(tx *gorm.DB) (err error) {
f.ID, err = uuid.NewV4()
return
}