feat(auth): add row/size caps + streaming to export-user-data
- Add per-collection row cap (default 10k, env EXPORT_ROW_CAP) via Prisma take on all findMany calls - Add total size cap (default 100MB, env EXPORT_SIZE_CAP_MB); throws PayloadTooLargeException (413) when exceeded - Convert response to Node.js Readable stream piped via NestJS StreamableFile to avoid large in-memory buffers - Export ExportUserDataResult interface (stream + truncated flag) from handler - Update controller to set Content-Type/Content-Disposition headers and return StreamableFile - Document EXPORT_ROW_CAP and EXPORT_SIZE_CAP_MB env vars in Swagger - Extend tests: row-cap assertion (take arg), size-cap 413 path, stream assertions Fixes GOO-223 (M-1 from GOO-200 audit). Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -10,6 +10,9 @@ import {
|
||||
HTTP_REQUESTS_TOTAL,
|
||||
GOODGO_WS_CONNECTED_CLIENTS,
|
||||
GOODGO_WS_MESSAGES_TOTAL,
|
||||
READ_MODEL_PROJECTOR_LAG_SECONDS,
|
||||
READ_MODEL_REFRESH_DURATION_SECONDS,
|
||||
READ_MODEL_RECONCILIATION_DRIFT_TOTAL,
|
||||
WEB_VITALS_LCP,
|
||||
WEB_VITALS_FCP,
|
||||
WEB_VITALS_CLS,
|
||||
@@ -37,6 +40,12 @@ export class MetricsService {
|
||||
private readonly wsConnectedClientsGauge: Gauge,
|
||||
@InjectMetric(GOODGO_WS_MESSAGES_TOTAL)
|
||||
private readonly wsMessagesCounter: Counter,
|
||||
@InjectMetric(READ_MODEL_PROJECTOR_LAG_SECONDS)
|
||||
private readonly projectorLagGauge: Gauge,
|
||||
@InjectMetric(READ_MODEL_REFRESH_DURATION_SECONDS)
|
||||
private readonly readModelRefreshHistogram: Histogram,
|
||||
@InjectMetric(READ_MODEL_RECONCILIATION_DRIFT_TOTAL)
|
||||
private readonly reconciliationDriftCounter: Counter,
|
||||
@InjectMetric(WEB_VITALS_LCP)
|
||||
private readonly lcpHistogram: Histogram,
|
||||
@InjectMetric(WEB_VITALS_FCP)
|
||||
@@ -106,6 +115,21 @@ export class MetricsService {
|
||||
this.wsMessagesCounter.inc({ namespace, event, direction });
|
||||
}
|
||||
|
||||
/** Set current projector lag (seconds behind source stream) for a handler. */
|
||||
setProjectorLag(handler: string, lagSeconds: number): void {
|
||||
this.projectorLagGauge.set({ handler }, lagSeconds);
|
||||
}
|
||||
|
||||
/** Record the duration of a read-model view refresh. */
|
||||
recordReadModelRefresh(view: string, durationSeconds: number): void {
|
||||
this.readModelRefreshHistogram.observe({ view }, durationSeconds);
|
||||
}
|
||||
|
||||
/** Increment the reconciliation drift counter for a read model. */
|
||||
recordReconciliationDrift(model: string, count = 1): void {
|
||||
this.reconciliationDriftCounter.inc({ model }, count);
|
||||
}
|
||||
|
||||
/** Map metric name → the correct histogram. */
|
||||
private readonly vitalHistograms: Record<string, Histogram | undefined> = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user