mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
6dda05f672
Eight files in services/ hold no state and touch no database: avatarUrl, conflictResult, demo, passwordPolicy, timezoneService, cookie, and the two crypto helpers. They are imported from 65 places, 62 of them already inside src/nest, so having them live in the legacy layer was pure inertia. They stay plain functions rather than becoming providers. Three importers sit outside the container and would have no way to reach an injectable one: db/migrations.ts runs before the app is built, and middleware/auth.ts and middleware/mfaPolicy.ts run beside it. Wrapping these in DI would buy ceremony and nothing else. mfaCrypto and apiKeyCrypto move together into common/crypto — they read the same ENCRYPTION_KEY, and the directory says so. services/ drops from 44 files to 36, 9,870 lines to 8,493. One trap worth recording: src/app-config and src/nest/app-config both exist. cookie.ts imported '../app-config' from services/, which resolved to the former; after the move the same string silently pointed at the latter, which has no readEnv. It is now explicit about which one it wants. Nothing else changes — no signatures, no behaviour, no tests rewritten beyond their import paths.
18 lines
756 B
TypeScript
18 lines
756 B
TypeScript
/**
|
|
* Optimistic-concurrency result shared by the entity update services (#1135).
|
|
*
|
|
* When a client replays an offline edit it may send `X-Base-Updated-At` — the
|
|
* `updated_at` the edit was based on. If the row has moved on since, the update
|
|
* service returns this sentinel instead of overwriting, and the controller turns
|
|
* it into a 409 carrying the server's current version so the client can let the
|
|
* user resolve the conflict. Absent token => unconditional update (back-compat).
|
|
*/
|
|
export interface UpdateConflict {
|
|
conflict: true;
|
|
server: unknown;
|
|
}
|
|
|
|
export function isUpdateConflict(result: unknown): result is UpdateConflict {
|
|
return !!result && typeof result === 'object' && (result as { conflict?: unknown }).conflict === true;
|
|
}
|