-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (34 loc) · 1.47 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
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/session"
"shidqi/shoppingcartapi/controllers"
)
func main() {
store := session.New()
app := fiber.New()
// controllers
productApiController := controllers.InitProductAPIController()
accountApiController := controllers.InitAccountAPIController(store)
cartApiController := controllers.InitCartController(store)
transactionApiController := controllers.InitTransactionController(store)
//grouping for controller
p := app.Group("/products")
c := app.Group("/cart")
t := app.Group("/transactions")
app.Get("/accounts", accountApiController.GetAllAccount)
app.Post("/accounts/create", accountApiController.CreateAccount)
app.Post("/login", accountApiController.LoginUser)
app.Post("/logout", accountApiController.Logout)
p.Get("/", productApiController.GetAllProduct)
p.Post("/", productApiController.CreateProduct)
p.Get("/detail/:id", productApiController.GetDetailProduct)
p.Put("/:id", productApiController.EditProduct)
p.Delete("/:id", productApiController.DeleteProduct)
p.Get("/addtocart/:cartid/products/:productid", cartApiController.AddToCart)
c.Get("/:cartid", cartApiController.GetDetailCart)
t.Get("/out/:accountid", transactionApiController.InsertToTransaction)
t.Get("/list/:accountid", transactionApiController.GetTransaction)
t.Get("/detail/:transactionid", transactionApiController.DetailTransaction)
app.Listen(":3000")
}