diff --git a/crm/rest/field.go b/crm/rest/field.go index c1bf651b2..1d33b4f72 100644 --- a/crm/rest/field.go +++ b/crm/rest/field.go @@ -22,10 +22,8 @@ type ( } ) -func (Field) New() *Field { - return &Field{ - field: service.Field(), - } +func (Field) New(field service.FieldService) *Field { + return &Field{field} } func (s *Field) List(ctx context.Context, _ *request.FieldList) (interface{}, error) { diff --git a/crm/rest/module.go b/crm/rest/module.go index 4ba36c886..66fdfeebc 100644 --- a/crm/rest/module.go +++ b/crm/rest/module.go @@ -20,11 +20,8 @@ type ( } ) -func (Module) New() *Module { - return &Module{ - module: service.Module(), - content: service.Content(), - } +func (Module) New(module service.ModuleService, content service.ContentService) *Module { + return &Module{module, content} } func (s *Module) List(ctx context.Context, r *request.ModuleList) (interface{}, error) { diff --git a/crm/rest/router.go b/crm/rest/router.go index d7e48891d..e98494bf4 100644 --- a/crm/rest/router.go +++ b/crm/rest/router.go @@ -3,13 +3,20 @@ package rest import ( "github.com/crusttech/crust/auth" "github.com/crusttech/crust/crm/rest/handlers" + "github.com/crusttech/crust/crm/service" "github.com/go-chi/chi" ) func MountRoutes(jwtAuth auth.TokenEncoder) func(chi.Router) { var ( - field = Field{}.New() - module = Module{}.New() + fieldSvc = service.Field() + moduleSvc = service.Module() + contentSvc = service.Content() + ) + + var ( + field = Field{}.New(fieldSvc) + module = Module{}.New(moduleSvc, contentSvc) ) // @todo pass jwtAuth to auth handlers (signUp) for JWT generation