-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (27 loc) · 779 Bytes
/
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
package main
import (
"github.com/gin-gonic/gin"
_ "github.com/telman03/ecom/docs"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/telman03/ecom/db"
"github.com/telman03/ecom/models"
"github.com/telman03/ecom/routes"
)
// @title E-commerce API
// @version 1.0
// @securityDefinitions.apikey BearerAuth
// @in header
// @name Authorization
func main() {
db.InitDB()
db.DB.AutoMigrate(&models.User{}, &models.Order{}, &models.OrderItem{}, &models.Product{}, &models.Cart{})
r := gin.Default()
routes.AuthRoutes(r)
routes.UserRoutes(r)
routes.ProductRoutes(r)
routes.RegisterCartRoutes(r)
routes.RegisterOrderRoutes(r)
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
r.Run(":8080")
}