-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (39 loc) · 876 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
44
45
46
47
48
package main
import (
"context"
"fmt"
"os"
"remood/pkg/auth"
"remood/routes"
"github.com/gin-gonic/gin"
_ "github.com/joho/godotenv/autoload"
"remood/pkg/database"
"remood/pkg/middleware"
)
func main() {
//DATABASE CONNECTION
db := database.GetMongoInstance()
defer db.Client.Connect(context.Background())
fmt.Println("MONGODB CONNECTED")
// GENERATE JWT SECRET KEY
auth.GenerateJWTKey()
//GIN DEFINE
router := gin.Default()
router.Use(middleware.CorsMiddleware)
api := router.Group("/api")
{
api.GET("/", func(ctx *gin.Context) {
ctx.JSON(200, gin.H{
"message": "Ping successful",
})
})
}
//ROUTER DEFINE
routes.UserRouter(api)
routes.DiaryNoteRouter(api)
routes.ReviewNoteRouter(api)
routes.DayReviewRouter(api)
routes.ArticleRouter(api)
port := fmt.Sprintf(":%s", os.Getenv("APP_PORT"))
router.Run("localhost" + port)
}