2025-07-03 17:55:15 +03:00
|
|
|
package routes
|
|
|
|
|
|
|
|
|
|
import (
|
2025-07-12 14:38:21 +03:00
|
|
|
"backend/controllers/cover"
|
2025-07-09 23:19:31 +03:00
|
|
|
"backend/controllers/template"
|
2025-07-06 16:46:21 +03:00
|
|
|
"backend/controllers/user"
|
2025-07-06 18:13:26 +03:00
|
|
|
"backend/middleware"
|
2025-07-03 17:55:15 +03:00
|
|
|
|
2025-07-03 21:58:49 +03:00
|
|
|
"github.com/gin-gonic/gin"
|
2025-07-03 17:55:15 +03:00
|
|
|
)
|
|
|
|
|
|
2025-07-03 21:58:49 +03:00
|
|
|
func SetupRoutes() *gin.Engine {
|
|
|
|
|
r := gin.Default()
|
2025-07-03 17:55:15 +03:00
|
|
|
|
2025-07-10 20:36:37 +03:00
|
|
|
// Guest routes (Register, Login)
|
2025-07-06 16:46:21 +03:00
|
|
|
r.POST("/register", user.Register)
|
|
|
|
|
r.POST("/login", user.Login)
|
2025-07-03 17:55:15 +03:00
|
|
|
|
2025-07-06 18:13:26 +03:00
|
|
|
// Authenticated routes middleware/group
|
|
|
|
|
auth := r.Group("/")
|
|
|
|
|
auth.Use(middleware.IsAuthenticated())
|
|
|
|
|
|
2025-07-09 23:19:31 +03:00
|
|
|
// Route to check if user is authenticated
|
|
|
|
|
auth.GET("/info", user.TokenInfo)
|
|
|
|
|
|
|
|
|
|
// Template routes (REST FUCKING GOOOOO)
|
|
|
|
|
templates := auth.Group("/templates")
|
2025-07-10 20:36:37 +03:00
|
|
|
templates.GET("", template.Get)
|
2025-07-09 23:19:31 +03:00
|
|
|
templates.POST("", template.Create)
|
|
|
|
|
// PUT (Edit)
|
|
|
|
|
// DELETE (Delete)
|
2025-07-06 18:13:26 +03:00
|
|
|
|
2025-07-12 14:38:21 +03:00
|
|
|
// Cover letter routes
|
|
|
|
|
covers := auth.Group("/cover")
|
2025-07-12 16:38:40 +03:00
|
|
|
covers.GET("", cover.Get)
|
|
|
|
|
covers.GET("/:id", cover.GetID)
|
2025-07-12 14:38:21 +03:00
|
|
|
covers.POST("", cover.Post)
|
|
|
|
|
|
2025-07-03 17:55:15 +03:00
|
|
|
return r
|
|
|
|
|
}
|