-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (43 loc) · 1.05 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
package main
import (
"analytics-api/database"
"analytics-api/handle"
"analytics-api/middlewares"
repoimpl "analytics-api/repository/repo_impl"
"analytics-api/router"
"os"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
)
func init() {
if err := godotenv.Load(".env"); err != nil {
return
}
}
func main() {
log, _ := handle.NewLog()
influx := &database.InfluxDB{
URL: os.Getenv("INFLUX_URL"),
Token: os.Getenv("INFLUX_TOKEN"),
Bucket: os.Getenv("INFLUX_BUCKET"),
Measurement: os.Getenv("INFLUX_MEASUREMENT"),
Organization: os.Getenv("INFLUX_ORGANIZATION"),
Logger: log,
}
influx.NewInfluxDB()
defer influx.Close()
sessiondHandle := handle.SessionHandle{
SessionRepo: repoimpl.NewSessionRepo(influx, log),
Log: log,
}
g := gin.Default()
g.LoadHTMLGlob("templates/*")
g.StaticFile("/record.js", "./js/record.js")
g.Use(middlewares.CORSMiddleware())
api := router.API{
Gin: g,
SessionHandle: sessiondHandle,
}
api.SetupRouter()
g.Run(":" + os.Getenv("SERVER_PORT"))
}