app

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("app",
	repos.NewFxMongoRepo[*entities.Account]("accounts", "acc", entities.AccountIndices),
	repos.NewFxMongoRepo[*entities.Invitation]("invitations", "invite", entities.InvitationIndices),

	fx.Provide(func(client AuthCacheClient) kv.Repo[*entities.Invitation] {
		return kv.NewRepo[*entities.Invitation](client)
	}),

	fx.Provide(func(conn ConsoleClient) console.ConsoleClient {
		return console.NewConsoleClient(conn)
	}),

	fx.Provide(func(conn IAMClient) iam.IAMClient {
		return iam.NewIAMClient(conn)
	}),

	fx.Provide(func(conn CommsClient) comms.CommsClient {
		return comms.NewCommsClient(conn)
	}),

	fx.Provide(func(conn AuthClient) auth.AuthClient {
		return auth.NewAuthClient(conn)
	}),

	fx.Provide(func(conn ContainerRegistryClient) container_registry.ContainerRegistryClient {
		return container_registry.NewContainerRegistryClient(conn)
	}),

	fx.Provide(func(d domain.Domain) accounts.AccountsServer {
		return &accountsGrpcServer{d: d}
	}),

	fx.Invoke(func(d domain.Domain, gserver AccountsGrpcServer) {
		registerAccountsGRPCServer(gserver, d)
	}),

	domain.Module,

	fx.Invoke(
		func(server httpServer.Server, d domain.Domain, env *env.Env, sessionRepo kv.Repo[*common.AuthSession]) {
			gqlConfig := generated.Config{Resolvers: graph.NewResolver(d)}

			gqlConfig.Directives.IsLoggedInAndVerified = func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
				sess := httpServer.GetSession[*common.AuthSession](ctx)
				if sess == nil {
					return nil, fiber.ErrUnauthorized
				}

				if !sess.UserVerified {
					return nil, fiber.ErrForbidden
				}

				return next(context.WithValue(ctx, "kloudlite-user-session", *sess))
			}

			schema := generated.NewExecutableSchema(gqlConfig)
			server.SetupGraphqlServer(schema,
				httpServer.NewSessionMiddleware(
					sessionRepo,
					constants.CookieName,
					env.CookieDomain,
					constants.CacheSessionPrefix,
				),
			)
		},
	),
)

Functions

This section is empty.

Types

type AccountsGrpcServer

type AccountsGrpcServer grpc.Server

type AuthCacheClient

type AuthCacheClient kv.Client

type AuthClient

type AuthClient grpc.Client

type CommsClient

type CommsClient grpc.Client

type ConsoleClient

type ConsoleClient grpc.Client

type ContainerRegistryClient

type ContainerRegistryClient grpc.Client

type IAMClient

type IAMClient grpc.Client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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