core

package
v0.0.0-...-258e4f8 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

We need to think about this Helx-Apps really breaks an ideally managed rest-api. Instead of relying on database to persist list of applications which support crud functionality, here we would either embed or reach out to a github repository for the information. Benefits - Allows for dynamic loading into ptolemaios however the downside is

Index

Constants

This section is empty.

Variables

View Source
var (
	EmailRX = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
)

Functions

func CloneBranch

func CloneBranch(url, branchName string) error

Clone the helx-apps branch from url and branchName provided. This will represent the applications available to the user in appstore.

func Matches

func Matches(value string, rx *regexp.Regexp) bool

func NewLogger

func NewLogger(out io.Writer) *slog.Logger

func NewOauthConfig

func NewOauthConfig(p Provider) *oauth2.Config

Default to github

func NewSessionManager

func NewSessionManager(db *pgxpool.Pool) *scs.SessionManager

Initialize a new session manager. Adjust the Lifetime here to create shorter or longer sessions as needed. Currently this is hardcoded to keep it simple.

func OpenDB

func OpenDB(dsn string) (*pgxpool.Pool, error)

func PermittedValue

func PermittedValue[T comparable](value T, permittedValues ...T) bool

func Unique

func Unique[T comparable](values []T) bool

Types

type Config

type Config struct {
	Port    string
	Env     string
	Version string
	Db      Db
}

Add new configs here

func NewConfig

func NewConfig() *Config

With NewConfig expect ENV variables passed from Makefile but ensure default values are always present in case running via go tooling. However worth noting that this appliation is tightly coupled to a database, without which it will fail.

type Db

type Db struct {
	Dsn string
}

Db

type Provider

type Provider int
const (
	Github Provider = iota
	Microsoft
	Slack
)

type Validator

type Validator struct {
	Errors map[string]string
}

func NewValidator

func NewValidator() *Validator

func (*Validator) AddError

func (v *Validator) AddError(key, message string)

func (*Validator) Check

func (v *Validator) Check(ok bool, key, message string)

func (*Validator) Valid

func (v *Validator) Valid() bool

Valid returns true if the errors map has no entries

Jump to

Keyboard shortcuts

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