package service

import (
	"context"

	"bsm/full/module/base/cloud/internal/server"
	pb "bsm/full/module/base/cloud/pb"
	gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
	"google.golang.org/grpc"
)

type ExposeOptions struct {
	Dependencies
	GRPC    *grpc.Server
	Gateway *gwRuntime.ServeMux
}

func Expose(options ExposeOptions) error {
	applyDependencies(options.Dependencies)
	server.New(options.GRPC)

	ctx := context.Background()
	if err := pb.RegisterAlbumHandlerServer(ctx, options.Gateway, server.NewAlbumServer()); err != nil {
		return err
	}
	if err := pb.RegisterBookmarkHandlerServer(ctx, options.Gateway, server.NewBookmarkServer()); err != nil {
		return err
	}
	if err := pb.RegisterDiskHandlerServer(ctx, options.Gateway, server.NewDiskServer()); err != nil {
		return err
	}
	if err := pb.RegisterNoteHandlerServer(ctx, options.Gateway, server.NewNoteServer()); err != nil {
		return err
	}
	if err := pb.RegisterPrivateHandlerServer(ctx, options.Gateway, server.NewPrivateServer()); err != nil {
		return err
	}
	if err := pb.RegisterShareHandlerServer(ctx, options.Gateway, server.NewShareServer()); err != nil {
		return err
	}
	if err := pb.RegisterSpaceHandlerServer(ctx, options.Gateway, server.NewSpaceServer()); err != nil {
		return err
	}
	return nil
}
