-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (39 loc) · 975 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
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"github.com/fatih/color"
"github.com/jasonlvhit/gocron"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
. "github.com/than-os/sent-dante/dbo"
"github.com/than-os/sent-dante/services"
)
var d = TON{}
func main() {
s := gocron.NewScheduler()
go func() {
s.Every(5).Seconds().Do(service.KeepAlive)
color.Red("%s", "running the job")
<-s.Start()
}()
e := echo.New()
//middlewares
e.Use(middleware.Logger())
e.Use(middleware.Recover())
//CORS
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{echo.GET, echo.POST, echo.DELETE},
}))
e.GET("/", service.RootFunc)
e.GET("/all", service.GetAllTonNodes)
e.POST("/register", service.RegisterTonNode)
e.POST("/node", service.GetTonNodeByIP)
e.DELETE("/node", service.RemoveTonNode)
//Start the server
e.Start(":30001")
}
func init() {
d.Server = "localhost"
d.Database = "ton"
d.NewSession()
}