api

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package api handles routes and their associated handlers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupMux

func SetupMux(cfg *APIConfig) *http.ServeMux

Types

type APIConfig

type APIConfig struct {
	Pool *pgxpool.Pool
	// contains filtered or unexported fields
}

func (*APIConfig) ConnectToDB

func (cfg *APIConfig) ConnectToDB(fs embed.FS, migrationsDir string)

func (*APIConfig) GenerateDBConnectionString

func (cfg *APIConfig) GenerateDBConnectionString() (string, error)

func (*APIConfig) Init

func (cfg *APIConfig) Init(envPath string) error

func (*APIConfig) NewLogger

func (cfg *APIConfig) NewLogger(level slog.Level)

type Account

type Account struct {
	ID          uuid.UUID `json:"id"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	BudgetID    uuid.UUID `json:"budget_id"`
	AccountType string    `json:"account_type"`
	IsDeleted   bool      `json:"is_deleted"`
	Meta
}

type Budget

type Budget struct {
	ID        uuid.UUID `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	AdminID   uuid.UUID `json:"admin_id"`
	Meta
}

type BudgetMemberRole

type BudgetMemberRole int
const (
	ADMIN BudgetMemberRole = iota
	MANAGER
	CONTRIBUTOR
	VIEWER
)

func BMRFromString

func BMRFromString(s string) (BudgetMemberRole, error)

func (BudgetMemberRole) String

func (bmr BudgetMemberRole) String() string

type BudgetMembership

type BudgetMembership struct {
	BudgetID   uuid.UUID        `json:"budget_id"`
	UserID     uuid.UUID        `json:"user_id"`
	MemberRole BudgetMemberRole `json:"member_role"`
}

type Category

type Category struct {
	ID        uuid.UUID  `json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	BudgetID  uuid.UUID  `json:"budget_id"`
	GroupID   *uuid.UUID `json:"group_id"`
	Meta
}

type CategoryReport

type CategoryReport struct {
	MonthID  time.Time `json:"month_id"`
	Name     string    `json:"category_name"`
	Assigned int64     `json:"assigned"`
	Activity int64     `json:"activity"`
	Balance  int64     `json:"balance"`
}

type DBConfig

type DBConfig struct {
	DBUser     string
	DBPassword string
	DBHost     string
	DBPort     string
	DBName     string
}

type Group

type Group struct {
	ID        uuid.UUID `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	BudgetID  uuid.UUID `json:"budget_id"`
	Meta
}

type Meta

type Meta struct {
	Name  string `json:"name"`
	Notes string `json:"notes"`
}

type MonthReport

type MonthReport struct {
	Assigned int64 `json:"assigned"`
	Activity int64 `json:"activity"`
	Balance  int64 `json:"balance"`
}

type Payee

type Payee struct {
	ID        uuid.UUID `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	BudgetID  uuid.UUID `json:"budget_id"`
	Meta
}

type Transaction

type Transaction struct {
	ID              uuid.UUID `json:"id"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	BudgetID        uuid.UUID `json:"budget_id"`
	LoggerID        uuid.UUID `json:"logger_id"`
	AccountID       uuid.UUID `json:"account_id"`
	TransactionType string    `json:"transaction_type"`
	TransactionDate time.Time `json:"transaction_date"`
	PayeeID         uuid.UUID `json:"payee_id"`
	Notes           string    `json:"notes"`
	Cleared         bool      `json:"is_cleared"`
}

type TransactionDetail

type TransactionDetail struct {
	ID              uuid.UUID        `json:"id"`
	TransactionDate time.Time        `json:"transaction_date"`
	TransactionType string           `json:"transaction_type"`
	Notes           string           `json:"notes"`
	PayeeName       string           `json:"payee_name"`
	BudgetName      string           `json:"budget_name"`
	AccountName     string           `json:"account_name"`
	LoggerName      string           `json:"logger_name"`
	TotalAmount     int64            `json:"total_amount"`
	Splits          map[string]int64 `json:"splits"`
	Cleared         bool             `json:"cleared"`
}

type TransactionSplit

type TransactionSplit struct {
	ID            uuid.UUID  `json:"id"`
	TransactionID uuid.UUID  `json:"transaction_id"`
	CategoryID    *uuid.UUID `json:"category_id"`
	Amount        int64      `json:"amount"`
}

type UpsertTransactionRqSchema

type UpsertTransactionRqSchema struct {
	AccountName         string `json:"account_name"`
	TransferAccountName string `json:"transfer_account_name"`
	// TransactionDate is a time string in the custom format "2006-01-02" (YYYY-MM-DD)
	TransactionDate string `json:"transaction_date"`
	PayeeName       string `json:"payee_name"`
	Notes           string `json:"notes"`
	Cleared         bool   `json:"is_cleared"`
	/* Amounts associates category names with the amount spent from each.
	If there is only one entry in Amounts, the transaction is not truly split.
	Nonetheless, all transactions are associated with at least one txn split.
	A 'txn split' reflects the sum of spending toward one particular category within the transaction.
	*/
	Amounts map[string]int64 `json:"amounts"`
}

UpsertTransactionRqSchema represents a raw POST or PUT payload sent by a client. It is validated through middleware before then being sent to the proper txn endpoint.

type User

type User struct {
	ID             uuid.UUID `json:"id"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	Username       string    `json:"username"`
	HashedPassword string    `json:"-"`
}

Jump to

Keyboard shortcuts

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