-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
130 lines (91 loc) · 2.7 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package main
import (
"log"
"net/http"
"os"
"openterps/benefits"
"openterps/categories"
"openterps/dbconnector"
"openterps/migrations"
"openterps/smells"
"openterps/strains"
"openterps/tastes"
"openterps/terpenes"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Print("Error loading .env file. Hopefully this isn't local")
}
r := gin.Default()
dbconnector.ConnectDatabase(os.Getenv("Host"), os.Getenv("Port"), os.Getenv("User"), os.Getenv("Password"), os.Getenv("Name"))
// GET / - home/info
r.GET("/", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": "Welcome to OpenTerps 0.0.1!"})
})
// GET /terpenes
r.GET("/terpenes", terpenes.GetTerpenes)
// GET /terpene/:id:
r.GET("/terpenes/:id", terpenes.GetTerpene)
// POST /terpenes
r.POST("/terpenes", terpenes.CreateTerpene)
// PUT /terpenes
r.PATCH("/terpenes/:id", terpenes.UpdateTerpene)
// Delete /terpenes
r.DELETE("/terpenes/:id", terpenes.DeleteTerpene)
// GET /benefits
r.GET("/benefits", benefits.GetBenefits)
// GET /benefit/:id
r.GET("/benefits/:id", benefits.GetBenefits)
// POST /benefits
r.POST("/benefits", benefits.CreateBenefit)
// PUT /benefits
r.PATCH("/benefits/:id", benefits.UpdateBenefit)
// Delete /benefits
r.DELETE("/benefits/:id", benefits.DeleteBenefit)
// GET /tastes
r.GET("/tastes", tastes.GetTastes)
// GET /taste/:id
r.GET("/tastes/:id", tastes.GetTaste)
// POST /tastes
r.POST("/tastes", tastes.CreateTastes)
// PUT /tastes
r.PATCH("/tastes/:id", tastes.UpdateTastes)
// Delete /tastes
r.DELETE("/tastes/:id", tastes.DeleteTastes)
// GET /smells
r.GET("/smells", smells.GetSmells)
// GET /smells/:id
r.GET("/smells/:id", smells.GetSmell)
// POST /smells
r.POST("/smells", smells.CreateSmells)
// PUT /smells
r.PATCH("/smells/:id", smells.UpdateSmells)
// Delete /smells
r.DELETE("/smells/:id", smells.DeleteSmells)
// GET /strains
r.GET("/strains", strains.GetStrains)
// GET /strains/:id
r.GET("/strains/:id", strains.GetStrain)
// POST /strains
r.POST("/strains", strains.CreateStrains)
// PUT /strains
r.PATCH("/strains/:id", strains.UpdateStrains)
// Delete /strains
r.DELETE("/strains/:id", strains.DeleteStrains)
// GET /categories
r.GET("/categories", categories.GetCategories)
// GET /categories/:id
r.GET("/categories/:id", categories.GetCategory)
// POST /categories
r.POST("/categories", categories.CreateCategories)
// PUT /categories
r.PATCH("/categories/:id", categories.UpdateCategories)
// Delete /categories
r.DELETE("/categories/:id", categories.DeleteCategories)
// POST /migrations
r.POST("/migrations", migrations.RunMigration)
r.Run(":" + os.Getenv("PORT"))
}