-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
69 lines (50 loc) · 1.52 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
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"log"
"runclub/database"
"runclub/handlers"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
)
func main() {
database.Connect()
// database.Migrate()
// Create a new engine
engine := html.New("./views", ".html")
// Pass the engine to the Views
app := fiber.New(fiber.Config{
Views: engine,
})
app.Static("/", "./public")
// Unauthenticated Pages
app.Get("/", handlers.Home)
app.Get("/login", handlers.LoginPage)
app.Get("/signup", handlers.SignupPage)
app.Get("/setup", handlers.Setup)
app.Get("/faq", handlers.Faq)
app.Get("/contact", handlers.Contact)
api := app.Group("/api")
// Unauthenticated API
api.Post("/login", handlers.Login)
api.Post("/signup", handlers.Signup)
app.Use(handlers.AuthMiddleware)
// Authenticated Pages
app.Get("/pastevents", handlers.PastEvents)
app.Get("/events", handlers.Event)
app.Get("/participants/:eventId", handlers.Participants)
app.Get("/timing/:eventId", handlers.Timing)
// Authenticated API
// API - Events
api.Get("/event", handlers.GetEvents)
api.Post("/event", handlers.CreateEvent)
// API - Participants
participant := api.Group("/participant")
participant.Get("/date", handlers.GetParticipantsByDate)
participant.Post("/event/:id", handlers.AddParticipant)
participant.Post("/find", handlers.GetParticipants)
// API - Timing
api.Post("/timing/:eventId/:bib", handlers.TimeParticipant)
// API - Contacts
api.Post("/contact", handlers.SendEmail)
log.Fatal(app.Listen(":5173"))
}