generated from GDGVIT/template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (34 loc) · 1.04 KB
/
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
package main
import (
"log"
"os"
"ultra-chat-backend/config"
"ultra-chat-backend/handlers"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"ultra-chat-backend/repositories"
)
func main() {
db := config.ConnectDB()
defer config.DisconnectDB()
userRepo := repositories.NewUserRepository(db)
summaryRepo, _ := repositories.NewMongoSummaryRepository(db)
e := echo.New()
e.Use(middleware.Recover())
// Auth Routes
authHandler := handlers.NewAuthHandler(userRepo)
e.GET("/login", authHandler.Login)
e.GET("/callback", authHandler.Callback)
e.GET("/profile", authHandler.Profile)
summaryHandler := handlers.NewSummaryHandler(summaryRepo)
e.POST("/create-summary", summaryHandler.CreateSummary)
e.GET("/summarizer", summaryHandler.GetSummaries)
e.PUT("/update-summary", summaryHandler.UpdateSummary)
e.DELETE("/delete-summary", summaryHandler.DeleteSummary)
e.GET("/is_authenticated", summaryHandler.IsAuthenticated)
port := os.Getenv("PORT")
if port == "" {
port = "5001"
}
log.Fatal(e.Start(":" + port))
}