forked from dhanrajchaurasia/CP-Grind
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
56 lines (43 loc) · 1.11 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
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"log"
"os"
"github.com/dhanrajchaurasia/CP-GRIND/controllers"
"github.com/dhanrajchaurasia/CP-GRIND/middleware"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
"github.com/dhanrajchaurasia/CP-GRIND/initializers"
)
func init() {
initializers.LoadEnvVars()
initializers.ConnectionToDB()
initializers.SyncDB()
}
var Engine = html.New("./views", ".html")
var App = fiber.New(fiber.Config{Views: Engine})
func Routes() {
// Get Requests
App.Get("/", controllers.HomePage)
App.Get("/404", controllers.NotFound)
App.Get("/login", controllers.LoginPage)
App.Get("/grind", controllers.GrindPage)
// Post Requests
App.Post("/signup", controllers.Signup)
App.Post("/login", controllers.Login)
App.Post("/logout", controllers.Logout)
App.Post("/cfProfile", controllers.GetCFProfile)
// 404 Page
App.Use(func(c *fiber.Ctx) error {
return c.SendString("Page Not Found")
})
}
func main() {
// Configure App
App.Static("/", "./public")
// Middleware
App.Use(middleware.AuthMiddleware)
// Routes
Routes()
// Server
log.Fatal(App.Listen(":" + os.Getenv("PORT")))
}