fx

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OptionPGAdminRepository         = fx.Provide(fx.Annotate(pg.NewAdminRepository, fx.As(new(repository.Admin))))
	OptionPGConfigurationRepository = fx.Provide(fx.Annotate(pg.NewConfigurationRepository, fx.As(new(repository.Configuration))))
	OptionPGMenuRepository          = fx.Provide(fx.Annotate(pg.NewMenuRepository, fx.As(new(repository.Menu))))
	OptionPGNodeRepository          = fx.Provide(fx.Annotate(pg.NewNodeRepository, fx.As(new(repository.Node))))
	OptionPGPageRepository          = fx.Provide(fx.Annotate(pg.NewPageRepository, fx.As(new(repository.Page))))
	OptionPGSiteRepository          = fx.Provide(fx.Annotate(pg.NewSiteRepository, fx.As(new(repository.Site))))
	OptionPGTemplateRepository      = fx.Provide(fx.Annotate(pg.NewTemplateRepository, fx.As(new(repository.Template))))
	OptionPGSessionRepository       = fx.Provide(NewPGSessionRepository)

	OptionThemeRepository = fx.Provide(repository.NewThemeRepository)

	OptionDecorateCacheConfigurationRepository = fx.Decorate(
		fx.Annotate(
			cacherepo.NewConfigurationRepository,
			fx.ParamTags("", `name:"repository-cache"`),
		),
	)
	OptionDecorateFallbackConfigurationRepository = fx.Decorate(func(r repository.Configuration) repository.Configuration {
		return fallback.NewConfigurationRepository(r, model.NewConfiguration())
	})
	OptionDecorateCacheSiteRepository = fx.Decorate(
		fx.Annotate(
			cacherepo.NewSiteRepository,
			fx.ParamTags("", `name:"repository-cache"`),
		),
	)
	OptionDecorateCachePageRepository = fx.Decorate(
		fx.Annotate(
			cacherepo.NewPageRepository,
			fx.ParamTags("", `name:"repository-cache"`),
		),
	)
	OptionDecorateCacheTemplateRepository = fx.Decorate(
		fx.Annotate(
			cacherepo.NewTemplateRepository,
			fx.ParamTags("", `name:"repository-cache"`),
		),
	)
	OptionDecorateFSTemplateRepository = fx.Decorate(
		fx.Annotate(
			func(r repository.Template, fss []fs.FS) repository.Template {
				for _, fsys := range fss {
					r = fsrepo.NewTemplateRepository(r, fsys)
				}
				return r
			},
			fx.ParamTags("", `name:"template-fs"`),
		),
	)
	OptionDecorateCacheMenuRepository = fx.Decorate(
		fx.Annotate(
			cacherepo.NewMenuRepository,
			fx.ParamTags("", `name:"repository-cache"`),
		),
	)
	OptionDecorateCacheNodeRepository = fx.Decorate(
		fx.Annotate(
			cacherepo.NewNodeRepository,
			fx.ParamTags("", `name:"repository-cache"`),
		),
	)

	OptionSessionManager = fx.Provide(NewSessionManager)

	OptionSeeder  = fx.Provide(fx.Annotate(cms.NewDefaultSeeder, fx.As(new(cms.Seeder))))
	OptionMenu    = fx.Provide(fx.Annotate(cms.NewDefaultMenu, fx.As(new(cms.Menu))))
	OptionMatcher = fx.Provide(
		fx.Annotate(
			cms.NewDefaultMatcher,
			fx.As(new(cms.Matcher)),
			fx.ParamTags(`group:"menu-voter"`),
		),
	)
	OptionURLVoter = fx.Provide(
		fx.Annotate(
			cms.NewURLVoter,
			fx.As(new(cms.Voter)),
			fx.ResultTags(`group:"menu-voter"`),
		),
	)

	OptionSiteSelector = fx.Provide(
		fx.Annotate(
			cms.NewDefaultSiteSelector,
			fx.As(new(cms.SiteSelector)),
		),
	)
	OptionPageHandler = fx.Provide(
		fx.Annotate(
			cms.NewDefaultPageHandler,
			fx.As(new(cms.PageHandler)),
		),
	)
	OptionPageCreateHandler = fx.Provide(cms.NewPageCreateHandler)
	OptionErrorHandler      = fx.Provide(cms.NewErrorHandler)
	OptionHTTPErrorHandler  = fx.Provide(func(h *cms.ErrorHandler) echo.HTTPErrorHandler { return h.Handle })
	OptionErrorResolver     = fx.Provide(cms.ErrorResolver)
	OptionRenderer          = fx.Provide(fx.Annotate(cms.NewRenderer, fx.As(new(echo.Renderer))))

	OptionThemeFuncMap = fx.Provide(fx.Annotate(FuncMap, fx.ResultTags(`group:"theme-func-map"`)))
	OptionThemeLoader  = fx.Provide(fx.Annotate(theme.NewRepositoryLoader, fx.As(new(theme.Loader))))

	OptionAuthorizer         = fx.Provide(cms.Authorizer)
	OptionAPIAuthorizer      = fx.Provide(cms.APIAuthorizer)
	OptionBasicAuthValidator = fx.Provide(cms.BasicAuthValidator)
	OptionJWTAuthValidator   = fx.Provide(func(repo repository.Admin, cfg JWTConfig) middleware.KeyAuthValidator {
		cfg.setDefaults()

		return cms.JWTAuthValidator(repo, cfg.Secret)
	})

	OptionSiteSelectorMiddleware = fx.Provide(echox.AsMiddleware(SiteSelectorMiddleware))
	OptionPageSelectorMiddleware = fx.Provide(echox.AsMiddleware(PageSelectorMiddleware))
	OptionHybridPageMiddleware   = fx.Provide(echox.AsMiddleware(HybridPageMiddleware))
	OptionSessionMiddleware      = fx.Provide(echox.AsMiddleware(SessionMiddleware))

	OptionAdminAuthAPI     = fx.Provide(api.AsHandler(NewAuthAPI, fx.ParamTags(`name:"admin-auth-cache"`)))
	OptionAdminAPI         = fx.Provide(api.AsHandler(NewAdminAPI))
	OptionConfigurationAPI = fx.Provide(api.AsHandler(NewConfigurationAPI))
	OptionSiteAPI          = fx.Provide(api.AsHandler(NewSiteAPI))
	OptionPageAPI          = fx.Provide(api.AsHandler(NewPageAPI))
	OptionTemplateAPI      = fx.Provide(api.AsHandler(NewTemplateAPI))
	OptionMenuAPI          = fx.Provide(api.AsHandler(NewMenuAPI))
	OptionNodeAPI          = fx.Provide(api.AsHandler(NewNodeAPI))
)

