-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (38 loc) · 950 Bytes
/
main.go
File metadata and controls
42 lines (38 loc) · 950 Bytes
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
package main
import (
"fmt"
"log"
"os"
"server/Auth"
"server/DB"
"server/Middleware"
"server/Routes"
"server/Scheduler"
"server/Utils"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
)
func main() {
if !DB.InitCollections() {
fmt.Println("Failed to initialize collections in the database")
return
}
app := fiber.New()
app.Use(cors.New())
if _, err := os.Stat(Utils.BaseStaticPath); os.IsNotExist(err) { // make sure base path exists
os.MkdirAll(Utils.BaseStaticPath, 0755)
}
Scheduler.Init()
app.Static("/", Utils.BaseStaticPath)
app.Use(Middleware.AppGaurd)
SetupRoutes(app)
app.Use(recover.New())
app.Use(logger.New())
log.Fatal(app.Listen(":3333"))
}
func SetupRoutes(app *fiber.App) {
Auth.SeedAdmin()
Routes.UserRoute(app.Group("/user"))
}