package service

import (
	"context"

	"bsm/full/module/base/initial/internal/server"
	pb "bsm/full/module/base/initial/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.RegisterCheckHandlerServer(ctx, options.Gateway, server.NewCheckServer()); err != nil {
		return err
	}
	if err := pb.RegisterDataHandlerServer(ctx, options.Gateway, server.NewDataServer()); err != nil {
		return err
	}
	return nil
}
