move service functions to service package

This commit is contained in:
kiwiidb
2022-01-19 16:10:55 +01:00
parent d3948cce06
commit 8eef14fccc
12 changed files with 26 additions and 25 deletions

View File

@@ -4,17 +4,17 @@ import (
"math/rand"
"net/http"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/labstack/echo/v4"
"github.com/labstack/gommon/random"
)
// AddInvoiceController : Add invoice controller struct
type AddInvoiceController struct {
svc *lib.LndhubService
svc *service.LndhubService
}
func NewAddInvoiceController(svc *lib.LndhubService) *AddInvoiceController {
func NewAddInvoiceController(svc *service.LndhubService) *AddInvoiceController {
return &AddInvoiceController{svc: svc}
}

View File

@@ -3,16 +3,16 @@ package controllers
import (
"net/http"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/labstack/echo/v4"
)
// AuthController : AuthController struct
type AuthController struct {
svc *lib.LndhubService
svc *service.LndhubService
}
func NewAuthController(svc *lib.LndhubService) *AuthController {
func NewAuthController(svc *service.LndhubService) *AuthController {
return &AuthController{
svc: svc,
}

View File

@@ -4,16 +4,16 @@ import (
"context"
"net/http"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/labstack/echo/v4"
)
// BalanceController : BalanceController struct
type BalanceController struct {
svc *lib.LndhubService
svc *service.LndhubService
}
func NewBalanceController(svc *lib.LndhubService) *BalanceController {
func NewBalanceController(svc *service.LndhubService) *BalanceController {
return &BalanceController{svc: svc}
}

View File

@@ -3,14 +3,14 @@ package controllers
import (
"net/http"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/labstack/echo/v4"
)
// CheckPaymentController : CheckPaymentController struct
type CheckPaymentController struct{}
func NewCheckPaymentController(svc *lib.LndhubService) *CheckPaymentController {
func NewCheckPaymentController(svc *service.LndhubService) *CheckPaymentController {
return &CheckPaymentController{}
}

View File

@@ -3,16 +3,16 @@ package controllers
import (
"net/http"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/labstack/echo/v4"
)
// CreateUserController : Create user controller struct
type CreateUserController struct {
svc *lib.LndhubService
svc *service.LndhubService
}
func NewCreateUserController(svc *lib.LndhubService) *CreateUserController {
func NewCreateUserController(svc *service.LndhubService) *CreateUserController {
return &CreateUserController{svc: svc}
}

View File

@@ -4,14 +4,14 @@ import (
"net/http"
"github.com/getAlby/lndhub.go/db/models"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/labstack/echo/v4"
)
// GetTXSController : GetTXSController struct
type GetTXSController struct{}
func NewGetTXSController(svc *lib.LndhubService) *GetTXSController {
func NewGetTXSController(svc *service.LndhubService) *GetTXSController {
return &GetTXSController{}
}

View File

@@ -3,16 +3,16 @@ package controllers
import (
"net/http"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/labstack/echo/v4"
)
// PayInvoiceController : Pay invoice controller struct
type PayInvoiceController struct {
svc *lib.LndhubService
svc *service.LndhubService
}
func NewPayInvoiceController(svc *lib.LndhubService) *PayInvoiceController {
func NewPayInvoiceController(svc *service.LndhubService) *PayInvoiceController {
return &PayInvoiceController{svc: svc}
}

View File

@@ -1,4 +1,4 @@
package lib
package service
import (
"context"

View File

@@ -1,4 +1,4 @@
package lib
package service
type Config struct {
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"`

View File

@@ -1,4 +1,4 @@
package lib
package service
import (
"context"

View File

@@ -1,4 +1,4 @@
package lib
package service
import (
"context"

View File

@@ -12,6 +12,7 @@ import (
"github.com/getAlby/lndhub.go/db"
"github.com/getAlby/lndhub.go/db/migrations"
"github.com/getAlby/lndhub.go/lib"
"github.com/getAlby/lndhub.go/lib/service"
"github.com/getAlby/lndhub.go/lib/tokens"
"github.com/getAlby/lndhub.go/lnd"
"github.com/getsentry/sentry-go"
@@ -27,7 +28,7 @@ import (
)
func main() {
c := &lib.Config{}
c := &service.Config{}
// Load configruation from environment variables
err := godotenv.Load(".env")
@@ -101,7 +102,7 @@ func main() {
}
logger.Infof("Connected to LND: %s - %s", getInfo.Alias, getInfo.IdentityPubkey)
svc := &lib.LndhubService{
svc := &service.LndhubService{
Config: c,
DB: dbConn,
LndClient: &lndClient,