-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
31 lines (27 loc) · 1.01 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"github.com/hmsayem/clean-architecture-implementation/cache"
"github.com/hmsayem/clean-architecture-implementation/controller"
"github.com/hmsayem/clean-architecture-implementation/repository"
"github.com/hmsayem/clean-architecture-implementation/router"
"github.com/hmsayem/clean-architecture-implementation/service"
"log"
"os"
)
var ()
func main() {
fireRepo, err := repository.NewFirestoreRepository()
if err != nil {
log.Fatal(err)
}
employeeService := service.NewEmployeeService(fireRepo)
redisCache := cache.NewRedisCache()
employeeController := controller.NewEmployeeController(employeeService, redisCache)
httpRouter := router.NewChiRouter()
httpRouter.Get("/employees", employeeController.GetAll)
httpRouter.Post("/employees", employeeController.Add)
httpRouter.Get("/employees/{id}", employeeController.Get)
httpRouter.Put("/employees/{id}", employeeController.Update)
httpRouter.Delete("/employees/{id}", employeeController.Delete)
httpRouter.Serve(os.Getenv("SERVER_PORT"))
}