Documentation
¶
Index ¶
- Constants
- func ClampFloat32(v, min, max float32) float32
- func ClampInt(v, min, max int) int
- func CombineFlags(flags []int) uint64
- func ComparePasswords(storedHash, password string) error
- func DeleteFilesWithPrefix(dir string, prefix string) (int, error)
- func EncryptPassword(password string) (string, error)
- func FilterNilMap[T ~map[string]interface{}](data T) T
- func GenerateWKT(lat, lon float64) (string, error)
- func GetAvatarURL(baseApiURL, imageDir, userUuid string, size int) *string
- func IntSliceToCsv(ids []int) string
- func IsValidDateStr(dateStr string) bool
- func IsValidEmail(email string) bool
- func IsValidIso639_1(languageStr string) bool
- func JWTMiddleware(gc *gin.Context)
- func ParseIntSliceCsv(s string) ([]int, error)
- func ReadSVG(path string) string
- func RemoveFile(path string) error
- func SqlNullBoolToBool(nb sql.NullBool) bool
- func SqlNullBoolToString(nb sql.NullBool) string
- func SqlNullInt64ToInt(n sql.NullInt64) int64
- func SqlNullInt64ToString(n sql.NullInt64) string
- func SqlNullStringToString(ns sql.NullString) string
- func SqlNullTimeToString(nt sql.NullTime) string
- func ToInt(value interface{}) (int, bool)
- func TruncateAtWord(s string, maxLength int) string
- func ValidateOptionalDate(fieldName string, value *string) error
- func ValidateOptionalNonEmptyString(fieldName string, value *string) error
- func ValidateOptionalTime(fieldName string, value *string) error
- func ValidateOptionalUrl(fieldName string, value *string) error
- type Claims
- type Config
- type Permission
- type SqlQueryItem
- type Uranus
- func (uranus *Uranus) CheckAllDatabaseConsistency(ctx context.Context) error
- func (app *Uranus) CloseAllDBs()
- func (app *Uranus) DbErrorToHTTP(err error) int
- func (app *Uranus) InitMainDB() error
- func (app *Uranus) LoadConfig(fileName string) error
- func (app *Uranus) Log(msg string)
- func (app *Uranus) PrepareSql() error
Constants ¶
const ( // Organization permissions PermBitEditOrganization = 0 PermBitDeleteOrganization = 1 PermBitChooseAsEventOrganization = 2 PermBitChooseAsEventPartner = 3 PermBitReceiveOrganizationMsgs = 4 PermBitManagePermissions = 5 PermBitManageTeam = 6 // Venue permissions PermBitAddVenue = 8 PermBitEditVenue = 9 PermBitDeleteVenue = 10 PermBitChooseVenue = 11 // Space permissions PermBitAddSpace = 16 PermBitEditSpace = 17 PermBitDeleteSpace = 18 // Event permissions PermBitAddEvent = 24 PermBitEditEvent = 25 PermBitDeleteEvent = 26 PermBitReleaseEvent = 27 PermBitViewEventInsights = 28 )
Variables ¶
This section is empty.
Functions ¶
func ClampFloat32 ¶ added in v0.1.1
func CombineFlags ¶
CombineFlags takes a slice of integers representing flag positions and combines them into a single uint64 bitmask.
Each integer in the input slice should be in the range [0, 63], representing a bit position in the 64-bit unsigned integer. The function sets the bit at each of these positions to 1 in the result.
For example, if flags = []int{0, 2, 5}, the result will have bits 0, 2, and 5 set, resulting in a value like: 0b00100101.
Any flag values outside the range [0, 63] are ignored.
Parameters:
- flags: A slice of integers representing positions of individual flags.
Returns:
- A uint64 value with the corresponding bits set.
func ComparePasswords ¶
ComparePasswords compares a plain password with a bcrypt hash
func DeleteFilesWithPrefix ¶ added in v0.1.1
DeleteFilesWithPrefix deletes all files in a directory that start with the given prefix. Returns the number of deleted files and an error (if any).
func EncryptPassword ¶
EncryptPassword hashes a password and returns the hashed string along with any error
func FilterNilMap ¶ added in v0.1.1
func FilterNilMap[T ~map[string]interface{}](data T) T
FilterNilMap removes nil values from a single map
func GenerateWKT ¶ added in v0.1.1
GenerateWKT takes lat/lon strings and returns a WKT POINT string
func GetAvatarURL ¶ added in v0.1.1
func IntSliceToCsv ¶ added in v0.1.1
func IsValidDateStr ¶
func IsValidEmail ¶ added in v0.1.1
func IsValidIso639_1 ¶
func JWTMiddleware ¶ added in v0.1.1
func ParseIntSliceCsv ¶ added in v0.1.1
func RemoveFile ¶ added in v0.1.1
RemoveFile deletes a file at the given path. Returns an error if the file cannot be deleted.
func SqlNullBoolToBool ¶
Utility function to extract bool from sql.NullBool
func SqlNullBoolToString ¶
Utility function to extract string from sql.NullBool
func SqlNullInt64ToInt ¶
Utility function to extract int64 from sql.NullInt64
func SqlNullInt64ToString ¶
Utility function to extract string from sql.NullInt64
func SqlNullStringToString ¶
func SqlNullStringToString(ns sql.NullString) string
Utility function to extract string from sql.NullString
func SqlNullTimeToString ¶
Utility function to extract time from sql.NullTime
func ToInt ¶ added in v0.1.1
ToInt converts an interface{} to int safely. Returns the int value and true if successful, false otherwise.
func TruncateAtWord ¶
TruncateAtWord truncates the string at the word boundary
func ValidateOptionalDate ¶ added in v0.1.1
ValidateOptionalDate validates an optional date string in the format YYYY-MM-DD. - If the pointer is nil or empty, it is considered valid. - Otherwise, it checks if the value matches the format "2006-01-02".
func ValidateOptionalNonEmptyString ¶ added in v0.1.1
ValidateOptionalNonEmptyString checks if an optional string pointer is non-empty. - If value is nil, it's considered valid. - If value is non-nil but empty or whitespace-only, it returns an error.
func ValidateOptionalTime ¶ added in v0.1.1
ValidateOptionalTime validates an optional time string in the format HH:MM (24-hour). - If the pointer is nil or empty, it is considered valid. - Otherwise, it checks if the value matches the format "15:04".
func ValidateOptionalUrl ¶ added in v0.1.1
ValidateOptionalUrl validates a pointer to a string as a URL. - If the pointer is nil, it's considered valid. - If the string is empty or whitespace, it's considered invalid. - Otherwise, it checks for valid URL format and http/https scheme.
Types ¶
type Claims ¶ added in v0.1.1
type Claims struct {
UserUuid string `json:"user_uuid"`
jwt.RegisteredClaims
}
Claims struct for JWT
type Config ¶
type Config struct {
Verbose bool `json:"verbose"`
DevMode bool `json:"dev_mode"`
DebugLevel int `json:"debug_level"`
Port int `json:"port"`
BaseApiUrl string `json:"base_api_url"`
IcsDomain string `json:"ics_domain"`
UseRouterMiddleware bool `json:"use_router_middleware"`
SupportedLanguages []string `json:"supported_languages"`
DbHost string `json:"db_host"`
DbPort int `json:"db_port"`
DbUser string `json:"db_user"`
DbPassword string `json:"db_password"`
DbName string `json:"db_name"`
DbSchema string `json:"db_schema"`
SSLMode string `json:"ssl_mode"`
AllowOrigins []string `json:"allow_origins"`
ProfileImageDir string `json:"profile_image_dir"`
ProfileImageQuality float32 `json:"profile_image_quality"`
PlutoImageMaxFileSize int `json:"pluto_image_max_file_size"`
PlutoImageMaxPx int `json:"pluto_image_max_px"`
PlutoVerbose bool `json:"pluto_verbose"`
PlutoImageDir string `json:"pluto_image_dir"`
PlutoCacheDir string `json:"pluto_cache_dir"`
JwtSecret string `json:"jwt_secret"`
SecretKey string `json:"secret_key"`
AuthTokenExpirationTime int `json:"auth_token_expiration_time"`
AuthSmtpHost string `json:"auth_smtp_host"`
AuthSmtpPort int `json:"auth_smtp_port"`
AuthSmtpLogin string `json:"auth_smtp_login"`
AuthSmtpPassword string `json:"auth_smtp_password"`
AuthReplyEmail string `json:"auth_reply_email"`
AuthResetPasswordUrl string `json:"auth_reset_password_url"`
InvitationExpirationMinutes int `json:"invitation_expiration_minutes"`
}
Config holds database configuration details
func DefaultConfig ¶ added in v0.1.1
func DefaultConfig() Config
type Permission ¶ added in v0.1.1
type Permission uint64
const ( // Organization permissions PermEditOrganization Permission = 1 << PermBitEditOrganization PermDeleteOrganization Permission = 1 << PermBitDeleteOrganization PermChooseAsEventOrganization Permission = 1 << PermBitChooseAsEventOrganization PermChooseAsEventPartner Permission = 1 << PermBitChooseAsEventPartner PermReceiveOrganizationMsgs Permission = 1 << PermBitReceiveOrganizationMsgs PermManagePermissions Permission = 1 << PermBitManagePermissions PermManageTeam Permission = 1 << PermBitManageTeam // Venue permissions PermAddVenue Permission = 1 << PermBitAddVenue PermEditVenue Permission = 1 << PermBitEditVenue PermDeleteVenue Permission = 1 << PermBitDeleteVenue PermChooseVenue Permission = 1 << PermBitChooseVenue // Space permissions PermAddSpace Permission = 1 << PermBitAddSpace PermEditSpace Permission = 1 << PermBitEditSpace PermDeleteSpace Permission = 1 << PermBitDeleteSpace // Event permissions PermAddEvent Permission = 1 << PermBitAddEvent PermEditEvent Permission = 1 << PermBitEditEvent PermDeleteEvent Permission = 1 << PermBitDeleteEvent PermReleaseEvent Permission = 1 << PermBitReleaseEvent PermViewEventInsights Permission = 1 << PermBitViewEventInsights PermCombinationAdmin = 0b00011111000001110000111101111111 )
func (*Permission) Add ¶ added in v0.1.1
func (p *Permission) Add(flag Permission)
func (Permission) Has ¶ added in v0.1.1
func (p Permission) Has(flag Permission) bool
func (Permission) HasAll ¶ added in v0.1.1
func (p Permission) HasAll(mask Permission) bool
HasAll checks if all bits in 'mask' are set in 'p'
func (Permission) HasAny ¶ added in v0.1.1
func (p Permission) HasAny(mask Permission) bool
HasAny checks if at least one bit in 'mask' is set in 'p'
func (*Permission) Remove ¶ added in v0.1.1
func (p *Permission) Remove(flag Permission)
type SqlQueryItem ¶ added in v0.1.1
type SqlQueryItem struct {
// contains filtered or unexported fields
}
type Uranus ¶
type Uranus struct {
Version string
APIName string
APIVersion string
MainDbPool *pgxpool.Pool
Config Config
SqlGetOrganization string
SqlGetVenue string
SqlGetEvent string
SqlGetEventDates string
SqlGetEventsProjected string
SqlGetEventsTypeSummary string
SqlGetEventsGeoJSON string
SqlGetUserOrganizationPermissions string
SqlGetUserEffectiveVenuePermissions string
SqlGetUserEventPermissions string
SqlGetAdminOrganization string
SqlInsertOrganization string
SqlUpdateOrganization string
SqlAdminInvitedOrganizationTeamMember string
SqlAdminInsertInvitedOrganizationTeamMember string
SqlAdminGetVenue string
SqlInsertVenue string
SqlUpdateVenue string
SqlAdminGetSpace string
SqlInsertSpace string
SqlUpdateSpace string
SqlAdminGetEvent string
SqlAdminGetEventTypes string
SqlAdminGetEventImages string
SqlAdminGetEventLinks string
SqlAdminGetEventDates string
SqlAdminInsertEventDate string
SqlAdminUpdateEventDate string
SqlAdminDeleteEvent string
SqlEventTypeGenreLookup string
SqlChoosableOrganizationVenues string
SqlChoosableVenueSpaces string
SqlChoosableEventTypes string
SqlChoosableEventGenres string
SqlGetGeojsonVenues string
SqlAdminGetOrganizationList string
SqlAdminGetOrganizationVenues string
SqlGetSystemEmailTemplate string
SqlAdminGetOrganizationEvents string
SqlAdminGetOrganizationMemberLink string
SqlAdminGetOrganizationMembers string
SqlAdminGetPermissionList string
SqlQueryUserOrgEventsOverview string
SqlAdminGetUserEventNotifications string
SqlAdminChoosableOrganizations string
SqlAdminChoosableUserEventVenues string
SqlAdminEvent string
SqlAdminSpacesForEvent string
SqlInsertPlutoImage string
SqlUpdatePlutoImageMeta string
JwtKey []byte `json:"jwt_secret"`
}
var UranusInstance *Uranus
func Initialize ¶ added in v0.1.1
func (*Uranus) CheckAllDatabaseConsistency ¶ added in v0.1.1
func (*Uranus) CloseAllDBs ¶
func (app *Uranus) CloseAllDBs()
func (*Uranus) DbErrorToHTTP ¶
Function to convert database errors to HTTP status codes