core

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package core wires all application dependencies together. It is the primary extension point for the pro version — supply AppOption functions to inject custom implementations of any data.*Repoer interface.

@title		okpos API
@version	0.1.0
@description	Business management API for small and medium businesses.
@host		localhost:8080
@BasePath	/api/v1

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppOption

type AppOption func(*OkPOSApp)

AppOption is a functional option for NewApp.

func WithAccountingRepo

func WithAccountingRepo(repo data.AccountingRepoer) AppOption

WithAccountingRepo injects an AccountingRepoer implementation.

func WithAssetRepo added in v0.5.1

func WithAssetRepo(repo data.AssetRepoer) AppOption

WithAssetRepo injects an AssetRepoer implementation.

func WithBranchRepo

func WithBranchRepo(repo data.BranchRepoer) AppOption

WithBranchRepo injects a BranchRepoer implementation.

func WithCashDrawerMethods

func WithCashDrawerMethods(methods []model.PaymentMethod) AppOption

WithCashDrawerMethods sets which payment methods count toward the physical cash drawer for session reconciliation. Defaults to model.DefaultCashDrawerMethods if not provided.

func WithClock added in v0.5.1

func WithClock(clk clock.Clock) AppOption

WithClock injects a Clock implementation, used for every timestamp the app records (audit fields, session/order timestamps, JWT issuance and expiry). Defaults to clock.NewReal() if not provided — tests that need a deterministic clock should pass a *clock.Fake here.

func WithCompanyRepo

func WithCompanyRepo(repo data.CompanyRepoer) AppOption

WithCompanyRepo injects a CompanyRepoer implementation.

func WithCustomerRepo

func WithCustomerRepo(repo data.CustomerRepoer) AppOption

WithCustomerRepo injects a CustomerRepoer implementation.

func WithDiscountRepo

func WithDiscountRepo(repo data.DiscountRepoer) AppOption

WithDiscountRepo injects a DiscountRepoer implementation.

func WithEnqueuer

func WithEnqueuer(e data.Enqueuer) AppOption

WithEnqueuer injects a custom Enqueuer implementation. The OSS default is nil (no background jobs). Pass repo.NewGoqiteEnqueuer(db) for the SQLite-backed implementation. Pro injects a River/PostgreSQL adapter.

func WithExpenseRepo

func WithExpenseRepo(repo data.ExpenseRepoer) AppOption

WithExpenseRepo injects an ExpenseRepoer implementation.

func WithFileRepo

func WithFileRepo(repo data.FileRepoer) AppOption

WithFileRepo injects a FileRepoer implementation.

func WithFileStorage

func WithFileStorage(storage data.FileStorage) AppOption

WithFileStorage injects a FileStorage implementation. The OSS default (see cmd/server.go) is repo.NewLocalFSStorage; pass repo.NewS3Storage for an S3-compatible backend.

func WithInventoryRepo

func WithInventoryRepo(repo data.InventoryRepoer) AppOption

WithInventoryRepo injects an InventoryRepoer implementation.

func WithInvoiceRepo added in v0.5.1

func WithInvoiceRepo(repo data.InvoiceRepoer) AppOption

WithInvoiceRepo injects an InvoiceRepoer implementation.

func WithJobRunner

func WithJobRunner(r jobRunner) AppOption

WithJobRunner injects the background job runner. Use repo.NewGoqiteEnqueuer + worker.NewRunner to build one, then pass both here. The runner is started as a goroutine when Start() is called.

func WithOrderRepo

func WithOrderRepo(repo data.OrderRepoer) AppOption

WithOrderRepo injects an OrderRepoer implementation.

func WithPaymentMethods

func WithPaymentMethods(methods []model.PaymentMethod) AppOption

WithPaymentMethods sets the allowed payment methods for checkout. Defaults to model.DefaultPaymentMethods if not provided.

func WithProductRepo

func WithProductRepo(repo data.ProductRepoer) AppOption

WithProductRepo injects a ProductRepoer implementation.

func WithRegistry

func WithRegistry(r *plugin.Registry) AppOption

WithRegistry injects the plugin event registry. Build with plugin.NewRegistry + plugin.Load, then pass here.

func WithReportsRepo

func WithReportsRepo(repo data.ReportsQuerier) AppOption

WithReportsRepo injects a ReportsQuerier implementation.

func WithSessionRepo

func WithSessionRepo(repo data.SessionRepoer) AppOption

WithSessionRepo injects a SessionRepoer implementation.

func WithStationRepo

func WithStationRepo(repo data.POSStationRepoer) AppOption

WithStationRepo injects a POSStationRepoer implementation.

func WithSupplierPaymentRepo

func WithSupplierPaymentRepo(repo data.SupplierPaymentRepoer) AppOption

WithSupplierPaymentRepo injects a SupplierPaymentRepoer implementation.

func WithSupplierRepo

func WithSupplierRepo(repo data.SupplierRepoer) AppOption

WithSupplierRepo injects a SupplierRepoer implementation.

func WithUserRepo

func WithUserRepo(repo data.UserRepoer) AppOption

WithUserRepo injects a UserRepoer implementation. The default (if not provided) is a nil repo — the serve command must supply one.

type OkPOSApp

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

OkPOSApp holds the fully-wired application.

func NewOkPOSApp added in v0.1.7

func NewOkPOSApp(e *echo.Echo, cfg *config.Config, opts ...AppOption) *OkPOSApp

NewOkPOSApp wires dependencies, registers middleware, validator, and routes. Pass AppOption functions to inject repo implementations.

func (*OkPOSApp) Config

func (a *OkPOSApp) Config() *config.Config

Config returns the application configuration.

func (*OkPOSApp) Echo

func (a *OkPOSApp) Echo() *echo.Echo

Echo returns the underlying Echo instance (useful for testing).

func (*OkPOSApp) Server

func (a *OkPOSApp) Server() *http.Server

Server returns a configured *http.Server.

func (*OkPOSApp) Start

func (a *OkPOSApp) Start() error

Start runs the HTTP server and (if configured) the background job runner. It blocks until the server stops; the runner is stopped when Start returns.

Jump to

Keyboard shortcuts

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