Skip to content

Commit

Permalink
Updated packages, formatting, new console log for http start
Browse files Browse the repository at this point in the history
  • Loading branch information
pkritiotis committed May 1, 2024
1 parent b69aecf commit d77b413
Show file tree
Hide file tree
Showing 93 changed files with 3,490 additions and 1,610 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/pkritiotis/go-climb-clean-architecture-example
go 1.16

require (
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/stretchr/testify v1.7.0
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/stretchr/testify v1.9.0
)
26 changes: 17 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8 changes: 4 additions & 4 deletions internal/app/crag/commands/addcrag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/uuid"
)

//AddCragRequest Model of CreateCragRequestHandler
// AddCragRequest Model of CreateCragRequestHandler
type AddCragRequest struct {
Name string
Desc string
Country string
}

//CreateCragRequestHandler Struct that allows handling AddCragRequest
// CreateCragRequestHandler Struct that allows handling AddCragRequest
type CreateCragRequestHandler interface {
Handle(command AddCragRequest) error
}
Expand All @@ -26,12 +26,12 @@ type addCragRequestHandler struct {
notificationService notification.Service
}

//NewAddCragRequestHandler Initializes an AddCommandHandler
// NewAddCragRequestHandler Initializes an AddCommandHandler
func NewAddCragRequestHandler(uuidProvider uuid.Provider, timeProvider time.Provider, repo crag.Repository, notificationService notification.Service) CreateCragRequestHandler {
return addCragRequestHandler{uuidProvider: uuidProvider, timeProvider: timeProvider, repo: repo, notificationService: notificationService}
}

