-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (32 loc) · 874 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
36
37
38
39
40
41
42
43
package main
import (
"os"
"cloth-management-system/database"
middleware "cloth-management-system/middleware"
routes "cloth-management-system/routes"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/mongo"
)
// reads if present, creates if not present
var clothCollection *mongo.Collection = database.OpenCollection(database.Client, "cloth")
func main() {
port := os.Getenv("PORT")
if port == "" {
// default port
port = "8000"
}
// Using gin router for JWT
router := gin.New()
router.Use(gin.Logger())
routes.UserRoutes(router)
router.Use(middleware.Authentication())
// Initializing routes
// functions defined in routes folder
routes.ClothRoutes(router)
routes.InventoryRoutes(router)
routes.CounterRoutes(router)
routes.OrderRoutes(router)
routes.OrderItemRoutes(router)
routes.InvoiceRoutes(router)
router.Run(":" + port)
}