Module Options
All options live under the key mongocamp in nuxt.config.ts.
ts
export default defineNuxtConfig({
modules: ['@sfxcode/nuxt-mongocamp-server'],
mongocamp: {
url: '',
apiKey: '',
paginationSize: 500,
refreshToken: false,
tokenRefreshInterval: 5000,
sessionMaxAge: 2592000,
server: {
enabled: false,
prefix: '/api/mongocamp-server',
connectionUri: '',
config: {},
jobs: true,
requestLogging: false,
metrics: false,
},
},
})Client
| Option | Type | Default | Description |
|---|---|---|---|
url | string | the server.prefix | Base URL of the MongoCamp API. Required without the embedded server. |
apiKey | string | — | API key of a technical user. Stored only in the private runtime config. useMongocampEventApi(event) in server code uses it automatically. |
paginationSize | number | 500 | Default rows per page for the search and list composables. Values below 10 fall back to the default. |
refreshToken | boolean | false | Refreshes the session token on an interval after login. |
tokenRefreshInterval | number | 5000 | Refresh interval in milliseconds. Values below 5000 fall back to the default. |
sessionMaxAge | number | 2592000 (30 days) | Max age in seconds of the mongocamp-session cookie. Values ≤ 0 fall back to the default. |
A missing url without the embedded server fails nuxi dev, nuxi build and nuxi generate. It does not fail nuxi prepare, so type stubs and IDE support work without a configured backend.
Embedded server
| Option | Type | Default | Description |
|---|---|---|---|
server.enabled | boolean | false | Serves the MongoCamp API from this application. |
server.prefix | string | /api/mongocamp-server | Path of the API. Must not be /. |
server.connectionUri | string | — | MongoDB connection string. Prefer the env variable NUXT_MONGOCAMP_SERVER_CONNECTION_URI. Without it the CONNECTION_* settings apply. |
server.config | object | {} | Server settings by key (CONNECTION_DATABASE, AUTH_EXPIRING_DURATION, ...). Environment variables win. |
server.jobs | boolean | true | Runs the jobs on their schedule in this instance. With several instances of one application, set it to false on all but one (or set JOBS_ENABLED=false in their environment). Register handlers with registerJobHandler. |
server.requestLogging | boolean | false | Writes every request as a document of mc_request_logging. See Request Logging & Metrics. |
server.metrics | boolean | false | Serves /system/monitoring/* (also Prometheus text) and writes the metric snapshots. |
server.collectionsDir | string | mongocamp | Directory of the declared collections in server/ of the application and its layers. Registered in the embedded server and typed for the client. With an external server, set it to get the types only. |
Environment variables
Nuxt's runtime config overrides apply:
| Variable | Overrides |
|---|---|
NUXT_PUBLIC_MONGOCAMP_URL | url |
NUXT_MONGOCAMP_API_KEY | apiKey |
NUXT_MONGOCAMP_SERVER_CONNECTION_URI | server.connectionUri |
Extensions of the embedded server are Nitro plugins on the mongocamp:* hooks. The embedded server also reads its own environment variables directly (CONNECTION_HOST, AUTH_SECRET, ...). They win over server.config. See Configuration.
