add QUERY_LIMIT environment variable and integrate into database initialization (#2)

Co-authored-by: highperfocused <highperfocused@pm.me>
This commit is contained in:
mroxso
2026-01-04 16:54:12 +01:00
committed by GitHub
parent c93da36c4e
commit c9dd6590da
2 changed files with 4 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ services:
- RELAY_PUBKEY=480ec1a7516406090dc042ddf67780ef30f26f3a864e83b417c053a5a611c838
- RELAY_DESCRIPTION=this is a public relay
- RELAY_ICON=https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fliquipedia.net%2Fcommons%2Fimages%2F3%2F35%2FSCProbe.jpg&f=1&nofb=1&ipt=0cbbfef25bce41da63d910e86c3c343e6c3b9d63194ca9755351bb7c2efa3359&ipo=images
- QUERY_LIMIT=1000
db:
image: postgres:17
restart: always

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"strconv"
"time"
"github.com/fiatjaf/eventstore/postgresql"
@@ -61,7 +62,8 @@ func main() {
relay.Info.Description = getEnv("RELAY_DESCRIPTION", "this is a public relay")
relay.Info.Icon = getEnv("RELAY_ICON", "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fliquipedia.net%2Fcommons%2Fimages%2F3%2F35%2FSCProbe.jpg&f=1&nofb=1&ipt=0cbbfef25bce41da63d910e86c3c343e6c3b9d63194ca9755351bb7c2efa3359&ipo=images")
db := postgresql.PostgresBackend{DatabaseURL: getEnv("DATABASE_URL", "postgresql://postgres:postgres@db:5432/khatru-relay?sslmode=disable")}
queryLimit, _ := strconv.Atoi(getEnv("QUERY_LIMIT", "100"))
db := postgresql.PostgresBackend{DatabaseURL: getEnv("DATABASE_URL", "postgresql://postgres:postgres@db:5432/khatru-relay?sslmode=disable"), QueryLimit: queryLimit}
if err := db.Init(); err != nil {
panic(err)
}