1010- [ Priority Routes] ( #priority-routes )
1111- [ Sync Routes] ( #sync-routes )
1212- [ Event Routes] ( #event-routes )
13+ - [ Operational Headers] ( #operational-headers )
1314
1415---
1516
@@ -54,8 +55,21 @@ Failure response:
5455
5556### /api/calendars
5657
58+ Authenticated calendar list endpoints:
59+
60+ - ` GET /api/calendars `
61+ - middleware: ` verifySession() `
62+ - returns all calendar records available to the authenticated user
63+ - ` POST /api/calendars `
64+ - middleware: ` verifySession() `
65+ - creates a calendar record for the authenticated user
66+
5767### /api/calendars/select
5868
69+ - ` PUT /api/calendars/select `
70+ - middleware: ` verifySession() `
71+ - toggles selected calendars used for sync/display
72+
5973---
6074
6175## Auth Routes
@@ -64,11 +78,41 @@ Failure response:
6478
6579### /api/auth/session
6680
67- Development helper endpoint (guarded by ` verifyIsDev ` ):
81+ Compass-defined development helper endpoint (guarded by ` verifyIsDev ` ):
6882
6983- ` POST /api/auth/session ` creates a session for a provided Compass user id
7084- ` GET /api/auth/session ` returns the current session user id
7185
86+ ` POST /api/auth/session ` request example:
87+
88+ ``` json
89+ {
90+ "cUserId" : " 67c9c6d49e2f3f65e0f44a1a"
91+ }
92+ ```
93+
94+ Behavior constraints:
95+
96+ - route is intended for development workflows only
97+ - ` cUserId ` must be a valid Mongo ObjectId string
98+ - ` GET ` also requires ` verifySession() `
99+
100+ ### SuperTokens-managed auth endpoints (runtime)
101+
102+ Files:
103+
104+ - ` packages/backend/src/common/middleware/supertokens.middleware.ts `
105+ - ` packages/web/src/auth/session/SessionProvider.tsx `
106+ - ` packages/web/src/common/apis/auth.api.ts `
107+
108+ The web app uses SuperTokens APIs mounted under ` /api ` :
109+
110+ - ` POST /api/signinup ` (Google OAuth sign-in/up exchange used by ` AuthApi.loginOrSignup ` )
111+ - ` POST /api/signout ` (session sign-out)
112+ - ` POST /api/session/refresh ` (session refresh)
113+
114+ These endpoints are framework-managed by the SuperTokens recipes configured in ` initSupertokens() ` , not by ` auth.routes.config.ts ` .
115+
72116---
73117
74118## User Routes
@@ -77,6 +121,10 @@ Development helper endpoint (guarded by `verifyIsDev`):
77121
78122### /api/user/profile
79123
124+ - ` GET /api/user/profile `
125+ - middleware: ` verifySession() `
126+ - returns current user profile for the active session user
127+
80128### /api/user/metadata
81129
82130` /api/user/metadata ` notes:
@@ -104,7 +152,10 @@ Current metadata shape used by sync/auth flows:
104152
105153** Source** : ` packages/backend/src/common/common.routes.config.ts `
106154
107- _ Review the source file for route definitions_
155+ ` CommonRoutesConfig ` is an abstract base class for route modules.
156+
157+ - no public API endpoints are defined in this module
158+ - endpoint paths live in feature route config files (` *.routes.config.ts ` )
108159
109160---
110161
@@ -114,8 +165,24 @@ _Review the source file for route definitions_
114165
115166### /api/priority
116167
168+ - ` GET /api/priority `
169+ - middleware: ` verifySession() `
170+ - returns all priority entities for current user
171+ - ` POST /api/priority `
172+ - middleware: ` verifySession() `
173+ - creates a priority entity
174+
117175### /api/priority/: id
118176
177+ - ` GET /api/priority/:id `
178+ - ` PUT /api/priority/:id `
179+ - ` DELETE /api/priority/:id `
180+
181+ Shared middleware for ` :id ` routes:
182+
183+ - ` verifySession() `
184+ - ` validateIdParam ` (ensures ` :id ` is a valid ObjectId)
185+
119186---
120187
121188## Sync Routes
@@ -126,6 +193,11 @@ _Review the source file for route definitions_
126193
127194Google push-notification ingress endpoint (Google-only caller).
128195
196+ Resolved path from ` GCAL_NOTIFICATION_ENDPOINT ` :
197+
198+ - ` POST /api/sync/gcal/notifications `
199+ - middleware: ` authMiddleware.verifyIsFromGoogle `
200+
129201Observed outcomes:
130202
131203- ` 200 ` with ` "INITIALIZED" ` on channel handshake notifications
@@ -135,6 +207,11 @@ Observed outcomes:
135207
136208### /api/sync/maintain-all
137209
210+ - ` POST /api/sync/maintain-all `
211+ - middleware: ` authMiddleware.verifyIsFromCompass `
212+ - intended caller: trusted internal job/function with ` x-comp-token `
213+ - controller uses a 5-minute timeout guard and may return ` 504 ` on timeout while work continues
214+
138215### /api/sync/import-gcal
139216
140217Authenticated user trigger for full import restart:
@@ -145,18 +222,40 @@ Authenticated user trigger for full import restart:
145222
146223### /api/event-change-demo
147224
225+ - ` POST /api/event-change-demo `
226+ - debug helper route used to dispatch event-change notifications to a configured demo socket user
227+
148228### ${SYNC_DEBUG}/import-incremental/: userId
149229
230+ - ` POST /api/sync/debug/import-incremental/:userId `
231+ - middleware: ` verifyIsFromCompass ` + ` requireGoogleConnectionFrom("userId") `
232+
150233### ${SYNC_DEBUG}/maintain/: userId
151234
235+ - ` POST /api/sync/debug/maintain/:userId?dry=true|false `
236+ - middleware: ` verifyIsFromCompass ` + ` requireGoogleConnectionFrom("userId") `
237+ - ` dry ` query controls dry-run mode
238+
152239### ${SYNC_DEBUG}/refresh/: userId
153240
241+ - ` POST /api/sync/debug/refresh/:userId `
242+ - middleware: ` verifyIsFromCompass ` + ` requireGoogleConnectionFrom("userId") `
243+
154244### ${SYNC_DEBUG}/start
155245
246+ - ` POST /api/sync/debug/start `
247+ - middleware: ` verifyIsFromCompass ` + ` verifySession() ` + ` requireGoogleConnectionSession `
248+
156249### ${SYNC_DEBUG}/stop
157250
251+ - ` POST /api/sync/debug/stop `
252+ - middleware: ` verifyIsFromCompass ` + ` verifySession() ` + ` requireGoogleConnectionSession `
253+
158254### ${SYNC_DEBUG}/stop-all/: userId
159255
256+ - ` POST /api/sync/debug/stop-all/:userId `
257+ - middleware: ` verifyIsFromCompass ` + ` requireGoogleConnectionFrom("userId") `
258+
160259---
161260
162261## Event Routes
@@ -165,14 +264,35 @@ Authenticated user trigger for full import restart:
165264
166265### /api/event
167266
267+ - ` GET /api/event `
268+ - middleware: ` verifySession() `
269+ - ` POST /api/event `
270+ - middleware: ` verifySession() ` + ` requireGoogleConnectionSession `
271+
168272### /api/event/deleteMany
169273
274+ - ` DELETE /api/event/deleteMany `
275+ - middleware: ` verifySession() `
276+
170277### /api/event/reorder
171278
279+ - ` PUT /api/event/reorder `
280+ - middleware: ` verifySession() `
281+
172282### /api/event/delete-all/: userId
173283
284+ - ` DELETE /api/event/delete-all/:userId `
285+ - middleware: ` verifySession() ` + ` authMiddleware.verifyIsDev `
286+
174287### /api/event/: id
175288
289+ - ` GET /api/event/:id `
290+ - middleware: ` verifySession() `
291+ - ` PUT /api/event/:id `
292+ - middleware: ` verifySession() ` + ` requireGoogleConnectionSession `
293+ - ` DELETE /api/event/:id `
294+ - middleware: ` verifySession() ` + ` requireGoogleConnectionSession `
295+
176296Write semantics:
177297
178298- ` POST /api/event ` , ` PUT /api/event/:id ` , ` DELETE /api/event/:id ` require Google connection middleware
@@ -187,7 +307,7 @@ Most endpoints require authentication via Supertokens session management.
187307
188308** Authentication Flow** :
189309
190- 1 . Client initiates OAuth flow via ` /api/auth `
310+ 1 . Client initiates OAuth exchange via SuperTokens endpoints (for example ` POST /api/signinup ` )
1913112 . User authenticates with Google
1923123 . Session cookie is set
1933134 . Subsequent requests include session cookie
@@ -197,6 +317,31 @@ Authentication exceptions:
197317
198318- ` GET /api/health ` is intentionally unauthenticated for monitoring and load balancer probes
199319
320+ ## Operational Headers
321+
322+ Source files:
323+
324+ - ` packages/backend/src/auth/middleware/auth.middleware.ts `
325+ - ` packages/backend/src/sync/sync.routes.config.ts `
326+ - ` packages/backend/src/sync/util/sync.util.ts `
327+
328+ Important non-cookie auth headers:
329+
330+ - ` x-comp-token `
331+ - required for Compass-internal sync routes guarded by ` verifyIsFromCompass `
332+ - must match ` ENV.TOKEN_COMPASS_SYNC `
333+ - Google notification headers (` x-goog-* ` )
334+ - required for notification ingress guarded by ` verifyIsFromGoogle `
335+ - include channel metadata and signed channel token used to validate origin
336+
337+ Operational example (` /api/sync/maintain-all ` ):
338+
339+ ``` bash
340+ curl -i -X POST \
341+ -H " x-comp-token: $TOKEN_COMPASS_SYNC " \
342+ /api/sync/maintain-all
343+ ```
344+
200345## Common Patterns
201346
202347### Route Configuration
@@ -244,7 +389,8 @@ When this payload accompanies `401` or `410`, web clients should keep the sessio
244389
245390## Key Endpoints
246391
247- - ` /api/auth/* ` - Authentication and OAuth flows
392+ - ` /api/auth/session ` - dev session helper route
393+ - ` /api/signinup ` , ` /api/signout ` , ` /api/session/* ` - SuperTokens auth/session APIs
248394- ` /api/user/* ` - User profile and metadata
249395- ` /api/event/* ` - Calendar event CRUD operations
250396- ` /api/calendars/* ` - Calendar list and selection
0 commit comments