upd(crm): inject service dependencies like sam
This commit is contained in:
+2
-4
@@ -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) {
|
||||
|
||||
+2
-5
@@ -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) {
|
||||
|
||||
+9
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user