Functions

func FuncMap

func FuncMap(pageRepo repository.Page, menu cms.Menu, matcher cms.Matcher) theme.FuncMap

func HybridPageMiddleware

func HybridPageMiddleware(pageHandler cms.PageHandler, cfgRepository repository.Configuration) echox.Middleware

func NewAdminAPI

func NewAdminAPI(r repository.Admin) v1.Admin

func NewAuthAPI

func NewAuthAPI(cache cms.Cache, r repository.Admin, cfg JWTConfig, logger *zap.Logger) v1.Auth

func NewConfigurationAPI

func NewConfigurationAPI(r repository.Configuration) v1.Configuration

func NewMenuAPI

func NewMenuAPI(r repository.Menu) v1.Menu

func NewNodeAPI

func NewNodeAPI(r repository.Node) v1.Node

func NewPGSessionRepository added in v0.0.9

func NewPGSessionRepository(cfg middleware.SessionConfig, lc fx.Lifecycle, db *sql.DB) scs.Store

func NewPageAPI

func NewPageAPI(r repository.Page, cfg repository.Configuration) v1.Page

func NewSessionManager added in v0.0.9

func NewSessionManager(params SessionManagerParams) *scs.SessionManager

func NewSiteAPI

func NewSiteAPI(r repository.Site) v1.Site

func NewTemplateAPI

func NewTemplateAPI(r repository.Template) v1.Template

func PageSelectorMiddleware

func PageSelectorMiddleware(params PageSelectorParams) echox.Middleware

func SeederBoot

func SeederBoot(seeder cms.Seeder, lc fx.Lifecycle)

func SessionMiddleware added in v0.0.9

func SessionMiddleware(cfg middleware.SessionConfig, manager *scs.SessionManager) echox.Middleware

func SiteSelectorMiddleware

func SiteSelectorMiddleware(siteSelector cms.SiteSelector, cfgRepository repository.Configuration) echox.Middleware

Types

type JWTConfig

type JWTConfig struct {
	Secret               string        `json:"secret,omitempty" yaml:"secret,omitempty"`
	AccessTokenDuration  time.Duration `json:"accessTokenDuration,omitempty" yaml:"accessTokenDuration,omitempty"`
	RefreshTokenDuration time.Duration `json:"refreshTokenDuration,omitempty" yaml:"refreshTokenDuration,omitempty"`
}

type PageSelectorParams

type PageSelectorParams struct {
	fx.In
	PageHandler    cms.PageHandler
	CfgRepository  repository.Configuration
	PageRepository repository.Page
}

type SessionManagerParams added in v0.0.9

type SessionManagerParams struct {
	fx.In
	Config middleware.SessionConfig
	Store  scs.Store
}

Jump to

Keyboard shortcuts

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