Initial configuration
const gate = createGuildGate({
app: {
name: "My Discord Dashboard",
environment: "production",
baseUrl: "https://panel.example.com",
},
owners: ["123456789012345678"],
locale: {default: "en"},
security: {
allowedOrigins: ["https://panel.example.com"],
csrfSecret: process.env.GUILDGATE_CSRF_SECRET!,
auditIpSalt: process.env.GUILDGATE_AUDIT_IP_SALT!,
session: {
ttlMs: 12 * 60 * 60_000,
idleTimeoutMs: 30 * 60_000,
rotateAfterMs: 15 * 60_000,
maximumSessionsPerUser: 5,
},
},
stores,
transactions,
telemetry,
audit: {
enabled: true,
redactKeys: ["token", "secret", "authorization"],
failClosedActions: ["guild.billing.update"],
},
reliability: {maximumLateSettlementMs: 5 * 60_000},
});
Production startup guards
The production profile rejects non-HTTPS baseUrl, empty or wildcard origins, loopback/unspecified/mapped-loopback URLs, insecure session cookies, and weak secrets. Discord OAuth endpoints and callbacks must also use HTTPS.
Session limit
Official memory, Redis, and PostgreSQL stores enforce maximumSessionsPerUser inside session creation. A shared custom store should implement atomic create-and-evict through create(record, maximumSessionsPerUser).
HTTP adapters return cookie-clearing metadata when they encounter an expired or revoked session.
Reliability setting
maximumLateSettlementMs bounds how long reservation and lease ownership may remain after the response deadline. Applications should pass context.signal to database and HTTP clients that support cancellation.
Fail-closed audit
An action in failClosedActions must enable audit and idempotency, require a transaction, and enlist the audit store in that transaction.