mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-19 13:44:53 +01:00
move service functions to service package
This commit is contained in:
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
@@ -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{}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
@@ -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{}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package lib
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package lib
|
||||
package service
|
||||
|
||||
type Config struct {
|
||||
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"`
|
||||
@@ -1,4 +1,4 @@
|
||||
package lib
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package lib
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
5
main.go
5
main.go
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user