2022-03-30 12:11:44 -04:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
log "github.com/sirupsen/logrus"
|
2022-04-02 03:31:29 -04:00
|
|
|
"gorm.io/gorm"
|
2022-03-30 12:11:44 -04:00
|
|
|
)
|
|
|
|
|
2022-04-02 03:31:29 -04:00
|
|
|
func Listen(db *gorm.DB) {
|
2022-03-30 12:11:44 -04:00
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
|
|
|
|
router := gin.Default()
|
|
|
|
router.SetTrustedProxies(nil)
|
|
|
|
router.Static("/static", "web/static")
|
|
|
|
router.StaticFile("/", "web/static/index.html")
|
2022-04-09 03:01:12 -04:00
|
|
|
router.GET("/api/overview", func(c *gin.Context) {
|
|
|
|
c.JSON(200, GetOverview(db))
|
|
|
|
})
|
2022-04-02 03:31:29 -04:00
|
|
|
router.GET("/api/investment", func(c *gin.Context) {
|
|
|
|
c.JSON(200, GetInvestment(db))
|
|
|
|
})
|
2022-04-16 01:08:32 -04:00
|
|
|
router.GET("/api/allocation", func(c *gin.Context) {
|
|
|
|
c.JSON(200, GetAllocation(db))
|
|
|
|
})
|
2022-04-09 12:45:05 -04:00
|
|
|
router.GET("/api/ledger", func(c *gin.Context) {
|
|
|
|
c.JSON(200, GetLedger(db))
|
|
|
|
})
|
2022-04-02 03:31:29 -04:00
|
|
|
log.Info("Listening on 7500")
|
2022-04-19 04:02:05 -04:00
|
|
|
err := router.Run(":7500")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2022-03-30 12:11:44 -04:00
|
|
|
}
|