utils

package
v0.0.0-...-fb9fc09 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB is the database connection

Functions

func ConnectDB

func ConnectDB()

ConnectDB connects to the database and performs migrations

func CreateAPIKey

func CreateAPIKey(apiKey *models.APIKey) error

CreateAPIKey creates a new API key in the database

func CreateCustomer

func CreateCustomer(customer *models.Customer) error

CreateCustomer creates a new customer in the database

func CreateServer

func CreateServer(server *models.Server) error

CreateServer creates a new server in the database

func CreateUser

func CreateUser(user *models.User) error

CreateUser creates a new user in the database

func DecryptFile

func DecryptFile(data []byte, key []byte) ([]byte, error)

DecryptFile decrypts a file using the given key and returns the decrypted file as a byte array

func DeleteCustomer

func DeleteCustomer(id uint) error

DeleteCustomer deletes a customer from the database

func DeleteServer

func DeleteServer(id uint) error

DeleteServer deletes a server from the database

func DeleteUser

func DeleteUser(id uint) error

DeleteUser deletes a user from the database

func DownloadFromS3

func DownloadFromS3(filename string) ([]byte, error)

DownloadFromS3 downloads a file from S3 and returns the file as a byte array

func EncryptFile

func EncryptFile(data []byte, key []byte) ([]byte, error)

EncryptFile encrypts a file using the given key and returns the encrypted file as a byte array

func GenerateDownloadLink(filename string) (string, error)

GenerateDownloadLink generates a download link for a file in S3

func GetAPIKeyByAccessKey

func GetAPIKeyByAccessKey(accessKey string) (*models.APIKey, error)

GetAPIKeyByAccessKey retrieves an API key from the database by its access key

func GetAllCustomers

func GetAllCustomers() ([]models.Customer, error)

GetAllCustomers returns all customers from the database

func GetAllServers

func GetAllServers() ([]models.Server, error)

GetAllServers returns all servers from the database

func GetAllUsers

func GetAllUsers() ([]models.User, error)

GetAllUsers returns all users from the database

func GetCustomerByID

func GetCustomerByID(id uint) (*models.Customer, error)

GetCustomerByID retrieves a customer from the database by its ID

func GetEncryptionKey

func GetEncryptionKey() string

GetEncryptionKey returns the encryption key

func GetFilesByUserID

func GetFilesByUserID(userID uint) ([]models.FileMetadata, error)

GetFilesByUserID returns all files from the database by user ID

func GetJWTSecret

func GetJWTSecret() string

GetJWTSecret returns the JWT secret key

func GetServerByID

func GetServerByID(id uint) (*models.Server, error)

GetServerByID retrieves a server from the database by its ID

func GetUploadLink(linkID string) (*models.UploadLink, error)

GetUploadLink retrieves an upload link from the database

func GetUserByEmail

func GetUserByEmail(email string) (*models.User, error)

GetUserByEmail retrieves a user from the database by email

func GetUserByID

func GetUserByID(id uint) (*models.User, error)

GetUserByID gets a user by ID from the database

func HashSecretKey

func HashSecretKey(secretKey string) (string, error)

HashSecretKey hashes the secret key using bcrypt and returns the hashed password.

func InitS3

func InitS3() error

InitS3 initializes the S3 session

func ParseInt

func ParseInt(s string) int

ParseInt parses a string to int.

func ParseUint

func ParseUint(s string) uint

ParseUint parses a string to uint.

func SaveFileMetadata

func SaveFileMetadata(file *models.FileMetadata) error

SaveFileMetadata saves file metadata to the database

func SaveUploadLink(link *models.UploadLink) error

SaveUploadLink saves the upload link to the database

func SearchCustomers

func SearchCustomers(query string) ([]models.Customer, error)

SearchCustomers searches for customers in the database without case sensitivity

func SearchServers

func SearchServers(query string) ([]models.Server, error)

SearchServers searches for servers in the database without case sensitivity

func SearchUsers

func SearchUsers(query string) ([]models.User, error)

SearchUsers searches for users in the database

func UpdateCustomer

func UpdateCustomer(id uint, customer *models.Customer) error

UpdateCustomer updates a customer in the database

func UpdateServer

func UpdateServer(id uint, server *models.Server) error

UpdateServer updates a server in the database

func UpdateUser

func UpdateUser(id uint, user *models.User) error

UpdateUser updates a user in the database

func UploadToS3

func UploadToS3(file []byte, filename string) error

UploadToS3 uploads a file to S3

func ValidateSearchQuery

func ValidateSearchQuery(query string) error

ValidateSearchQuery validates the search query based on DNS rules

func VerifyAPIKey

func VerifyAPIKey(accessKey, secretKey string) (bool, *models.User, error)

VerifyAPIKey verifies the provided API accessKey and secretKey

func VerifyCredentials

func VerifyCredentials(email, password string) bool

VerifyCredentials checks if the email and password are valid and returns true if they are valid, otherwise it returns false

func VerifySecretKey

func VerifySecretKey(hashedSecretKey, secretKey string) error

VerifySecretKey verifies if the provided secret key matches the hashed password.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL