-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
42 lines (33 loc) · 895 Bytes
/
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
package main
import (
"carpool-backend/database"
"carpool-backend/routes/bookings"
"carpool-backend/routes/rides"
"carpool-backend/routes/users"
"log"
"github.com/gofiber/fiber/v2"
)
func SetupRoutes(app *fiber.App) {
// booking routes
app.Post("/bookings", bookings.CreateBooking)
app.Put("/bookings", bookings.EditBooking)
app.Delete("/bookings", bookings.DeleteBooking)
// ride routes
app.Post("/rides", rides.CreateRide)
app.Put("/rides", rides.UpdateRide)
app.Delete("/rides", rides.DeleteRide)
app.Get("/rides", rides.GetRides)
app.Get("/search", rides.SearchRides)
app.Get("/rides/:id", rides.GetRidesById)
// user routes
app.Post("/users", users.CreateUser)
}
func main() {
app := fiber.New()
database.ConnectToDB()
SetupRoutes(app)
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World 👋!")
})
log.Fatal(app.Listen(":3000"))
}