cascade

package module
v0.0.0-...-03d9d23 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

README

cascade

Simple link shortener api written in Go. Very early stages, not even close to ready.

Project was named after the Cascade Mountain Range.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExpiredJWT = fmt.Errorf("JWT has expired")
View Source
var ErrShortUrlExists = fmt.Errorf("shortUrl already exists")

Functions

func Init

func Init(db DBConnection, kv KVConnection, jwtSigningSecret string)

func Run

func Run(port int)

func Shutdown

func Shutdown()

Types

type Account

type Account struct {
	gorm.Model
	Email    string
	Verified bool
	Password string
}

type AccountManager

type AccountManager struct {
	// contains filtered or unexported fields
}

func NewAccountManager

func NewAccountManager(db *DB, kv *KVStore, jwtSigningSecret string) *AccountManager

func (*AccountManager) ChangePassword

func (am *AccountManager) ChangePassword(accountID uint, newPassword string) error

func (*AccountManager) Close

func (am *AccountManager) Close() error

func (*AccountManager) CreateAccount

func (am *AccountManager) CreateAccount(email string, password string) (*Account, error)

func (*AccountManager) GenerateJWT

func (am *AccountManager) GenerateJWT(accountID uint) (string, error)

func (*AccountManager) GetAccountByEmail

func (am *AccountManager) GetAccountByEmail(email string) (*Account, error)

func (*AccountManager) Login

func (am *AccountManager) Login(email string, password string) (string, string, error)

func (*AccountManager) Logout

func (am *AccountManager) Logout(login Login) error

func (*AccountManager) RecordLogin

func (am *AccountManager) RecordLogin(login Login) error

func (*AccountManager) ValidateJWT

func (am *AccountManager) ValidateJWT(jwtToken string) (uint, error)

func (*AccountManager) ValidateRefreshToken

func (am *AccountManager) ValidateRefreshToken(refreshToken string) (Login, error)

type AccountRequest

type AccountRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type DB

type DB struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(dbConn DBConnection) (*DB, error)

func (*DB) Close

func (db *DB) Close()

type DBConnection

type DBConnection struct {
	Address string
}

type KVConnection

type KVConnection struct {
	Address string
}

type KVStore

type KVStore struct {
	// contains filtered or unexported fields
}

func NewKVStore

func NewKVStore(kvConn KVConnection) (*KVStore, error)

func (*KVStore) Close

func (kv *KVStore) Close()

func (*KVStore) Delete

func (kv *KVStore) Delete(key string) error

func (*KVStore) Exists

func (kv *KVStore) Exists(key string) (bool, error)

func (*KVStore) Get

func (kv *KVStore) Get(key string) (string, error)

func (*KVStore) Increment

func (kv *KVStore) Increment(key string) error

func (*KVStore) Put

func (kv *KVStore) Put(key string, value string) error
type Link struct {
	gorm.Model
	Url      string
	ShortUrl string
	Count    int
	Owner    uint
}

type LinkManager

type LinkManager struct {
	// contains filtered or unexported fields
}

func NewLinkManager

func NewLinkManager(db *DB, kv *KVStore) *LinkManager
func (lm *LinkManager) CreateLink(url string, shortUrl string, accountID uint) error
func (lm *LinkManager) GetLink(shortUrl string, queriedByAccountID uint) (string, error)

type LinkRequest

type LinkRequest struct {
	Url      string `json:"url"`
	ShortUrl string `json:"shortUrl"`
}

type Login

type Login struct {
	gorm.Model
	AccountID    uint
	IpAddress    string
	UserAgent    string
	RefreshToken string
	ExpiresAt    time.Time
}

type Query

type Query struct {
	gorm.Model
	LinkID    uint // Link ID
	QueriedBy uint // Account ID
}

Directories

Path Synopsis
cmd
cascade command

Jump to

Keyboard shortcuts

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