-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to override branding
- Loading branch information
Showing
4 changed files
with
83 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,56 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type Config struct { | ||
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"` | ||
SentryDSN string `envconfig:"SENTRY_DSN"` | ||
LogFilePath string `envconfig:"LOG_FILE_PATH"` | ||
JWTSecret []byte `envconfig:"JWT_SECRET" required:"true"` | ||
JWTRefreshTokenExpiry int `envconfig:"JWT_REFRESH_EXPIRY" default:"604800"` // in seconds, default 7 days | ||
JWTAccessTokenExpiry int `envconfig:"JWT_ACCESS_EXPIRY" default:"172800"` // in seconds, default 2 days | ||
LNDAddress string `envconfig:"LND_ADDRESS" required:"true"` | ||
LNDMacaroonHex string `envconfig:"LND_MACAROON_HEX" required:"true"` | ||
LNDCertHex string `envconfig:"LND_CERT_HEX"` | ||
CustomName string `envconfig:"CUSTOM_NAME"` | ||
Host string `envconfig:"HOST" default:"localhost:3000"` | ||
Port int `envconfig:"PORT" default:"3000"` | ||
DefaultRateLimit int `envconfig:"DEFAULT_RATE_LIMIT" default:"10"` | ||
StrictRateLimit int `envconfig:"STRICT_RATE_LIMIT" default:"10"` | ||
BurstRateLimit int `envconfig:"BURST_RATE_LIMIT" default:"1"` | ||
EnablePrometheus bool `envconfig:"ENABLE_PROMETHEUS" default:"false"` | ||
PrometheusPort int `envconfig:"PROMETHEUS_PORT" default:"9092"` | ||
WebhookUrl string `envconfig:"WEBHOOK_URL"` | ||
FeeReserve bool `envconfig:"FEE_RESERVE" default:"false"` | ||
AllowAccountCreation bool `envconfig:"ALLOW_ACCOUNT_CREATION" default:"true"` | ||
MaxReceiveAmount int64 `envconfig:"MAX_RECEIVE_AMOUNT" default:"0"` | ||
MaxSendAmount int64 `envconfig:"MAX_SEND_AMOUNT" default:"0"` | ||
MaxAccountBalance int64 `envconfig:"MAX_ACCOUNT_BALANCE" default:"0"` | ||
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"` | ||
SentryDSN string `envconfig:"SENTRY_DSN"` | ||
LogFilePath string `envconfig:"LOG_FILE_PATH"` | ||
JWTSecret []byte `envconfig:"JWT_SECRET" required:"true"` | ||
JWTRefreshTokenExpiry int `envconfig:"JWT_REFRESH_EXPIRY" default:"604800"` // in seconds, default 7 days | ||
JWTAccessTokenExpiry int `envconfig:"JWT_ACCESS_EXPIRY" default:"172800"` // in seconds, default 2 days | ||
LNDAddress string `envconfig:"LND_ADDRESS" required:"true"` | ||
LNDMacaroonHex string `envconfig:"LND_MACAROON_HEX" required:"true"` | ||
LNDCertHex string `envconfig:"LND_CERT_HEX"` | ||
CustomName string `envconfig:"CUSTOM_NAME"` | ||
Host string `envconfig:"HOST" default:"localhost:3000"` | ||
Port int `envconfig:"PORT" default:"3000"` | ||
DefaultRateLimit int `envconfig:"DEFAULT_RATE_LIMIT" default:"10"` | ||
StrictRateLimit int `envconfig:"STRICT_RATE_LIMIT" default:"10"` | ||
BurstRateLimit int `envconfig:"BURST_RATE_LIMIT" default:"1"` | ||
EnablePrometheus bool `envconfig:"ENABLE_PROMETHEUS" default:"false"` | ||
PrometheusPort int `envconfig:"PROMETHEUS_PORT" default:"9092"` | ||
WebhookUrl string `envconfig:"WEBHOOK_URL"` | ||
FeeReserve bool `envconfig:"FEE_RESERVE" default:"false"` | ||
AllowAccountCreation bool `envconfig:"ALLOW_ACCOUNT_CREATION" default:"true"` | ||
MaxReceiveAmount int64 `envconfig:"MAX_RECEIVE_AMOUNT" default:"0"` | ||
MaxSendAmount int64 `envconfig:"MAX_SEND_AMOUNT" default:"0"` | ||
MaxAccountBalance int64 `envconfig:"MAX_ACCOUNT_BALANCE" default:"0"` | ||
BrandingTitle string `envconfig:"BRANDING_TITLE" default:"LndHub - Alby Lightning"` | ||
BrandingDesc string `envconfig:"BRANDING_DESC" default:"Alby server for the Lightning Network"` | ||
BrandingUrl string `envconfig:"BRANDING_URL" default:"https://ln.getalby.com"` | ||
BrandingLogo string `envconfig:"BRANDING_LOGO" default:""` | ||
BrandingFavicon string `envconfig:"BRANDING_FAVICON" default:"../static/img/favicon.png"` | ||
BrandingFooter FooterLinkMap `envconfig:"BRANDING_FOOTER" default:"about=https://getalby.com;community=https://t.me/getAlby"` | ||
} | ||
|
||
// envconfig map decoder uses colon (:) as the default separator | ||
// we have to override the decoder so we can use colon for the protocol prefix (e.g. "https:") | ||
|
||
type FooterLinkMap map[string]string | ||
|
||
func (flm *FooterLinkMap) Decode(value string) error { | ||
m := map[string]string{} | ||
for _, pair := range strings.Split(value, ";") { | ||
kvpair := strings.Split(pair, "=") | ||
if len(kvpair) != 2 { | ||
return fmt.Errorf("invalid map item: %q", pair) | ||
} | ||
m[kvpair[0]] = kvpair[1] | ||
} | ||
*flm = m | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters