From f6559a6a0c4c360fb3e4f35e9ab93dbe6e96d3b1 Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Sat, 22 Jan 2022 21:36:27 +0100 Subject: [PATCH 1/2] Make port configurable --- lib/service/config.go | 1 + main.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/service/config.go b/lib/service/config.go index d0fe717..668f78f 100644 --- a/lib/service/config.go +++ b/lib/service/config.go @@ -9,4 +9,5 @@ type Config struct { LNDAddress string `envconfig:"LND_ADDRESS" required:"true"` LNDMacaroonHex string `envconfig:"LND_MACAROON_HEX" required:"true"` LNDCertHex string `envconfig:"LND_CERT_HEX"` + Port int `envconfig:"PORT" default:"3000"` } diff --git a/main.go b/main.go index 962bd1c..3d99d69 100644 --- a/main.go +++ b/main.go @@ -143,7 +143,7 @@ func main() { // Start server go func() { - if err := e.Start(":3000"); err != nil && err != http.ErrServerClosed { + if err := e.Start(fmt.Sprintf(":%v", c.Port)); err != nil && err != http.ErrServerClosed { e.Logger.Fatal("shutting down the server") } }() From 3e3e5fb3cf7d19e674cdae204f20ed9ead9d9052 Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Sat, 22 Jan 2022 23:25:31 +0100 Subject: [PATCH 2/2] Document PORT config option --- README.md | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index eb6da05..6211990 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,9 @@ vim .env # edit your config + `LND_ADDRESS`: LND address (with port) + `LND_MACAROON_HEX`: LND macaroon + `LND_CERT_HEX`: LND certificate -+ `LOG_FILE_PATH`: (optional) By default all logs are written to STDOUT. If you want to log to a file provide the log file path here ++ `LOG_FILE_PATH`: (optional) By default all logs are written to STDOUT. If you want to log to a file provide the log file path here + `SENTRY_DSN`: (optional) Sentry DSN for exception tracking ++ `PORT`: (default: 3000) Port the app should listen on ## Developing @@ -50,7 +51,7 @@ make ``` -## Database +## Database LndHub.go supports PostgreSQL and SQLite as database backend. But SQLite does not support the same data consistency checks as PostgreSQL. ### Ideas @@ -61,31 +62,31 @@ LndHub.go supports PostgreSQL and SQLite as database backend. But SQLite does no ### Data model ``` - ┌─────────────┐ - │ User │ - └─────────────┘ - │ - ┌─────────────────┬───────┴─────────┬─────────────────┐ - ▼ ▼ ▼ ▼ + ┌─────────────┐ + │ User │ + └─────────────┘ + │ + ┌─────────────────┬───────┴─────────┬─────────────────┐ + ▼ ▼ ▼ ▼ Accounts: ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ Incoming │ │ Current │ │ Outgoing │ │ Fees │ Every user has └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ - four accounts - - Every Transaction Entry is associated to one debit account and one - credit account - - ┌────────────────────────┐ - │Transaction Entry │ - │ │ - │+ user_id │ - ┌────────────┐ │+ invoice_id │ - │ Invoice │────────────────▶+ debit_account_id │ - └────────────┘ │+ credit_account_id │ - │+ amount │ - Invoice holds the │+ ... │ - lightning related │ │ - data └────────────────────────┘ - + four accounts + + Every Transaction Entry is associated to one debit account and one + credit account + + ┌────────────────────────┐ + │Transaction Entry │ + │ │ + │+ user_id │ + ┌────────────┐ │+ invoice_id │ + │ Invoice │────────────────▶+ debit_account_id │ + └────────────┘ │+ credit_account_id │ + │+ amount │ + Invoice holds the │+ ... │ + lightning related │ │ + data └────────────────────────┘ + ```