Skip to content

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 ​

OptionTypeDefaultDescription
urlstringthe server.prefixBase URL of the MongoCamp API. Required without the embedded server.
apiKeystring—API key of a technical user. Stored only in the private runtime config. useMongocampEventApi(event) in server code uses it automatically.
paginationSizenumber500Default rows per page for the search and list composables. Values below 10 fall back to the default.
refreshTokenbooleanfalseRefreshes the session token on an interval after login.
tokenRefreshIntervalnumber5000Refresh interval in milliseconds. Values below 5000 fall back to the default.
sessionMaxAgenumber2592000 (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 ​

OptionTypeDefaultDescription
server.enabledbooleanfalseServes the MongoCamp API from this application.
server.prefixstring/api/mongocamp-serverPath of the API. Must not be /.
server.connectionUristring—MongoDB connection string. Prefer the env variable NUXT_MONGOCAMP_SERVER_CONNECTION_URI. Without it the CONNECTION_* settings apply.
server.configobject{}Server settings by key (CONNECTION_DATABASE, AUTH_EXPIRING_DURATION, ...). Environment variables win.
server.jobsbooleantrueRuns 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.requestLoggingbooleanfalseWrites every request as a document of mc_request_logging. See Request Logging & Metrics.
server.metricsbooleanfalseServes /system/monitoring/* (also Prometheus text) and writes the metric snapshots.
server.collectionsDirstringmongocampDirectory 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:

VariableOverrides
NUXT_PUBLIC_MONGOCAMP_URLurl
NUXT_MONGOCAMP_API_KEYapiKey
NUXT_MONGOCAMP_SERVER_CONNECTION_URIserver.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.

Released under the MIT License.