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"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
"github.com/getAlby/lndhub.go/lib/service"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/gommon/random"
|
"github.com/labstack/gommon/random"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddInvoiceController : Add invoice controller struct
|
// AddInvoiceController : Add invoice controller struct
|
||||||
type AddInvoiceController 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}
|
return &AddInvoiceController{svc: svc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
"github.com/getAlby/lndhub.go/lib/service"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AuthController : AuthController struct
|
// AuthController : AuthController struct
|
||||||
type 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{
|
return &AuthController{
|
||||||
svc: svc,
|
svc: svc,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
"github.com/getAlby/lndhub.go/lib/service"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BalanceController : BalanceController struct
|
// BalanceController : BalanceController struct
|
||||||
type 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}
|
return &BalanceController{svc: svc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
"github.com/getAlby/lndhub.go/lib/service"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CheckPaymentController : CheckPaymentController struct
|
// CheckPaymentController : CheckPaymentController struct
|
||||||
type CheckPaymentController struct{}
|
type CheckPaymentController struct{}
|
||||||
|
|
||||||
func NewCheckPaymentController(svc *lib.LndhubService) *CheckPaymentController {
|
func NewCheckPaymentController(svc *service.LndhubService) *CheckPaymentController {
|
||||||
return &CheckPaymentController{}
|
return &CheckPaymentController{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
"github.com/getAlby/lndhub.go/lib/service"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateUserController : Create user controller struct
|
// CreateUserController : Create user controller struct
|
||||||
type CreateUserController 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}
|
return &CreateUserController{svc: svc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/db/models"
|
"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"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetTXSController : GetTXSController struct
|
// GetTXSController : GetTXSController struct
|
||||||
type GetTXSController struct{}
|
type GetTXSController struct{}
|
||||||
|
|
||||||
func NewGetTXSController(svc *lib.LndhubService) *GetTXSController {
|
func NewGetTXSController(svc *service.LndhubService) *GetTXSController {
|
||||||
return &GetTXSController{}
|
return &GetTXSController{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
"github.com/getAlby/lndhub.go/lib/service"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PayInvoiceController : Pay invoice controller struct
|
// PayInvoiceController : Pay invoice controller struct
|
||||||
type PayInvoiceController 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}
|
return &PayInvoiceController{svc: svc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package lib
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lib
|
package service
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"`
|
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lib
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lib
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
5
main.go
5
main.go
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/getAlby/lndhub.go/db"
|
"github.com/getAlby/lndhub.go/db"
|
||||||
"github.com/getAlby/lndhub.go/db/migrations"
|
"github.com/getAlby/lndhub.go/db/migrations"
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
"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/lib/tokens"
|
||||||
"github.com/getAlby/lndhub.go/lnd"
|
"github.com/getAlby/lndhub.go/lnd"
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
@@ -27,7 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
c := &lib.Config{}
|
c := &service.Config{}
|
||||||
|
|
||||||
// Load configruation from environment variables
|
// Load configruation from environment variables
|
||||||
err := godotenv.Load(".env")
|
err := godotenv.Load(".env")
|
||||||
@@ -101,7 +102,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
logger.Infof("Connected to LND: %s - %s", getInfo.Alias, getInfo.IdentityPubkey)
|
logger.Infof("Connected to LND: %s - %s", getInfo.Alias, getInfo.IdentityPubkey)
|
||||||
|
|
||||||
svc := &lib.LndhubService{
|
svc := &service.LndhubService{
|
||||||
Config: c,
|
Config: c,
|
||||||
DB: dbConn,
|
DB: dbConn,
|
||||||
LndClient: &lndClient,
|
LndClient: &lndClient,
|
||||||
|
|||||||
Reference in New Issue
Block a user