//Handle Handles the AddCragRequest
// Handle Handles the AddCragRequest
func (h addCragRequestHandler) Handle(req AddCragRequest) error {
c := crag.Crag{
ID: h.uuidProvider.NewUUID(),
Expand Down
6 changes: 3 additions & 3 deletions internal/app/crag/commands/addcrag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package commands

import (
"errors"
"testing"
"time"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app/notification"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
timeUtil "github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/time"
uuidUtil "github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/uuid"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestAddCragCommandHandler_Handle(t *testing.T) {
Expand Down Expand Up @@ -178,7 +179,6 @@ func TestAddCragCommandHandler_Handle(t *testing.T) {

err := h.Handle(tt.args.request)
assert.Equal(t, err, tt.err)

})
}
}
Expand Down
10 changes: 5 additions & 5 deletions internal/app/crag/commands/deletecrag.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package commands

import (
"fmt"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
)

//DeleteCragRequest Command Model
// DeleteCragRequest Command Model
type DeleteCragRequest struct {
CragID uuid.UUID
}

//DeleteCragRequestHandler Handler Struct with Dependencies
// DeleteCragRequestHandler Handler Struct with Dependencies
type DeleteCragRequestHandler interface {
Handle(command DeleteCragRequest) error
}
Expand All @@ -20,12 +21,12 @@ type deleteCragRequestHandler struct {
repo crag.Repository
}

//NewDeleteCragRequestHandler Handler constructor
// NewDeleteCragRequestHandler Handler constructor
func NewDeleteCragRequestHandler(repo crag.Repository) DeleteCragRequestHandler {
return deleteCragRequestHandler{repo: repo}
}

//Handle Handlers the DeleteCragRequest request
// Handle Handlers the DeleteCragRequest request
func (h deleteCragRequestHandler) Handle(command DeleteCragRequest) error {
crag, err := h.repo.GetByID(command.CragID)
if crag == nil {
Expand All @@ -35,5 +36,4 @@ func (h deleteCragRequestHandler) Handle(command DeleteCragRequest) error {
return err
}
return h.repo.Delete(command.CragID)

}
3 changes: 2 additions & 1 deletion internal/app/crag/commands/deletecrag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package commands
import (
"errors"
"fmt"
"testing"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"github.com/stretchr/testify/assert"
"testing"
)

func TestDeleteCragCommandHandler_Handle(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions internal/app/crag/commands/updatecrag.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ package commands

import (
"fmt"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
)

//UpdateCragRequest Update Model
// UpdateCragRequest Update Model
type UpdateCragRequest struct {
ID uuid.UUID
Name string
Desc string
Country string
}

//UpdateCragRequestHandler Contains the dependencies of the handler
// UpdateCragRequestHandler Contains the dependencies of the handler
type UpdateCragRequestHandler interface {
Handle(command UpdateCragRequest) error
}
Expand All @@ -23,12 +24,12 @@ type updateCragRequestHandler struct {
repo crag.Repository
}

//NewUpdateCragRequestHandler Constructor
// NewUpdateCragRequestHandler Constructor
func NewUpdateCragRequestHandler(repo crag.Repository) UpdateCragRequestHandler {
return updateCragRequestHandler{repo: repo}
}

//Handle Handles the update request
// Handle Handles the update request
func (h updateCragRequestHandler) Handle(command UpdateCragRequest) error {
crag, err := h.repo.GetByID(command.ID)
if crag == nil {
Expand All @@ -43,5 +44,4 @@ func (h updateCragRequestHandler) Handle(command UpdateCragRequest) error {
crag.Country = command.Country

return h.repo.Update(*crag)

}
5 changes: 3 additions & 2 deletions internal/app/crag/commands/updatecrag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package commands
import (
"errors"
"fmt"
"testing"
"time"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestNewUpdateCragCommandHandler(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions internal/app/crag/queries/getallcrags.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package queries

import (
"time"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"time"
)

// GetAllCragsResult is the result of the GetAllCragsRequest Query
Expand All @@ -15,7 +16,7 @@ type GetAllCragsResult struct {
CreatedAt time.Time
}

//GetAllCragsRequestHandler Contains the dependencies of the Handler
// GetAllCragsRequestHandler Contains the dependencies of the Handler
type GetAllCragsRequestHandler interface {
Handle() ([]GetAllCragsResult, error)
}
Expand All @@ -24,14 +25,13 @@ type getAllCragsRequestHandler struct {
repo crag.Repository
}

//NewGetAllCragsRequestHandler Handler constructor
// NewGetAllCragsRequestHandler Handler constructor
func NewGetAllCragsRequestHandler(repo crag.Repository) GetAllCragsRequestHandler {
return getAllCragsRequestHandler{repo: repo}
}

//Handle Handles the query
// Handle Handles the query
func (h getAllCragsRequestHandler) Handle() ([]GetAllCragsResult, error) {

res, err := h.repo.GetAll()
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/app/crag/queries/getallcrags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package queries

import (
"errors"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"testing"

"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)
Expand Down
11 changes: 6 additions & 5 deletions internal/app/crag/queries/getcrag.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package queries

import (
"time"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"time"
)

//GetCragRequest Model of the Handler
// GetCragRequest Model of the Handler
type GetCragRequest struct {
CragID uuid.UUID
}
Expand All @@ -20,7 +21,7 @@ type GetCragResult struct {
CreatedAt time.Time
}

//GetCragRequestHandler provides an interfaces to handle a GetCragRequest and return a *GetCragResult
// GetCragRequestHandler provides an interfaces to handle a GetCragRequest and return a *GetCragResult
type GetCragRequestHandler interface {
Handle(query GetCragRequest) (*GetCragResult, error)
}
Expand All @@ -29,12 +30,12 @@ type getCragRequestHandler struct {
repo crag.Repository
}

//NewGetCragRequestHandler Handler Constructor
// NewGetCragRequestHandler Handler Constructor
func NewGetCragRequestHandler(repo crag.Repository) GetCragRequestHandler {
return getCragRequestHandler{repo: repo}
}

//Handle Handlers the GetCragRequest query
// Handle Handlers the GetCragRequest query
func (h getCragRequestHandler) Handle(query GetCragRequest) (*GetCragResult, error) {
crag, err := h.repo.GetByID(query.CragID)
var result *GetCragResult
Expand Down
5 changes: 3 additions & 2 deletions internal/app/crag/queries/getcrag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package queries

import (
"errors"
"testing"
"time"

"github.com/google/uuid"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestGetCragQueryHandler_Handle(t *testing.T) {
Expand Down
11 changes: 6 additions & 5 deletions internal/app/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ import (
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/uuid"
)

//Queries Contains all available query handlers of this app
// Queries Contains all available query handlers of this app
type Queries struct {
GetAllCragsHandler queries.GetAllCragsRequestHandler
GetCragHandler queries.GetCragRequestHandler
}

//Commands Contains all available command handlers of this app
// Commands Contains all available command handlers of this app
type Commands struct {
CreateCragHandler commands.CreateCragRequestHandler
UpdateCragHandler commands.UpdateCragRequestHandler
DeleteCragHandler commands.DeleteCragRequestHandler
}

//CragServices Contains the grouped queries and commands of the app layer
// CragServices Contains the grouped queries and commands of the app layer
type CragServices struct {
Queries Queries
Commands Commands
}

//Services contains all exposed services of the application layer
// Services contains all exposed services of the application layer
type Services struct {
CragServices CragServices
}
Expand All @@ -46,5 +46,6 @@ func NewServices(cragRepo crag.Repository, ns notification.Service, up uuid.Prov
UpdateCragHandler: commands.NewUpdateCragRequestHandler(cragRepo),
DeleteCragHandler: commands.NewDeleteCragRequestHandler(cragRepo),
},
}}
},
}
}
3 changes: 2 additions & 1 deletion internal/app/services_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package app

import (
"testing"

"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app/crag/commands"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app/crag/queries"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app/notification"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/time"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/uuid"
"github.com/stretchr/testify/assert"
"testing"
)

func TestNewApp(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/domain/crag/crag.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package crag

import (
"github.com/google/uuid"
"time"

"github.com/google/uuid"
)

//Crag Model that represents the Crag
// Crag Model that represents the Crag
type Crag struct {
ID uuid.UUID
Name string
Expand Down
Loading

0 comments on commit d77b413

Please sign in to comment.