user

package
v0.0.0-...-e46c3b8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(func(lc fx.Lifecycle, logger *zap.Logger, validate *validator.Validate) (access.Service, prime.Service, error) {
		db, err := open.Open(open.DB{
			User: env.Get(usernameKey),
			Pass: env.Get(passwordKey),
			Name: env.Get(dbNameKey),
		})
		if err != nil {
			return nil, nil, err
		}
		lc.Append(fx.Hook{
			OnStart: func(ctx context.Context) error {
				return open.Ping(ctx, db)
			},
			OnStop: miscfx.IgnoreContext(db.Close),
		})
		userService := user.Use(
			repo.UserRepoForDB(db),
			logger,
			validate,
		)
		accessService := access.Use(
			repo.AccessRepoForDB(db),
			logger,
			[]byte(env.Get(refreshSecretKey)),
			[]byte(env.Get(accessSecretKey)),
		)
		lc.Append(miscfx.CronJob(func() {
			ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
			defer cancel()
			accessService.RemExpired(ctx)
		}, time.Minute))
		return accessService, prime.Use(userService, accessService), nil
	}),
	fx.Invoke(data.RegisterPasswordValidator),
	fx.Invoke(routes.Register),
)

Module bundles fx.Options for the user Fx Module.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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