cic-dw/internal/dashboard/api.go
Mohammed Sohail 128b15407a
server: init api server
- echo (https://echo.labstack.com/) as web framework
- carbon for auto date-range parsing
- add dashboard sql queries
2022-05-11 16:57:56 +03:00

30 lines
580 B
Go

package dashboard
import (
"github.com/jackc/pgx/v4/pgxpool"
"github.com/labstack/echo/v4"
"github.com/nleof/goyesql"
)
type api struct {
db *pgxpool.Pool
q goyesql.Queries
}
func InitDashboardApi(e *echo.Echo, db *pgxpool.Pool, queries goyesql.Queries) {
g := e.Group("/dashboard")
g.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
c.Set("api", &api{
db: db,
q: queries,
})
return next(c)
}
})
g.GET("/new-registrations", handleNewRegistrations)
g.GET("/transactions-count", handleTransactionsCount)
}