-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (36 loc) · 789 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
package main
import (
"app/src/database"
"app/src/middleware"
"app/src/routes"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"os"
)
const (
VERSION = "0.1"
)
func setupRouter() *gin.Engine {
r := gin.Default()
r.Use(middleware.JSONLoggerMiddleware())
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.Use(middleware.CORSMiddleware())
store := cookie.NewStore([]byte(os.Getenv("TOKEN_SECRET_KEY")))
r.Use(sessions.Sessions("userSession", store))
routes.AuthRoutes(r)
routes.Routes(r)
return r
}
func init() {
err := database.ConnectToDB()
if err != nil {
return
}
}
func main() {
//helper.Log.Printf("Server v%s pid=%d started with processes: %d", VERSION, )
r := setupRouter()
r.Run(":" + os.Getenv("PORT"))
}