@sfxcode/mongocamp-server-core 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @sfxcode/mongocamp-server-core
2
2
 
3
3
  The MongoCamp REST API (`openapi/docs.yaml`) as a framework-neutral core: `createMongocampServer()` returns a web standard
4
- `fetch(Request): Promise<Response>` handler. It replaces the Scala `mongocamp-server` and is hosted by `apps/server` (Nitro 3,
5
- standalone) or embedded in a Nuxt application.
4
+ `fetch(Request): Promise<Response>` handler. It is hosted by `apps/server` (Nitro 3, standalone) or embedded in a Nuxt
5
+ application.
6
6
 
7
7
  ```ts
8
8
  import { createMongocampServer } from '@sfxcode/mongocamp-server-core'
@@ -17,15 +17,22 @@ await server.close()
17
17
 
18
18
  ## Configuration
19
19
 
20
- The keys are the env variables of the Scala server (`CONNECTION_*`, `AUTH_*`, `CORS_*`, ...). Persistent keys live in
21
- `<AUTH_PREFIX>configuration` and can be changed with `PATCH /system/configurations/{key}`; env and programmatic values win.
20
+ The keys are env variables (`CONNECTION_*`, `AUTH_*`, `CORS_*`, ...). Persistent keys live in `<AUTH_PREFIX>configuration` and can be
21
+ changed with `PATCH /system/configurations/{key}`; env and programmatic values win.
22
22
 
23
- | Plugin of the Scala server | Keys |
23
+ ## Features
24
+
25
+ Optional parts that a host switches on with `server.use(...)`, in Nitro from a plugin on `mongocamp:ready`:
26
+
27
+ | Feature | Content |
24
28
  | --- | --- |
25
- | request logging | `REQUESTLOGGING_ENABLED` — every request is a document of `<AUTH_PREFIX>request_logging` |
26
- | micrometer | `METRICS_ENABLED` — `GET /system/monitoring/{jvm,system,mongodb,events,prometheus}`; `METRICS_MONGODB_*` select the MongoDB metrics, `LOGGING_METRICS_MONGODB_*` write snapshots into `monitoring_*` every `LOGGING_METRICS_MONGODB_STEP` |
29
+ | `requestLogging()` | every request is a document of `<AUTH_PREFIX>request_logging` |
30
+ | `metrics()` | `GET /system/monitoring/{runtime,system,mongodb,events,prometheus}` (404 while off); `METRICS_MONGODB_*` select the MongoDB metrics, `LOGGING_METRICS_MONGODB_*` write snapshots into `monitoring_*` every `LOGGING_METRICS_MONGODB_STEP` |
27
31
 
28
- The category `jvm` holds the numbers of the Node runtime (`nodejs_*`).
32
+ `REQUESTLOGGING_ENABLED` / `METRICS_ENABLED` still switch them on in the core with a deprecation warning (removed in 3.0); `featureSwitches:
33
+ false` turns that off. `apps/server` reads the two settings in its own Nitro plugin.
34
+
35
+ The category `runtime` holds the numbers of the Node runtime (`nodejs_*`).
29
36
 
30
37
  ## Logging
31
38
 
@@ -36,7 +43,17 @@ the event of `evlog/nuxt` when the application uses it.
36
43
 
37
44
  ## Extensions
38
45
 
39
- The dynamic JVM plugins of the Scala server are replaced by three things a host can use.
46
+ In Nitro, extensions are Nitro 3 plugins: `connectHooks(server, nitroApp.hooks)` (done by `apps/server` and the Nuxt module) calls
47
+ `mongocamp:ready` with the started server and forwards every event as a hook `mongocamp:<event>`:
48
+
49
+ ```ts
50
+ export default definePlugin((nitroApp) => {
51
+ nitroApp.hooks.hook('mongocamp:ready', server => server.use(metrics()))
52
+ nitroApp.hooks.hook('mongocamp:document:update', event => audit(event))
53
+ })
54
+ ```
55
+
56
+ Expensive parts of an event are only read for hooks with a listener. Without Nitro, a host uses the server directly:
40
57
 
41
58
  ### Events
42
59