mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 14:06:27 +00:00
218d8baf0a
A new `integrations/dawarich` domain behind its own addon. Each reader connects their own instance; the API key is encrypted at rest and never returned. Nothing is written back to Dawarich, and no raw position is kept in TREK: the recorded route is fetched per request for the window being looked at and thrown away again. What it produces are suggestions, never facts. A recorded stay becomes a proposed place or journal entry, a country or city becomes a proposed Atlas mark, and a stay near a wish becomes a proposed tick-off; each one waits for the reader to confirm it. Identity is (user, Dawarich visit), so a second sync neither duplicates nor overwrites what was accepted, and deleting the result puts the suggestion back on the list. The sync runs as a job on the central scheduler, one user at a time, guarded against overlapping runs.
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
// Augments Express's `Request` with the fields TREK middleware + Nest guards
|
|
// attach after authentication. Replaces the per-site casts
|
|
// (`(req as AuthRequest).user`, `getRequest<Request & { user?: User }>()`) with
|
|
// a single source of truth so downstream code can read `req.user` directly.
|
|
|
|
import type { PublicApiGrant } from '@trek/shared';
|
|
import type { User } from '../types';
|
|
|
|
declare module 'express-serve-static-core' {
|
|
interface Request {
|
|
/**
|
|
* Set by `authenticate` middleware (Express) and `JwtAuthGuard` (Nest).
|
|
* Present on every route mounted behind those guards. `null` is used by
|
|
* `optionalAuthenticate` to signal "checked, but unauthenticated".
|
|
*/
|
|
user?: User | null;
|
|
/**
|
|
* What the `/api/v1` integration key presented on this request may read.
|
|
* Set by `ApiTokenGuard`, and only there.
|
|
*
|
|
* Its own field rather than something folded into `user`: the grant belongs
|
|
* to the credential, not to the person, and a cookie session has no grant at
|
|
* all. Putting it on `user` would leak a token's restrictions into every
|
|
* other auth path that happens to read the same object.
|
|
*/
|
|
apiToken?: PublicApiGrant;
|
|
}
|
|
}
|
|
|
|
// This file has imports, so TS treats it as a module. The empty export keeps
|
|
// the `declare module` augmentation visible project-wide.
|
|
export {};
|