You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Hot reload | Startup-only for v1 | Simpler implementation; can be added later |
27
27
| Registry API | Adapters only (no public registry) | Clean boundary, single integration point |
28
28
| Implementation location | In parse-server directly | Core server functionality |
29
-
| Webhook key | Explicitly configured (required) | No auto-generation, no persistence question |
29
+
| Webhook key | Explicitly configured (required) | No auto-generation, no persistence question. Diverges from proposal which offered auto-generation.|
30
30
| Language | TypeScript | Type safety throughout |
31
31
| Architecture | Replace triggers.js entirely | CloudCodeManager becomes single source of truth |
32
+
| applicationId scoping | One CloudCodeManager per app | Stored on `Config`, mirrors existing `_triggerStore[applicationId]` pattern |
32
33
33
34
## 3. Architecture
34
35
35
36
### 3.1 CloudCodeManager — The New Core
36
37
37
-
`CloudCodeManager` replaces `triggers.js` as the single source of truth for all hook registration, lookup, and execution.
38
+
`CloudCodeManager` replaces `triggers.js` as the single source of truth for all hook registration, lookup, and execution. One instance exists per `applicationId`, stored on the app's `Config` object.
|`beforeSubscribe`| class name |`defineTrigger('Todo', 'beforeSubscribe', handler)`|
141
+
142
+
This matches the existing internal storage pattern in `triggers.js` where `getClassName(Parse.File)` returns `'@File'`. The LegacyAdapter maps `Parse.Cloud.beforeSaveFile(handler)` to `defineTrigger('@File', 'beforeSave', handler)`, and `Parse.Cloud.beforeConnect(handler)` to `defineTrigger('@Connect', 'beforeConnect', handler)`.
143
+
121
144
## 4. Built-in Adapter Implementations
122
145
123
146
### 4.1 LegacyAdapter
@@ -169,7 +192,7 @@ Wraps `cloudCodeCommand: 'swift run CloudCode'`.
169
192
-`initialize()` spawns child process with environment variables, waits for `PARSE_CLOUD_READY:<port>` on stdout, fetches manifest via `GET http://localhost:<port>/`, registers bridge handlers.
-`shutdown()` sends `SIGTERM`, waits `shutdownTimeout`, then `SIGKILL`.
172
-
- Crash recovery: unregisters hooks, restarts with exponential backoff (1s, 2s, 4s, 8s, capped at `maxRestartDelay`).
195
+
- Crash recovery: the `CloudCodeManager` calls `unregisterAll(adapter.name)` internally, then the adapter restarts with exponential backoff (1s, 2s, 4s, 8s, capped at `maxRestartDelay`).
173
196
174
197
**Environment variables passed to child process:**
175
198
@@ -269,6 +292,7 @@ function resolveAdapters(options: ParseServerOptions): CloudCodeAdapter[] {
269
292
|`RestQuery.js`|`getTrigger`, `maybeRunTrigger`| Import from `CloudCodeManager`|
270
293
|`UsersRouter.js`|`getTrigger` (login/logout) | Import from `CloudCodeManager`|
271
294
|`FilesRouter.js`|`getTrigger` (file triggers) | Import from `CloudCodeManager`|
295
+
|`GlobalConfigRouter.js`|`maybeRunGlobalConfigTrigger`| Import from `CloudCodeManager`|
272
296
|`LiveQuery/`|`getTrigger`, `maybeRunTrigger`, connect/subscribe | Import from `CloudCodeManager`|
273
297
|`Config.js`| Validates cloud config | Updated for new options |
274
298
@@ -307,7 +331,17 @@ class LegacyAdapter implements CloudCodeAdapter {
307
331
308
332
### 6.4 Utility Functions
309
333
310
-
Pure data transformation helpers from `triggers.js` (`getRequestObject()`, `getResponseObject()`, `resolveError()`, `toJSONwithObjects()`) move to `src/cloud-code/request-utils.ts`. They have no dependency on the hook store.
334
+
Pure data transformation helpers from `triggers.js` move to `src/cloud-code/request-utils.ts`. They have no dependency on the hook store:
335
+
336
+
-`getRequestObject()`, `getResponseObject()` — build request/response objects for trigger handlers
337
+
-`getRequestQueryObject()` — build request for query triggers
338
+
-`resolveError()` — normalize error responses
339
+
-`toJSONwithObjects()` — serialize with Parse object preservation
340
+
-`inflate()` — inflate REST data into Parse Objects (used by `RestWrite.js`)
341
+
342
+
### 6.5 Validators and Rate Limiting
343
+
344
+
Validators (including `requireUser`, `requireMaster`, `fields`, `rateLimit`) are supported only through the `LegacyAdapter`. Non-legacy adapters (InProcess, External) handle validation within their own process — Parse Server does not apply server-side validators for hooks registered by these adapters. Rate limiting middleware integration (`addRateLimit`) is handled by the `LegacyAdapter` during `initialize()`, preserving existing behavior.
0 commit comments