This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
67 lines (48 loc) · 2.7 KB
/
main.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
animaltypes "animals/animal-types"
"animals/animals"
"animals/locations"
"animals/users"
visitedlocation "animals/visited-locations"
"github.com/gofiber/fiber/v2"
)
func main() {
router := setupRouter()
router.Listen(":5000")
}
func setupRouter() *fiber.App {
router := fiber.New()
router.Post("/registration", users.CheckUnauthorized, users.Controller.Create)
usersRouter := router.Group("accounts")
usersRouter.Get("/search", users.DisableAuthCheck, users.CheckAuth, users.Controller.GetAll)
usersRouter.Get("/:id", users.DisableAuthCheck, users.CheckAuth, users.Controller.GetOne)
usersRouter.Put("/:id", users.CheckAuth, users.Controller.Update)
usersRouter.Delete("/:id", users.CheckAuth, users.Controller.Remove)
locationsRouter := router.Group("locations")
locationsRouter.Get("/:id", users.DisableAuthCheck, users.CheckAuth, locations.Controller.GetOne)
locationsRouter.Post("/", users.CheckAuth, locations.Controller.Create)
locationsRouter.Put("/:id", users.CheckAuth, locations.Controller.Update)
locationsRouter.Delete("/:id", users.CheckAuth, locations.Controller.Remove)
animalsRouter := router.Group("animals")
animalsRouter.Get("/search", users.DisableAuthCheck, users.CheckAuth, animals.Controller.GetAll)
animalsRouter.Get("/:id", users.DisableAuthCheck, users.CheckAuth, animals.Controller.GetOne)
animalsRouter.Post("/", users.CheckAuth, animals.Controller.Create)
animalsRouter.Put("/:id", users.CheckAuth, animals.Controller.Update)
animalsRouter.Delete("/:id", users.CheckAuth, animals.Controller.Remove)
animalsTypesRouter := animalsRouter.Group(":id/types")
animalsTypesRouter.Post("/:typeId", users.CheckAuth, animals.Controller.AddType)
animalsTypesRouter.Put("/", users.CheckAuth, animals.Controller.ReplaceType)
animalsTypesRouter.Delete("/:typeId", users.CheckAuth, animals.Controller.RemoveType)
animalTypesRouter := animalsRouter.Group("types")
animalTypesRouter.Get("/:id", users.DisableAuthCheck, users.CheckAuth, animaltypes.Controller.GetOne)
animalTypesRouter.Post("/", users.CheckAuth, animaltypes.Controller.Create)
animalTypesRouter.Put("/:id", users.CheckAuth, animaltypes.Controller.Update)
animalTypesRouter.Delete("/:id", users.CheckAuth, animaltypes.Controller.Remove)
animalsLocationsRouter := animalsRouter.Group(":animalId/locations")
animalsLocationsRouter.Get("/", users.DisableAuthCheck, users.CheckAuth, visitedlocation.Controller.GetAll)
animalsLocationsRouter.Post("/:locationId", users.CheckAuth, visitedlocation.Controller.Create)
animalsLocationsRouter.Put("/", users.CheckAuth, visitedlocation.Controller.Update)
animalsLocationsRouter.Delete("/:locationId", users.CheckAuth, visitedlocation.Controller.Remove)
return router
}