-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (27 loc) · 785 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
package main
import (
"os"
"github.com/gin-gonic/gin"
// "github.com/tahmid56/go-crud/controllers"
"github.com/tahmid56/go-crud/controllers"
"github.com/tahmid56/go-crud/initializers"
"github.com/tahmid56/go-crud/middleware"
)
func init() {
initializers.LoadEnvVariables()
initializers.ConnectToDatabase()
initializers.SyncDatabase()
}
func main() {
r := gin.Default()
r.POST("/sign-up", controllers.SignUp)
r.POST("/sign-in", controllers.SignIn)
r.Use(middleware.RequireAuth)
r.GET("/validate", controllers.Validate)
r.POST("/posts", controllers.PostsCreate)
r.GET("/posts", controllers.GetPosts)
r.GET("/posts/:id", controllers.GetPost)
r.PUT("/posts/:id", controllers.UpdatePost)
r.DELETE("/posts/:id", controllers.DeletePost)
r.Run(os.Getenv("PORT"))
}