From c9dd6590dadd7fa18027b67f9ab99951f4c85d3e Mon Sep 17 00:00:00 2001 From: mroxso <24775431+mroxso@users.noreply.github.com> Date: Sun, 4 Jan 2026 16:54:12 +0100 Subject: [PATCH] add QUERY_LIMIT environment variable and integrate into database initialization (#2) Co-authored-by: highperfocused --- compose.yaml | 1 + main.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index ee984c2..e996dee 100644 --- a/compose.yaml +++ b/compose.yaml @@ -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 diff --git a/main.go b/main.go index 5ef2d93..ce61490 100644 --- a/main.go +++ b/main.go @@ -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) }