-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.go
52 lines (43 loc) · 1.02 KB
/
server.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
49
50
51
52
package main
import (
"log"
"os"
"Server/db"
"Server/routes"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
)
func main() {
// Initialize Firestore
if err := db.InitFirestore(); err != nil {
log.Fatalf("Error initializing Firestore: %v", err)
}
// Load .env file
err := godotenv.Load(".env")
if err != nil {
log.Fatalf("Error loading .env file")
}
// Set up Gin router
router := gin.Default()
// Apply CORS middleware
config := cors.DefaultConfig()
config.AllowOrigins = []string{"*"} // Allow requests from any origin
router.Use(cors.New(config))
// Set up routes
routes.SetupUserRoutes(router)
routes.SetupNGORoutes(router)
routes.SetupChatbotRoutes(router)
routes.SetupCampaignRoutes(router)
routes.SetupEventRoutes(router)
routes.SetupStripeRoutes(router)
routes.SetupArticleRoutes(router)
routes.SetupVideoRoutes(router)
routes.SetupBlogRoutes(router)
// Run the server
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
router.Run(":" + port)
}