-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
34 lines (29 loc) · 1.16 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
package main
import (
"github.com/gin-gonic/gin"
auth "main-module/controllers/auth"
profile "main-module/controllers/profile"
post "main-module/controllers/posts"
"main-module/initializers"
"main-module/middleware"
"main-module/models"
)
func init() {
initializers.LoadEnvVariables()
initializers.ConnectToDb()
initializers.SyncDatabase()
}
func main() {
r := gin.Default()
//Authentication routes
r.POST("/signup", auth.SignUp)
r.POST("/login", auth.Login)
//Profile routes
r.GET("/profile", middleware.RequireAuth, middleware.RoleMiddleware(models.UserRoleAdmin, models.UserRoleAuthor, models.UserRoleEditor, models.UserRoleViewer), profile.GetProfile)
r.PUT("/profile/update", middleware.RequireAuth, middleware.RoleMiddleware(models.UserRoleAdmin, models.UserRoleAuthor, models.UserRoleEditor, models.UserRoleViewer), profile.UpdateProfile)
r.Static("/profile-image", "./build/resources/main/static/profile-image")
//Post routes
r.POST("/post/create",middleware.RequireAuth,middleware.RoleMiddleware(models.UserRoleAdmin, models.UserRoleAuthor, models.UserRoleEditor),post.CreatePost)
r.GET("/post/:id", middleware.RequireAuth,post.GetPost)
r.Run()
}