Migration from the Scala MongoCamp server
The TypeScript server (@sfxcode/mongocamp-server-core, standalone in apps/server, embedded through the Nuxt module) implements in its 1.x releases the same OpenAPI contract (openapi/docs.yaml, 93 operations) as the Scala mongocamp-server 1.9.x; clients such as nuxt-ui-mongocamp and the generated client of this module work unchanged with 1.x.
2.0 changes the contract (documents as Extended JSON, Lucene rules, 404 for missing resources, salted password hashes, no Scala leftovers, ...). This page describes the switch from Scala to the compatible 1.x line; every change of 2.0 and the steps for it are in Migration to 2.0. With 2.0, start once with
MIGRATION_DROP_SCALA_LEFTOVERS=trueon a database of the Scala server and do not run a Scala server on it afterwards.
Switching
- Stop the Scala server.
- Start the new server against the same database with the same environment (
CONNECTION_*,AUTH_PREFIX,AUTH_*,CORS_*):- standalone:
docker build -f apps/server/Dockerfile -t mongocamp-nitro-server .and run it like the Scala image (portSERVER_PORT, default 8080), ornode apps/server/.output/server/index.mjs; - embedded:
mongocamp: { server: { enabled: true } }in a Nuxt 4.7 application on Nitro 3 (see Getting Started).
- standalone:
- Point the clients at the new url (embedded: the prefix, default
/api/mongocamp-server).
What keeps working without changes:
| Data | Collection | Notes |
|---|---|---|
| users, roles, grants | mc_users, mc_roles | SHA-256 passwords (2.0 replaces them with salted hashes at login), api keys |
| tokens | mc_token_cache | 1.x: hashed and legacy plain entries, tokens stay valid because the stored AUTH_SECRET is used; 2.0: hashed entries only, a token of the Scala server needs a new login |
| configurations | mc_configuration | values of the Scala server are read as they are (durations as text, Int32/Int64 numbers) |
| documents, indexes, GridFS buckets | your collections, *.files / *.chunks | Int64 length/chunkSize of the Java driver are read |
| jobs | mc_jobs | see below |
| request log | mc_request_logging | same document shape |
Stored settings apply: a database where the request logging plugin was active (REQUESTLOGGING_ENABLED stored as true) keeps logging requests. New keys are added to mc_configuration, nothing else in it is changed. This was checked on a copy of a database written by the Scala server: stored token secret, api key logins, documents, buckets and the migrated cleanup job worked, the Quartz tables stayed untouched.
The server reports itself as mongocamp-nitro-server (/version, the server header, the served spec, the issuer of new tokens) with the version of the module; existing tokens of the Scala server stay valid (the issuer is not checked).
The 0.0.0.0:8080 listener, CORS headers, error headers (x-error-code, x-error-message, x-error-additional-info), pagination headers and the Extended JSON formats are the same.
Differences
Changed on purpose
- Jobs: cron expressions use the syntax of croner (
*/5 * * * * *,L,W,#,@daily; 0 = Sunday), not Quartz (0 0/5 * ? * * *). The token cleanup job is migrated at startup (2.0: once, withMIGRATION_DROP_SCALA_LEFTOVERS=true); other stored jobs with a Quartz expression are listed as not scheduled with the reason, update them withPATCH /system/jobs/{group}/{name}. The Quartz tablesmc_jobs_*are not read. Every instance with an active scheduler runs the jobs (Quartz was clustered); disable it per instance withjobs: false. An invalid cron expression answers 400 (Scala: 412 "already added"). - Configurations: env values win over stored ones but are no longer written into
mc_configuration;PATCH /system/configurations/{key}checks the value against the type (Scala stored anything).CONNECTION_PASSWORDandAUTH_SECRETare answered as********. 15 keys of the former plugins are registered, so 51 configurations are listed. - Plugins: the dynamic JVM plugins are gone. Request logging (
REQUESTLOGGING_ENABLED) and metrics (METRICS_ENABLED,/system/monitoring/*, plus Prometheus text) are part of the core and off by default; the categoryjvmholds Node runtime numbers. Extensions use events, job handlers and host routes (see Extensions). - Cluster and events: there is no JGroups cluster;
/system/clusterlists this process, events are delivered within the instance. - API docs:
/docs/docs.yaml(DOCS_OPENAPI) is the spec of the contract with the name, version and path of this server;/docs(DOCS_SWAGGER) is a Scalar UI instead of Swagger UI. - Shutdown:
DELETE /systemstops the standalone server; an embedded server answers 400.
Bug fixes visible to clients
- Unknown routes answer a JSON
ErrorDescription404 with CORS headers (Scala: plain text without CORS). - A token of a deleted user answers 401 (Scala: 404 "user does not exists");
GET /admin/users/{id}works with the static auth handler. - Default JSON format: a BSON Timestamp is the date of its seconds (Scala: a date in January 1970), a UUID its text (Scala: null); whole doubles are written as
2(canonical Extended JSON still writes{"$numberDouble":"2.0"}). - Partial updates merge plain fields into an explicit
$set(Scala could lose them). - Admin changes update single fields; extra fields of users and roles survive.
- Files: deleting a file of more than one chunk answers
wasAcknowledged: true; the download content type comes from the file name; an invalid file id answers 400 on every file route. - A single insert omits
insertedCount/errors(optional in the spec) instead of writingnull.
Kept on purpose
In 1.x, quirks that clients may rely on stay as they were, e.g. the JSON schema keeps objectId as type name and the Lucene converter keeps the behaviour of the Scala LuceneQueryConverter (default field "", the value conversion of the Scala server). 2.0 fixes them, see Migration to 2.0.
Verification
pnpm test:contract runs the ported suites of the Scala server (and of mongodb-driver) against the in-process core; with BASE_URL, BASE_PREFIX, DATABASE and GEODATA_DATABASE it runs against any running server, e.g. the Docker image or an embedded Nuxt application (seed the database with test/contract/setup/seed.ts first).
