From 826af554b824d5815700584221f2d04f665a488a Mon Sep 17 00:00:00 2001 From: johnsmccain Date: Sun, 29 Mar 2026 05:35:01 +0100 Subject: [PATCH 1/2] feat: add timestamp header helper for public creator responses --- src/modules/creator/creator.controller.ts | 2 + src/modules/creators/creators.controllers.ts | 3 ++ src/utils/timestamp-headers.utils.ts | 39 ++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 src/utils/timestamp-headers.utils.ts diff --git a/src/modules/creator/creator.controller.ts b/src/modules/creator/creator.controller.ts index ad5ed45..c5b22bd 100644 --- a/src/modules/creator/creator.controller.ts +++ b/src/modules/creator/creator.controller.ts @@ -7,6 +7,7 @@ import { sendValidationError, ErrorCode, } from '../../utils/api-response.utils'; +import { attachTimestampHeader } from '../../utils/timestamp-headers.utils'; import { getPaginatedCreators } from './creator.service'; import { parseCreatorSortOptions } from './creator.utils'; import { safeIntParam } from '../../utils/query.utils'; @@ -59,6 +60,7 @@ export async function listCreators(req: Request, res: Response) { sort, }); + attachTimestampHeader(res); return sendSuccess( res, wrapPublicCreatorListResponse(creators, meta), diff --git a/src/modules/creators/creators.controllers.ts b/src/modules/creators/creators.controllers.ts index cfff38c..97852c0 100644 --- a/src/modules/creators/creators.controllers.ts +++ b/src/modules/creators/creators.controllers.ts @@ -11,6 +11,7 @@ import { sendSuccess, sendValidationError, } from '../../utils/api-response.utils'; +import { attachTimestampHeader } from '../../utils/timestamp-headers.utils'; import { parsePublicQuery } from '../../utils/public-query-parse.utils'; import { buildOffsetPaginationMeta } from '../../utils/pagination.utils'; import { buildCreatorListRequestContext } from './creator-list-context.utils'; @@ -44,6 +45,7 @@ export const httpListCreators: AsyncController = async (req, res, next) => { }) ); + attachTimestampHeader(res); sendSuccess(res, response); } catch (error) { next(error); @@ -79,6 +81,7 @@ export const httpGetCreatorStats: AsyncController = async (req, res, next) => { // Serialize using the public stats mapper const stats = mapPublicCreatorStats(placeholderMetrics); + attachTimestampHeader(res); sendSuccess(res, stats); } catch (error) { next(error); diff --git a/src/utils/timestamp-headers.utils.ts b/src/utils/timestamp-headers.utils.ts new file mode 100644 index 0000000..7368fec --- /dev/null +++ b/src/utils/timestamp-headers.utils.ts @@ -0,0 +1,39 @@ +// src/utils/timestamp-headers.utils.ts +// Centralizes timestamp header formatting for public creator-facing responses. + +import { Response } from 'express'; + +/** + * Header name used to communicate the server-side response timestamp to clients. + * + * Clients can use this to detect stale cached responses or correlate + * request timing without parsing the response body. + */ +export const RESPONSE_TIMESTAMP_HEADER = 'X-Response-Timestamp'; + +/** + * Formats a Date as an ISO 8601 string suitable for use in HTTP headers. + * + * @param date - Defaults to `new Date()` (now) + * @returns ISO 8601 UTC string, e.g. "2026-03-29T12:00:00.000Z" + */ +export function formatTimestampHeader(date: Date = new Date()): string { + return date.toISOString(); +} + +/** + * Attaches an `X-Response-Timestamp` header to the response. + * + * Call this before sending any public creator response so clients + * receive a consistent, parseable timestamp on every reply. + * + * @param res - Express response object + * @param date - Timestamp to attach; defaults to now + * + * @example + * attachTimestampHeader(res); + * sendSuccess(res, data); + */ +export function attachTimestampHeader(res: Response, date: Date = new Date()): void { + res.set(RESPONSE_TIMESTAMP_HEADER, formatTimestampHeader(date)); +} From 6ea35d1dca290b4d707d3966c30865ba980afb31 Mon Sep 17 00:00:00 2001 From: johnsmccain Date: Sun, 29 Mar 2026 05:50:48 +0100 Subject: [PATCH 2/2] fix: enable prismaSchemaFolder to include all model files in client generation --- prisma/schema/schema.prisma | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prisma/schema/schema.prisma b/prisma/schema/schema.prisma index 00e10fe..2be1739 100644 --- a/prisma/schema/schema.prisma +++ b/prisma/schema/schema.prisma @@ -5,8 +5,9 @@ // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init generator client { - provider = "prisma-client-js" - output = "../../node_modules/.prisma/client" + provider = "prisma-client-js" + output = "../../node_modules/.prisma/client" + previewFeatures = ["prismaSchemaFolder"] } datasource db {