reactions

package module
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

modules/reactions

Official Lesstruct module: reader gestures on every post — Clap (repeatable applause, capped per reader per post, with a public count) and Read Later (a private, one-per-post mark feeding a personal reading list).

Layout (module template)

module.go            # kernel.Module + Migrator + RouteProvider + PublicRouteProvider
migrations/          # {sqlite,postgresql,mysql}/000001_reactions.{up,down}.sql (embed)
api/                 # browser + public handlers (kernel httpx envelope) + dto
domain/              # service, entities, validation, repository interfaces
domain/mocks/        # ReactionRepository testify mock (via make mock)
store/               # single-source repository on kernel.Dialect
admin/               # admin-shell manifest (read-later entry)
testutil/            # kernel fixture for module tests

Handlers

Both browser and public surfaces are served from this module via RouteProvider (authenticated /api/v1/...) and PublicRouteProvider (anonymous /api/v1/public/...). No routes.go or HandlerSet change is needed: core discovers both interfaces through the module registry.

Migrations

Each module versions independently in its own schema_migrations_<module> table (see internal/database/modules.go), so modules install and upgrade without touching the core sequence. Module migrations stay idempotent (CREATE TABLE IF NOT EXISTS).

Documentation

Overview

Package reactions is the official reader-gesture module: Clap (repeatable applause, capped per reader per post, with a public count) and Read Later (a private, one-per-post mark feeding a personal reading list).

Index

Constants

View Source
const (
	// Name is the registry key for this module.
	Name = "reactions"

	// Version is the module version reported via Module.Version.
	Version = "0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module is the reactions kernel module.

func New

func New(opts ...Option) *Module

New builds the module, adopting the composition root's wiring. The handler is built once here so routes serve the same instance.

func (*Module) AdminManifest

func (m *Module) AdminManifest() kernel.AdminExtensionManifest

AdminManifest declares this module's admin-shell extensions: the read-later navigation entry.

func (*Module) Handler

func (m *Module) Handler() *api.ReactionHandler

Handler exposes the reaction handler for composition-root wiring.

func (*Module) Init

func (m *Module) Init(_ kernel.Kernel) error

Init validates presence of the adopted seams. Migration execution is core-driven (it needs the live *sql.DB, which modules never touch directly).

func (*Module) Migrations

func (m *Module) Migrations() fs.FS

Migrations returns the embedded migration filesystem, laid out per driver ({sqlite,postgresql,mysql}/NNN_name.{up,down}.sql). The core runner tracks each module in its own schema_migrations_<module> table.

func (*Module) Name

func (m *Module) Name() string

Name returns the registry key.

func (*Module) Optional

func (m *Module) Optional() []string

Optional lists soft dependencies. None.

func (*Module) RegisterPublicRoutes

func (m *Module) RegisterPublicRoutes(router chi.Router)

RegisterPublicRoutes mounts the anonymous reaction surface. Core passes the public router (rate-limited, no auth chain).

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(router chi.Router)

RegisterRoutes mounts the authenticated reaction surface. Core passes the protected router (CSRF + JWT + 1MB pre-chained).

func (*Module) Requires

func (m *Module) Requires() []string

Requires lists hard dependencies. Reactions reference content items and users loosely (owner/content IDs without foreign-key enforcement); users is declared so account deletion cleans up reaction rows in dependency order.

func (*Module) Service

func (m *Module) Service() *reactiondomain.Service

Service exposes the adopted domain service for composition-root wiring. It stays valid for the module's lifetime.

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown releases module resources. There are none beyond memory.

func (*Module) Version

func (m *Module) Version() string

Version returns the module version.

type Option

type Option func(*Module)

Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module that serves nothing (handlers built over nil dependencies must not be invoked).

func WithContentResolver

func WithContentResolver(resolve api.ContentResolver) Option

WithContentResolver attaches the published-content lookup for slug-scoped handlers. Without one content-scoped endpoints fail at lookup time.

func WithService

func WithService(service *reactiondomain.Service) Option

WithService adopts the reactions domain service (composition root). The same instance backs the browser and public handlers.

Directories

Path Synopsis
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for reactions.
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for reactions.
api
Package store is the single-source reaction repository: one implementation against *sql.DB plus a kernel Dialect, replacing per-driver copies.
Package store is the single-source reaction repository: one implementation against *sql.DB plus a kernel Dialect, replacing per-driver copies.
Package testutil provides the kernel fixture module tests run against.
Package testutil provides the kernel fixture module tests run against.

Jump to

Keyboard shortcuts

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