Skip to content

Commit

Permalink
refact: move handlers into handlers dir (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn authored Dec 19, 2024
1 parent b1d9b19 commit 3a0cba7
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions server/rpc/v1/auth.go → server/rpc/handlers/v1/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func (h *authHandler) Signup(ctx context.Context, req *connect.Request[apiv1.Sig
if err := h.repo.NewTx(ctx, func(tx repo.Tx) error {
auth, err := tx.CreateAuth(ctx, emailAddress, req.Msg.GetPassword())
if err != nil {
if errors.Is(err, repo.ErrAuthEmailExists) {
log.Warn("email exists")
return nil
}
return fmt.Errorf("create auth: %w", err)
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
v1 "github.com/crlssn/getstronger/server/gen/proto/api/v1"
"github.com/crlssn/getstronger/server/gen/proto/api/v1/apiv1connect"
"github.com/crlssn/getstronger/server/repo"
rpc "github.com/crlssn/getstronger/server/rpc/v1"
handlers "github.com/crlssn/getstronger/server/rpc/handlers/v1"
"github.com/crlssn/getstronger/server/testing/container"
"github.com/crlssn/getstronger/server/testing/factory"
"github.com/crlssn/getstronger/server/xcontext"
Expand All @@ -37,7 +37,7 @@ func (s *exerciseSuite) SetupSuite() {
ctx := context.Background()
s.testContainer = container.NewContainer(ctx)
s.testFactory = factory.NewFactory(s.testContainer.DB)
s.handler = rpc.NewExerciseHandler(repo.New(s.testContainer.DB))
s.handler = handlers.NewExerciseHandler(repo.New(s.testContainer.DB))

s.T().Cleanup(func() {
if err := s.testContainer.Terminate(ctx); err != nil {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
apiv1 "github.com/crlssn/getstronger/server/gen/proto/api/v1"
"github.com/crlssn/getstronger/server/gen/proto/api/v1/apiv1connect"
"github.com/crlssn/getstronger/server/repo"
rpc "github.com/crlssn/getstronger/server/rpc/v1"
handlers "github.com/crlssn/getstronger/server/rpc/handlers/v1"
"github.com/crlssn/getstronger/server/testing/container"
"github.com/crlssn/getstronger/server/testing/factory"
"github.com/crlssn/getstronger/server/xcontext"
Expand All @@ -40,7 +40,7 @@ func (s *notificationSuite) SetupSuite() {
ctx := context.Background()
s.testContainer = container.NewContainer(ctx)
s.testFactory = factory.NewFactory(s.testContainer.DB)
s.handler = rpc.NewNotificationHandler(repo.New(s.testContainer.DB), nil)
s.handler = handlers.NewNotificationHandler(repo.New(s.testContainer.DB), nil)

s.T().Cleanup(func() {
if err := s.testContainer.Terminate(ctx); err != nil {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions server/rpc/server/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (

"github.com/crlssn/getstronger/server/config"
"github.com/crlssn/getstronger/server/gen/proto/api/v1/apiv1connect"
handlers "github.com/crlssn/getstronger/server/rpc/handlers/v1"
"github.com/crlssn/getstronger/server/rpc/interceptors"
"github.com/crlssn/getstronger/server/rpc/middlewares"
v1 "github.com/crlssn/getstronger/server/rpc/v1"
"github.com/crlssn/getstronger/server/stream"
)

Expand All @@ -27,13 +27,13 @@ func Module() fx.Option {
interceptors.Module(),
fx.Provide(
registerHandlers,
v1.NewAuthHandler,
v1.NewFeedHandler,
v1.NewUserHandler,
v1.NewRoutineHandler,
v1.NewWorkoutHandler,
v1.NewExerciseHandler,
v1.NewNotificationHandler,
handlers.NewAuthHandler,
handlers.NewFeedHandler,
handlers.NewUserHandler,
handlers.NewRoutineHandler,
handlers.NewWorkoutHandler,
handlers.NewExerciseHandler,
handlers.NewNotificationHandler,
middlewares.New,
),
fx.Invoke(
Expand Down

0 comments on commit 3a0cba7

Please sign in to comment.