-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
47 lines (35 loc) · 1.06 KB
/
main.go
File metadata and controls
47 lines (35 loc) · 1.06 KB
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
package main
import (
"context"
"strconv"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"github.com/mayuka-c/e-commerce/config"
"github.com/mayuka-c/e-commerce/controllers"
"github.com/mayuka-c/e-commerce/database"
"github.com/mayuka-c/e-commerce/middleware"
"github.com/mayuka-c/e-commerce/routes"
"github.com/mayuka-c/e-commerce/tokens"
)
var (
ctx = context.Background()
)
var serviceConfig config.ServiceConfig
var dbConfig config.DBConfig
func init() {
serviceConfig = config.GetServiceConfig(ctx)
dbConfig = config.GetDBConfig(ctx)
}
func main() {
dbClient := database.DBSet(dbConfig)
tokenGenerator := tokens.NewTokenGenerator(dbClient)
app := controllers.NewApplication(dbClient, tokenGenerator)
router := gin.New()
router.Use(gin.Logger())
routes.UserRoutes(router, app)
router.Use(middleware.Authentication(tokenGenerator))
routes.ProductRoutes(router, app)
routes.AddressRoutes(router, app)
log.Println("E-commerce is running at port: ", serviceConfig.APIPort)
log.Fatal(router.Run(":" + strconv.Itoa(serviceConfig.APIPort)))
}