-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (30 loc) · 974 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
package main
import (
"ginTest/controllers"
"ginTest/initialize"
"ginTest/middleware"
"github.com/gin-gonic/gin"
)
var r = gin.Default()
func init() {
initialize.LoadDotEnv()
initialize.ConnectToDB()
middleware.CORSMiddleware(r)
}
func main() {
// User routes
r.POST("/register", controllers.CreateUser)
r.POST("/login", controllers.LoginUser)
// TODO: PREVENT TOTAL DESTRUCTION
//r.GET("/user/:id", controllers.GetUserByID)
//r.DELETE("/user/:id", controllers.DeleteUser)
//r.PUT("/user/:id", middleware.CheckUserIsAuthor, controllers.UpdateUser)
// Review routes
r.POST("/review", controllers.CreateReview)
r.GET("/review/:id", controllers.GetReviewsByMovieID)
r.GET("review/user/:id", controllers.GetReviewsByAuthor)
r.GET("/review/:id/rating", controllers.GetMovieAverageRating)
r.DELETE("/review/:id", controllers.DeleteReview)
r.PUT("/review/:id", middleware.CheckUserIsAuthor, middleware.RequireAuth, controllers.UpdateReview)
r.Run()
}