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:
32
libs/contracts/events/schemas/payment.completed.schema.json
Normal file
32
libs/contracts/events/schemas/payment.completed.schema.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://goodgo.vn/schemas/events/payment.completed.schema.json",
|
||||
"title": "payment.completed",
|
||||
"description": "Emitted when a Payment aggregate transitions to SUCCEEDED after a verified gateway IPN (VNPay / MoMo / ZaloPay).",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"paymentId",
|
||||
"orderId",
|
||||
"userId",
|
||||
"amount",
|
||||
"currency",
|
||||
"gateway",
|
||||
"gatewayTransactionId",
|
||||
"paidAt"
|
||||
],
|
||||
"properties": {
|
||||
"paymentId": { "type": "string", "minLength": 1 },
|
||||
"orderId": { "type": "string", "minLength": 1 },
|
||||
"userId": { "type": "string", "minLength": 1 },
|
||||
"amount": {
|
||||
"type": "string",
|
||||
"pattern": "^-?\\d+(\\.\\d+)?$",
|
||||
"description": "Decimal as string to preserve VND precision (no float rounding)."
|
||||
},
|
||||
"currency": { "type": "string", "enum": ["VND", "USD"] },
|
||||
"gateway": { "type": "string", "enum": ["vnpay", "momo", "zalopay"] },
|
||||
"gatewayTransactionId": { "type": "string", "minLength": 1 },
|
||||
"paidAt": { "type": "string", "format": "date-time" }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user