Skip to content

useMongocampLimits ​

The limits of the server (2.6, GET /system/capabilities → limits), readable by every signed-in user — so a component can respect a limit before the server refuses a request.

ts
const { limits, authFeatures, status, load } = useMongocampLimits()
await load()
if (limits.value.gridfsUploadMaxBytes !== undefined && file.size > limits.value.gridfsUploadMaxBytes) { /* … */ }
ReturnDescription
limitsComputedRef<ServerLimits> — only the limits that are on (0 on the wire is "off" and left out): bodyMaxBytes, pagingMaxRows, exportMaxDocuments, gridfsUploadMaxBytes, importMaxBytes, and since server 2.11 the rate limits as configured text (rateLimitLogin 10/15m, rateLimitRequests). Empty until loaded and after a failure — treat "unknown" like "no limit", the server still refuses what is too large
authFeaturesServer 3.1: ComputedRef<AuthFeatures | undefined> from the same answer's features — { sessions, registration: 'open' | 'invite' | 'off', passwordReset, passwordless, requireVerifiedEmail }; undefined until loaded or after a failure. MongocampUsers shows Invite User from it. (The capabilities need a login, so the logged-out pages — login, register, reset — still take props.)
status'idle' | 'loading' | 'ready' | 'failed'
load(force?)Asks once per signed-in user; callers asking together share one request. Never throws; 15 s timeout

The cache is a shared useState per signed-in user: another user starts empty, and an answer that arrives after the user changed is dropped. The pure part is utils/serverLimits.ts (normalizeLimits).

Used by MongocampCollectionData (no page size above pagingMaxRows), MongocampBucketFiles (an upload over gridfsUploadMaxBytes is not sent) and MongocampExportAll (says before the export that exportMaxDocuments cuts it). MongocampServerInfo lists all limits.

Released under the MIT License.