@rpcbase/server 0.563.0 → 0.565.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/applyRouteLoaders.d.ts +2 -2
- package/dist/applyRouteLoaders.d.ts.map +1 -1
- package/dist/{handler-D7wE1EUT.js → handler-BTtU7fJq.js} +58 -4
- package/dist/handler-BTtU7fJq.js.map +1 -0
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/notifications/api/notifications/handler.d.ts.map +1 -1
- package/dist/notifications/api/notifications/index.d.ts +12 -0
- package/dist/notifications/api/notifications/index.d.ts.map +1 -1
- package/dist/notifications/createNotification.d.ts +5 -0
- package/dist/notifications/createNotification.d.ts.map +1 -1
- package/dist/notifications/digest.d.ts.map +1 -1
- package/dist/notifications.js +79 -8
- package/dist/notifications.js.map +1 -1
- package/dist/renderSSR.d.ts +1 -1
- package/dist/renderSSR.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/handler-D7wE1EUT.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Request } from 'express';
|
|
1
|
+
import { Request as ExpressRequest, Response as ExpressResponse } from 'express';
|
|
2
2
|
import { StaticHandlerContext } from '@rpcbase/router';
|
|
3
3
|
export type RouterContextWithRedirect = StaticHandlerContext & {
|
|
4
4
|
redirectResponse?: Response;
|
|
5
5
|
redirectRouteId?: string | null;
|
|
6
6
|
redirectRoutePath?: string | null;
|
|
7
7
|
};
|
|
8
|
-
export declare function applyRouteLoaders(req:
|
|
8
|
+
export declare function applyRouteLoaders(req: ExpressRequest, res: ExpressResponse, dataRoutes: any[]): Promise<RouterContextWithRedirect>;
|
|
9
9
|
//# sourceMappingURL=applyRouteLoaders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyRouteLoaders.d.ts","sourceRoot":"","sources":["../src/applyRouteLoaders.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"applyRouteLoaders.d.ts","sourceRoot":"","sources":["../src/applyRouteLoaders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAA;AAChF,OAAO,EACL,oBAAoB,EAMrB,MAAM,iBAAiB,CAAA;AAmHxB,MAAM,MAAM,yBAAyB,GAAG,oBAAoB,GAAG;IAC7D,gBAAgB,CAAC,EAAE,QAAQ,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,GAAG,EAAE,GAChB,OAAO,CAAC,yBAAyB,CAAC,CA8MpC"}
|
|
@@ -41,6 +41,7 @@ const notificationPlatformPayloadSchema = object({
|
|
|
41
41
|
apns: record(string(), unknown()).optional()
|
|
42
42
|
}).passthrough();
|
|
43
43
|
const createRequestStringSchema = string().trim();
|
|
44
|
+
const notificationUrlModeSchema = _enum(["navigate", "merge_current_search"]);
|
|
44
45
|
const notificationContentFieldsSchema = object({
|
|
45
46
|
title: string().min(1),
|
|
46
47
|
body: string().optional(),
|
|
@@ -51,6 +52,9 @@ const createRequestSchema = object({
|
|
|
51
52
|
title: createRequestStringSchema.min(1),
|
|
52
53
|
body: createRequestStringSchema.optional(),
|
|
53
54
|
image: createRequestStringSchema.optional(),
|
|
55
|
+
url: createRequestStringSchema.min(1).optional(),
|
|
56
|
+
urlMode: notificationUrlModeSchema.optional(),
|
|
57
|
+
metadata: record(string(), unknown()).optional(),
|
|
54
58
|
data: notificationDataSchema.optional(),
|
|
55
59
|
platform: notificationPlatformPayloadSchema.optional()
|
|
56
60
|
});
|
|
@@ -66,6 +70,19 @@ const normalizeNotificationActionUrl = (url, origin) => {
|
|
|
66
70
|
return null;
|
|
67
71
|
}
|
|
68
72
|
};
|
|
73
|
+
const normalizeNotificationActionLink = (url, origin, urlMode = "navigate") => {
|
|
74
|
+
const raw = url.trim();
|
|
75
|
+
if (!raw) return null;
|
|
76
|
+
try {
|
|
77
|
+
const base = new URL(origin);
|
|
78
|
+
const parsed = new URL(raw, base);
|
|
79
|
+
if (parsed.origin !== base.origin) return null;
|
|
80
|
+
if (urlMode === "navigate") return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
81
|
+
return `${parsed.search}${parsed.hash}` || null;
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
69
86
|
const notificationSchema = object({
|
|
70
87
|
id: string(),
|
|
71
88
|
topic: string().optional(),
|
|
@@ -167,7 +184,10 @@ const getRequestOrigin = (ctx) => {
|
|
|
167
184
|
const getNotificationActionLinks = (notification) => {
|
|
168
185
|
const links = [];
|
|
169
186
|
if (typeof notification.data?.link === "string") {
|
|
170
|
-
links.push(
|
|
187
|
+
links.push({
|
|
188
|
+
link: notification.data.link,
|
|
189
|
+
urlMode: notification.data.linkMode === "merge_current_search" ? "merge_current_search" : "navigate"
|
|
190
|
+
});
|
|
171
191
|
}
|
|
172
192
|
const platformWebpush = notification.platform?.webpush;
|
|
173
193
|
if (platformWebpush && typeof platformWebpush === "object" && !Array.isArray(platformWebpush)) {
|
|
@@ -175,12 +195,34 @@ const getNotificationActionLinks = (notification) => {
|
|
|
175
195
|
if (fcmOptions && typeof fcmOptions === "object" && !Array.isArray(fcmOptions)) {
|
|
176
196
|
const link = fcmOptions.link;
|
|
177
197
|
if (typeof link === "string") {
|
|
178
|
-
links.push(
|
|
198
|
+
links.push({
|
|
199
|
+
link,
|
|
200
|
+
urlMode: "navigate"
|
|
201
|
+
});
|
|
179
202
|
}
|
|
180
203
|
}
|
|
181
204
|
}
|
|
182
205
|
return links;
|
|
183
206
|
};
|
|
207
|
+
const actionSearchParamsMatchTargetUrl = (actionUrl, targetUrl, origin) => {
|
|
208
|
+
try {
|
|
209
|
+
const base = new URL(origin);
|
|
210
|
+
const action = new URL(actionUrl, base);
|
|
211
|
+
const target = new URL(targetUrl, base);
|
|
212
|
+
for (const [key, value] of action.searchParams) {
|
|
213
|
+
if (target.searchParams.get(key) !== value) return false;
|
|
214
|
+
}
|
|
215
|
+
return Array.from(action.searchParams.keys()).length > 0;
|
|
216
|
+
} catch {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const notificationActionLinkMatchesUrl = (action, targetUrl, origin) => {
|
|
221
|
+
if (action.urlMode === "merge_current_search") {
|
|
222
|
+
return actionSearchParamsMatchTargetUrl(action.link, targetUrl, origin);
|
|
223
|
+
}
|
|
224
|
+
return normalizeNotificationActionUrl(action.link, origin) === targetUrl;
|
|
225
|
+
};
|
|
184
226
|
const buildDisabledTopics = (settings, key) => {
|
|
185
227
|
const raw = settings?.topicPreferences;
|
|
186
228
|
if (!Array.isArray(raw) || raw.length === 0) return [];
|
|
@@ -355,12 +397,24 @@ const createNotificationForCurrentUser = async (payload, ctx) => {
|
|
|
355
397
|
error: "invalid_payload"
|
|
356
398
|
};
|
|
357
399
|
}
|
|
400
|
+
const origin = getRequestOrigin(ctx);
|
|
401
|
+
const actionLink = parsed.data.url ? normalizeNotificationActionLink(parsed.data.url, origin, parsed.data.urlMode) ?? void 0 : void 0;
|
|
402
|
+
if (parsed.data.url && !actionLink) {
|
|
403
|
+
ctx.res.status(400);
|
|
404
|
+
return {
|
|
405
|
+
ok: false,
|
|
406
|
+
error: "invalid_payload"
|
|
407
|
+
};
|
|
408
|
+
}
|
|
358
409
|
const created = await createNotification(ctx, {
|
|
359
410
|
userId: session.userId,
|
|
360
411
|
topic: parsed.data.topic,
|
|
361
412
|
title: parsed.data.title,
|
|
362
413
|
body: parsed.data.body,
|
|
363
414
|
image: parsed.data.image,
|
|
415
|
+
url: actionLink,
|
|
416
|
+
urlMode: parsed.data.urlMode,
|
|
417
|
+
metadata: parsed.data.metadata,
|
|
364
418
|
data: parsed.data.data,
|
|
365
419
|
platform: parsed.data.platform
|
|
366
420
|
}, ability);
|
|
@@ -495,7 +549,7 @@ const markReadByUrl = async (payload, ctx) => {
|
|
|
495
549
|
data: 1,
|
|
496
550
|
platform: 1
|
|
497
551
|
}).lean();
|
|
498
|
-
const matchingIds = candidates.filter((notification) => getNotificationActionLinks(notification).some((
|
|
552
|
+
const matchingIds = candidates.filter((notification) => getNotificationActionLinks(notification).some((action) => notificationActionLinkMatchesUrl(action, targetUrl, origin))).map((notification) => notification._id);
|
|
499
553
|
if (matchingIds.length === 0) {
|
|
500
554
|
return markReadByUrlResponseSchema.parse({
|
|
501
555
|
ok: true,
|
|
@@ -839,4 +893,4 @@ const handler = (api) => {
|
|
|
839
893
|
export {
|
|
840
894
|
handler as default
|
|
841
895
|
};
|
|
842
|
-
//# sourceMappingURL=handler-
|
|
896
|
+
//# sourceMappingURL=handler-BTtU7fJq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-BTtU7fJq.js","sources":["../src/notifications/api/notifications/shared.ts","../src/notifications/api/notifications/index.ts","../src/notifications/api/notifications/handler.ts"],"sourcesContent":["import type { Ctx } from \"@rpcbase/api\"\n\n\ntype NotificationSessionUser = {\n id?: unknown\n currentTenantId?: unknown\n}\n\nexport const getSessionUser = (ctx: Ctx) => {\n const rawSessionUser = (ctx.req.session as { user?: NotificationSessionUser } | null | undefined)?.user\n const userId = typeof rawSessionUser?.id === \"string\" ? rawSessionUser.id.trim() : \"\"\n const tenantId = typeof rawSessionUser?.currentTenantId === \"string\" ? rawSessionUser.currentTenantId.trim() : \"\"\n\n if (!userId) {\n ctx.res.status(401)\n return null\n }\n\n if (!tenantId) {\n ctx.res.status(400)\n return null\n }\n\n return { userId, tenantId }\n}\n\n","import { z } from \"zod\"\n\n\nexport const ListRoute = \"/api/rb/notifications\"\nexport const CreateRoute = \"/api/rb/notifications/create\"\nexport const MarkReadRoute = \"/api/rb/notifications/:notificationId/read\"\nexport const MarkReadByUrlRoute = \"/api/rb/notifications/mark-read-by-url\"\nexport const ArchiveRoute = \"/api/rb/notifications/:notificationId/archive\"\nexport const MarkAllReadRoute = \"/api/rb/notifications/mark-all-read\"\nexport const SettingsRoute = \"/api/rb/notifications/settings\"\nexport const DigestRunRoute = \"/api/rb/notifications/digest/run\"\n\nexport const listRequestSchema = z.object({\n includeArchived: z.boolean().optional(),\n unreadOnly: z.boolean().optional(),\n limit: z.number().int().min(1).max(200).optional(),\n markSeen: z.boolean().optional(),\n})\n\nexport type ListRequestPayload = z.infer<typeof listRequestSchema>\n\nexport const notificationDataSchema = z.record(z.string(), z.string())\n\nexport const notificationPlatformPayloadSchema = z.object({\n webpush: z.record(z.string(), z.unknown()).optional(),\n fcmOptions: z.record(z.string(), z.unknown()).optional(),\n android: z.record(z.string(), z.unknown()).optional(),\n apns: z.record(z.string(), z.unknown()).optional(),\n}).passthrough()\n\nexport type NotificationPlatformPayload = z.infer<typeof notificationPlatformPayloadSchema>\n\nconst createRequestStringSchema = z.string().trim()\nconst notificationUrlModeSchema = z.enum([\"navigate\", \"merge_current_search\"])\n\nexport const notificationContentFieldsSchema = z.object({\n title: z.string().min(1),\n body: z.string().optional(),\n image: z.string().optional(),\n})\n\nexport const createRequestSchema = z.object({\n topic: createRequestStringSchema.min(1).optional(),\n title: createRequestStringSchema.min(1),\n body: createRequestStringSchema.optional(),\n image: createRequestStringSchema.optional(),\n url: createRequestStringSchema.min(1).optional(),\n urlMode: notificationUrlModeSchema.optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n data: notificationDataSchema.optional(),\n platform: notificationPlatformPayloadSchema.optional(),\n})\n\nexport type CreateRequestPayload = z.infer<typeof createRequestSchema>\n\nexport const normalizeNotificationActionUrl = (url: string, origin: string): string | null => {\n const raw = url.trim()\n if (!raw) return null\n\n try {\n const base = new URL(origin)\n const parsed = new URL(raw, base)\n if (parsed.origin !== base.origin) return null\n return `${parsed.pathname}${parsed.search}`\n } catch {\n return null\n }\n}\n\nexport const normalizeNotificationActionLink = (\n url: string,\n origin: string,\n urlMode: z.infer<typeof notificationUrlModeSchema> = \"navigate\",\n): string | null => {\n const raw = url.trim()\n if (!raw) return null\n\n try {\n const base = new URL(origin)\n const parsed = new URL(raw, base)\n if (parsed.origin !== base.origin) return null\n if (urlMode === \"navigate\") return `${parsed.pathname}${parsed.search}${parsed.hash}`\n return `${parsed.search}${parsed.hash}` || null\n } catch {\n return null\n }\n}\n\nexport const notificationSchema = z.object({\n id: z.string(),\n topic: z.string().optional(),\n title: notificationContentFieldsSchema.shape.title,\n body: notificationContentFieldsSchema.shape.body,\n image: notificationContentFieldsSchema.shape.image,\n data: notificationDataSchema.optional(),\n platform: notificationPlatformPayloadSchema.optional(),\n createdAt: z.string(),\n seenAt: z.string().optional(),\n readAt: z.string().optional(),\n archivedAt: z.string().optional(),\n})\n\nexport type NotificationPayload = z.infer<typeof notificationSchema>\n\nexport const listResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n notifications: z.array(notificationSchema).optional(),\n unreadCount: z.number().int().min(0).optional(),\n unseenCount: z.number().int().min(0).optional(),\n})\n\nexport type ListResponsePayload = z.infer<typeof listResponseSchema>\n\nexport const createResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n id: z.string().optional(),\n})\n\nexport type CreateResponsePayload = z.infer<typeof createResponseSchema>\n\nexport const markReadResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n})\n\nexport type MarkReadResponsePayload = z.infer<typeof markReadResponseSchema>\n\nexport const markReadByUrlRequestSchema = z.object({\n url: z.string().trim().min(1),\n})\n\nexport type MarkReadByUrlRequestPayload = z.infer<typeof markReadByUrlRequestSchema>\n\nexport const markReadByUrlResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n matchedCount: z.number().int().min(0).optional(),\n modifiedCount: z.number().int().min(0).optional(),\n})\n\nexport type MarkReadByUrlResponsePayload = z.infer<typeof markReadByUrlResponseSchema>\n\nexport const archiveResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n})\n\nexport type ArchiveResponsePayload = z.infer<typeof archiveResponseSchema>\n\nexport const markAllReadResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n})\n\nexport type MarkAllReadResponsePayload = z.infer<typeof markAllReadResponseSchema>\n\nexport const digestFrequencySchema = z.enum([\"off\", \"daily\", \"weekly\"])\n\nexport type DigestFrequency = z.infer<typeof digestFrequencySchema>\n\nexport const topicPreferenceSchema = z.object({\n topic: z.string(),\n inApp: z.boolean(),\n emailDigest: z.boolean(),\n push: z.boolean(),\n})\n\nexport type TopicPreferencePayload = z.infer<typeof topicPreferenceSchema>\n\nexport const settingsSchema = z.object({\n digestFrequency: digestFrequencySchema,\n topicPreferences: z.array(topicPreferenceSchema),\n lastDigestSentAt: z.string().optional(),\n})\n\nexport type SettingsPayload = z.infer<typeof settingsSchema>\n\nexport const settingsResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n settings: settingsSchema.optional(),\n})\n\nexport type SettingsResponsePayload = z.infer<typeof settingsResponseSchema>\n\nexport const updateSettingsRequestSchema = z.object({\n digestFrequency: digestFrequencySchema.optional(),\n topicPreferences: z.array(topicPreferenceSchema).optional(),\n})\n\nexport type UpdateSettingsRequestPayload = z.infer<typeof updateSettingsRequestSchema>\n\nexport const updateSettingsResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n settings: settingsSchema.optional(),\n})\n\nexport type UpdateSettingsResponsePayload = z.infer<typeof updateSettingsResponseSchema>\n\nexport const digestRunRequestSchema = z.object({\n force: z.boolean().optional(),\n})\n\nexport type DigestRunRequestPayload = z.infer<typeof digestRunRequestSchema>\n\nexport const digestRunResponseSchema = z.object({\n ok: z.boolean(),\n error: z.string().optional(),\n sent: z.boolean().optional(),\n skippedReason: z.string().optional(),\n})\n\nexport type DigestRunResponsePayload = z.infer<typeof digestRunResponseSchema>\n","import { Api, type ApiHandler, type Ctx } from \"@rpcbase/api\"\nimport { models, type IRBNotification, type IRBNotificationSettings } from \"@rpcbase/db\"\nimport { buildAbilityFromSession, getAccessibleByQuery } from \"@rpcbase/db/acl\"\n\nimport { createNotification } from \"../../createNotification\"\nimport { sendNotificationsDigestForUser } from \"../../digest\"\nimport { getSessionUser } from \"./shared\"\n\nimport * as Notifications from \"./index\"\n\n\ntype NotificationDoc = IRBNotification & { _id: unknown }\ntype NotificationActionDoc = Pick<NotificationDoc, \"_id\" | \"data\" | \"platform\">\ntype SettingsDoc = IRBNotificationSettings & { _id: unknown }\ntype NotificationActionLink = {\n link: string\n urlMode: \"navigate\" | \"merge_current_search\"\n}\n\nconst toIso = (value: unknown): string | undefined => (value instanceof Date ? value.toISOString() : undefined)\nconst isRecord = (value: unknown): value is Record<string, unknown> => Boolean(value) && typeof value === \"object\" && !Array.isArray(value)\n\nconst toStringMap = (value: unknown): Record<string, string> | undefined => {\n if (!isRecord(value)) return undefined\n const entries = Object.entries(value)\n .filter((entry): entry is [string, string] => typeof entry[1] === \"string\")\n return entries.length > 0 ? Object.fromEntries(entries) : undefined\n}\n\nconst getForwardedHeaderValue = (value: unknown): string | undefined => {\n const raw = Array.isArray(value) ? value[0] : value\n if (typeof raw !== \"string\") return undefined\n return raw.split(\",\")[0]?.trim() || undefined\n}\n\nconst getRequestOrigin = (ctx: Ctx): string => {\n const protocol = getForwardedHeaderValue(ctx.req.headers[\"x-forwarded-proto\"]) ?? ctx.req.protocol\n const host = getForwardedHeaderValue(ctx.req.headers[\"x-forwarded-host\"]) ?? ctx.req.get(\"host\")\n\n return protocol && host ? `${protocol}://${host}` : \"\"\n}\n\nconst getNotificationActionLinks = (notification: NotificationActionDoc): NotificationActionLink[] => {\n const links: NotificationActionLink[] = []\n\n if (typeof notification.data?.link === \"string\") {\n links.push({\n link: notification.data.link,\n urlMode: notification.data.linkMode === \"merge_current_search\" ? \"merge_current_search\" : \"navigate\",\n })\n }\n\n const platformWebpush = notification.platform?.webpush\n if (platformWebpush && typeof platformWebpush === \"object\" && !Array.isArray(platformWebpush)) {\n const fcmOptions = (platformWebpush as { fcmOptions?: unknown }).fcmOptions\n if (fcmOptions && typeof fcmOptions === \"object\" && !Array.isArray(fcmOptions)) {\n const link = (fcmOptions as { link?: unknown }).link\n if (typeof link === \"string\") {\n links.push({ link, urlMode: \"navigate\" })\n }\n }\n }\n\n return links\n}\n\nconst actionSearchParamsMatchTargetUrl = (actionUrl: string, targetUrl: string, origin: string): boolean => {\n try {\n const base = new URL(origin)\n const action = new URL(actionUrl, base)\n const target = new URL(targetUrl, base)\n for (const [key, value] of action.searchParams) {\n if (target.searchParams.get(key) !== value) return false\n }\n return Array.from(action.searchParams.keys()).length > 0\n } catch {\n return false\n }\n}\n\nconst notificationActionLinkMatchesUrl = (\n action: NotificationActionLink,\n targetUrl: string,\n origin: string,\n): boolean => {\n if (action.urlMode === \"merge_current_search\") {\n return actionSearchParamsMatchTargetUrl(action.link, targetUrl, origin)\n }\n\n return Notifications.normalizeNotificationActionUrl(action.link, origin) === targetUrl\n}\n\nconst buildDisabledTopics = (\n settings: SettingsDoc | null,\n key: \"inApp\" | \"emailDigest\",\n): string[] => {\n const raw = settings?.topicPreferences\n if (!Array.isArray(raw) || raw.length === 0) return []\n\n return raw\n .map((pref) => {\n if (!pref || typeof pref !== \"object\") return null\n const topic = typeof (pref as { topic?: unknown }).topic === \"string\" ? (pref as { topic: string }).topic.trim() : \"\"\n if (!topic) return null\n const enabled = (pref as Record<string, unknown>)[key] === true\n return enabled ? null : topic\n })\n .filter((topic): topic is string => Boolean(topic))\n}\n\nconst listNotifications: ApiHandler<Notifications.ListRequestPayload, Notifications.ListResponsePayload> = async(\n payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"read\", \"RBNotification\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const parsed = Notifications.listRequestSchema.safeParse(payload)\n if (!parsed.success) {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_payload\" }\n }\n\n const { userId } = session\n const includeArchived = parsed.data.includeArchived === true\n const unreadOnly = parsed.data.unreadOnly === true\n const limit = parsed.data.limit ?? 50\n const markSeen = parsed.data.markSeen === true\n\n const SettingsModel = await models.get(\"RBNotificationSettings\", { req: ctx.req, ability })\n const settings = (await SettingsModel.findOne({ userId }).lean()) as SettingsDoc | null\n const disabledTopics = buildDisabledTopics(settings, \"inApp\")\n\n const NotificationModel = await models.get(\"RBNotification\", { req: ctx.req, ability })\n\n const queryFilters: Record<string, unknown>[] = [\n { userId },\n getAccessibleByQuery(ability, \"read\", \"RBNotification\"),\n ]\n if (!includeArchived) queryFilters.push({ archivedAt: { $exists: false } })\n if (unreadOnly) queryFilters.push({ readAt: { $exists: false } })\n if (disabledTopics.length > 0) queryFilters.push({ topic: { $nin: disabledTopics } })\n const query: Record<string, unknown> = { $and: queryFilters }\n\n const notifications = (await NotificationModel.find(query)\n .sort({ createdAt: -1 })\n .limit(limit)\n .lean()) as NotificationDoc[]\n\n const unseenQueryFilters: Record<string, unknown>[] = [\n { userId },\n { archivedAt: { $exists: false } },\n { seenAt: { $exists: false } },\n getAccessibleByQuery(ability, \"read\", \"RBNotification\"),\n ]\n if (disabledTopics.length > 0) unseenQueryFilters.push({ topic: { $nin: disabledTopics } })\n const unseenQuery: Record<string, unknown> = { $and: unseenQueryFilters }\n\n const unreadQueryFilters: Record<string, unknown>[] = [\n { userId },\n { archivedAt: { $exists: false } },\n { readAt: { $exists: false } },\n getAccessibleByQuery(ability, \"read\", \"RBNotification\"),\n ]\n if (disabledTopics.length > 0) unreadQueryFilters.push({ topic: { $nin: disabledTopics } })\n const unreadQuery: Record<string, unknown> = { $and: unreadQueryFilters }\n\n const [unreadCount, unseenCount] = await Promise.all([\n NotificationModel.countDocuments(unreadQuery),\n NotificationModel.countDocuments(unseenQuery),\n ])\n\n const now = markSeen ? new Date() : null\n if (now && unseenCount > 0) {\n await NotificationModel.updateMany(unseenQuery, { $set: { seenAt: now } })\n }\n\n return Notifications.listResponseSchema.parse({\n ok: true,\n notifications: notifications.map((n) => ({\n id: String(n._id),\n topic: typeof n.topic === \"string\" ? n.topic : undefined,\n title: typeof n.title === \"string\" ? n.title : \"\",\n body: typeof n.body === \"string\" ? n.body : undefined,\n image: typeof n.image === \"string\" ? n.image : undefined,\n data: toStringMap(n.data),\n platform: isRecord(n.platform) ? n.platform : undefined,\n createdAt: toIso(n.createdAt) ?? new Date().toISOString(),\n seenAt: toIso(n.seenAt) ?? (now && !n.archivedAt && !n.seenAt ? now.toISOString() : undefined),\n readAt: toIso(n.readAt),\n archivedAt: toIso(n.archivedAt),\n })),\n unreadCount,\n unseenCount: now ? 0 : unseenCount,\n })\n}\n\nconst createNotificationForCurrentUser: ApiHandler<Notifications.CreateRequestPayload, Notifications.CreateResponsePayload> = async(\n payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"create\", \"RBNotification\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const parsed = Notifications.createRequestSchema.safeParse(payload)\n if (!parsed.success) {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_payload\" }\n }\n\n const origin = getRequestOrigin(ctx)\n const actionLink = parsed.data.url\n ? Notifications.normalizeNotificationActionLink(parsed.data.url, origin, parsed.data.urlMode) ?? undefined\n : undefined\n if (parsed.data.url && !actionLink) {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_payload\" }\n }\n\n const created = await createNotification(ctx, {\n userId: session.userId,\n topic: parsed.data.topic,\n title: parsed.data.title,\n body: parsed.data.body,\n image: parsed.data.image,\n url: actionLink,\n urlMode: parsed.data.urlMode,\n metadata: parsed.data.metadata,\n data: parsed.data.data,\n platform: parsed.data.platform,\n }, ability)\n\n return Notifications.createResponseSchema.parse({ ok: true, id: created.id })\n}\n\nconst markRead: ApiHandler<unknown, Notifications.MarkReadResponsePayload> = async(\n _payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"update\", \"RBNotification\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const notificationId = typeof ctx.req.params.notificationId === \"string\" ? ctx.req.params.notificationId.trim() : \"\"\n if (!notificationId) {\n ctx.res.status(400)\n return { ok: false, error: \"missing_notification_id\" }\n }\n\n const NotificationModel = await models.get(\"RBNotification\", { req: ctx.req, ability })\n const now = new Date()\n\n try {\n await NotificationModel.updateOne(\n { $and: [{ _id: notificationId }, { archivedAt: { $exists: false } }, getAccessibleByQuery(ability, \"update\", \"RBNotification\")] },\n { $set: { readAt: now, seenAt: now } },\n )\n } catch {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_notification_id\" }\n }\n\n return { ok: true }\n}\n\nconst markReadByUrl: ApiHandler<Notifications.MarkReadByUrlRequestPayload, Notifications.MarkReadByUrlResponsePayload> = async(\n payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"update\", \"RBNotification\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const parsed = Notifications.markReadByUrlRequestSchema.safeParse(payload)\n if (!parsed.success) {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_payload\" }\n }\n\n const origin = getRequestOrigin(ctx)\n const targetUrl = Notifications.normalizeNotificationActionUrl(parsed.data.url, origin)\n if (!targetUrl) {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_payload\" }\n }\n\n const NotificationModel = await models.get(\"RBNotification\", { req: ctx.req, ability })\n const query: Record<string, unknown> = {\n $and: [\n { userId: session.userId },\n { archivedAt: { $exists: false } },\n { readAt: { $exists: false } },\n {\n $or: [\n { \"data.link\": { $type: \"string\" } },\n { \"platform.webpush.fcmOptions.link\": { $type: \"string\" } },\n ],\n },\n getAccessibleByQuery(ability, \"update\", \"RBNotification\"),\n ],\n }\n\n const candidates = (await NotificationModel.find(query)\n .select({ _id: 1, data: 1, platform: 1 })\n .lean()) as NotificationActionDoc[]\n\n const matchingIds = candidates\n .filter((notification) =>\n getNotificationActionLinks(notification).some((action) =>\n notificationActionLinkMatchesUrl(action, targetUrl, origin),\n ),\n )\n .map((notification) => notification._id)\n\n if (matchingIds.length === 0) {\n return Notifications.markReadByUrlResponseSchema.parse({\n ok: true,\n matchedCount: 0,\n modifiedCount: 0,\n })\n }\n\n const now = new Date()\n const result = await NotificationModel.updateMany(\n {\n $and: [\n { _id: { $in: matchingIds } },\n { userId: session.userId },\n { archivedAt: { $exists: false } },\n { readAt: { $exists: false } },\n getAccessibleByQuery(ability, \"update\", \"RBNotification\"),\n ],\n },\n { $set: { readAt: now, seenAt: now } },\n )\n\n const modifiedCount = typeof result.modifiedCount === \"number\" ? result.modifiedCount : matchingIds.length\n\n return Notifications.markReadByUrlResponseSchema.parse({\n ok: true,\n matchedCount: matchingIds.length,\n modifiedCount,\n })\n}\n\nconst markAllRead: ApiHandler<unknown, Notifications.MarkAllReadResponsePayload> = async(\n _payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"update\", \"RBNotification\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const SettingsModel = await models.get(\"RBNotificationSettings\", { req: ctx.req, ability })\n const settings = (await SettingsModel.findOne({ userId: session.userId }).lean()) as SettingsDoc | null\n const disabledTopics = buildDisabledTopics(settings, \"inApp\")\n\n const NotificationModel = await models.get(\"RBNotification\", { req: ctx.req, ability })\n\n const queryFilters: Record<string, unknown>[] = [\n { userId: session.userId },\n { archivedAt: { $exists: false } },\n { readAt: { $exists: false } },\n getAccessibleByQuery(ability, \"update\", \"RBNotification\"),\n ]\n if (disabledTopics.length > 0) queryFilters.push({ topic: { $nin: disabledTopics } })\n const query: Record<string, unknown> = { $and: queryFilters }\n\n const now = new Date()\n await NotificationModel.updateMany(query, { $set: { readAt: now, seenAt: now } })\n\n return { ok: true }\n}\n\nconst archiveNotification: ApiHandler<unknown, Notifications.ArchiveResponsePayload> = async(\n _payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"update\", \"RBNotification\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const notificationId = typeof ctx.req.params.notificationId === \"string\" ? ctx.req.params.notificationId.trim() : \"\"\n if (!notificationId) {\n ctx.res.status(400)\n return { ok: false, error: \"missing_notification_id\" }\n }\n\n const NotificationModel = await models.get(\"RBNotification\", { req: ctx.req, ability })\n\n try {\n await NotificationModel.updateOne(\n { $and: [{ _id: notificationId }, { archivedAt: { $exists: false } }, getAccessibleByQuery(ability, \"update\", \"RBNotification\")] },\n { $set: { archivedAt: new Date() } },\n )\n } catch {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_notification_id\" }\n }\n\n return { ok: true }\n}\n\nconst getSettings: ApiHandler<unknown, Notifications.SettingsResponsePayload> = async(\n _payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"read\", \"RBNotificationSettings\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const SettingsModel = await models.get(\"RBNotificationSettings\", { req: ctx.req, ability })\n const settings = (await SettingsModel.findOne(\n { $and: [{ userId: session.userId }, getAccessibleByQuery(ability, \"read\", \"RBNotificationSettings\")] },\n ).lean()) as SettingsDoc | null\n\n const digestFrequencyRaw = typeof settings?.digestFrequency === \"string\" ? settings.digestFrequency : \"weekly\"\n const digestFrequency: Notifications.DigestFrequency =\n digestFrequencyRaw === \"off\" || digestFrequencyRaw === \"daily\" || digestFrequencyRaw === \"weekly\"\n ? digestFrequencyRaw\n : \"weekly\"\n\n const topicPreferences = Array.isArray(settings?.topicPreferences)\n ? settings!.topicPreferences.map((pref) => ({\n topic: typeof pref.topic === \"string\" ? pref.topic : \"\",\n inApp: pref.inApp === true,\n emailDigest: pref.emailDigest === true,\n push: pref.push === true,\n })).filter((pref) => pref.topic.length > 0)\n : []\n\n return Notifications.settingsResponseSchema.parse({\n ok: true,\n settings: {\n digestFrequency,\n topicPreferences,\n lastDigestSentAt: toIso(settings?.lastDigestSentAt),\n },\n })\n}\n\nconst updateSettings: ApiHandler<Notifications.UpdateSettingsRequestPayload, Notifications.UpdateSettingsResponsePayload> = async(\n payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"update\", \"RBNotificationSettings\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const parsed = Notifications.updateSettingsRequestSchema.safeParse(payload)\n if (!parsed.success) {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_payload\" }\n }\n\n const SettingsModel = await models.get(\"RBNotificationSettings\", { req: ctx.req, ability })\n const nextValues: Record<string, unknown> = {}\n\n if (parsed.data.digestFrequency) {\n nextValues.digestFrequency = parsed.data.digestFrequency\n }\n\n if (parsed.data.topicPreferences) {\n const seen = new Set<string>()\n const next = parsed.data.topicPreferences\n .map((pref) => ({\n topic: pref.topic.trim(),\n inApp: pref.inApp,\n emailDigest: pref.emailDigest,\n push: pref.push,\n }))\n .filter((pref) => pref.topic.length > 0)\n .filter((pref) => {\n if (seen.has(pref.topic)) return false\n seen.add(pref.topic)\n return true\n })\n\n nextValues.topicPreferences = next\n }\n\n const ops: Record<string, unknown> = {\n $setOnInsert: { userId: session.userId },\n }\n\n if (Object.keys(nextValues).length > 0) {\n ops.$set = nextValues\n }\n\n const settings = (await SettingsModel.findOneAndUpdate(\n { $and: [{ userId: session.userId }, getAccessibleByQuery(ability, \"update\", \"RBNotificationSettings\")] },\n ops,\n { upsert: true, returnDocument: \"after\", setDefaultsOnInsert: true },\n ).lean()) as SettingsDoc | null\n\n const digestFrequencyRaw = typeof settings?.digestFrequency === \"string\" ? settings.digestFrequency : \"weekly\"\n const digestFrequency: Notifications.DigestFrequency =\n digestFrequencyRaw === \"off\" || digestFrequencyRaw === \"daily\" || digestFrequencyRaw === \"weekly\"\n ? digestFrequencyRaw\n : \"weekly\"\n\n const topicPreferences = Array.isArray(settings?.topicPreferences)\n ? settings!.topicPreferences.map((pref) => ({\n topic: typeof pref.topic === \"string\" ? pref.topic : \"\",\n inApp: pref.inApp === true,\n emailDigest: pref.emailDigest === true,\n push: pref.push === true,\n })).filter((pref) => pref.topic.length > 0)\n : []\n\n return Notifications.updateSettingsResponseSchema.parse({\n ok: true,\n settings: {\n digestFrequency,\n topicPreferences,\n lastDigestSentAt: toIso(settings?.lastDigestSentAt),\n },\n })\n}\n\nconst runDigest: ApiHandler<Notifications.DigestRunRequestPayload, Notifications.DigestRunResponsePayload> = async(\n payload,\n ctx,\n) => {\n const session = getSessionUser(ctx)\n if (!session) {\n return { ok: false, error: \"unauthorized\" }\n }\n\n const ability = buildAbilityFromSession({ tenantId: session.tenantId, session: ctx.req.session })\n if (!ability.can(\"read\", \"RBNotification\")) {\n ctx.res.status(403)\n return { ok: false, error: \"forbidden\" }\n }\n\n const parsed = Notifications.digestRunRequestSchema.safeParse(payload)\n if (!parsed.success) {\n ctx.res.status(400)\n return { ok: false, error: \"invalid_payload\" }\n }\n\n const result = await sendNotificationsDigestForUser(ctx, {\n userId: session.userId,\n ability,\n force: parsed.data.force === true,\n })\n\n if (!result.ok) {\n ctx.res.status(500)\n return { ok: false, error: result.error }\n }\n\n return {\n ok: true,\n sent: result.sent,\n ...(result.skippedReason ? { skippedReason: result.skippedReason } : {}),\n }\n}\n\nexport default (api: Api) => {\n api.post(Notifications.ListRoute, listNotifications)\n api.post(Notifications.CreateRoute, createNotificationForCurrentUser)\n api.post(Notifications.MarkReadRoute, markRead)\n api.post(Notifications.MarkReadByUrlRoute, markReadByUrl)\n api.post(Notifications.MarkAllReadRoute, markAllRead)\n api.post(Notifications.ArchiveRoute, archiveNotification)\n api.get(Notifications.SettingsRoute, getSettings)\n api.put(Notifications.SettingsRoute, updateSettings)\n api.post(Notifications.DigestRunRoute, runDigest)\n}\n"],"names":["getSessionUser","ctx","rawSessionUser","req","session","user","userId","id","trim","tenantId","currentTenantId","res","status","ListRoute","CreateRoute","MarkReadRoute","MarkReadByUrlRoute","ArchiveRoute","MarkAllReadRoute","SettingsRoute","DigestRunRoute","listRequestSchema","z","includeArchived","boolean","optional","unreadOnly","limit","int","min","max","markSeen","notificationDataSchema","notificationPlatformPayloadSchema","webpush","string","unknown","fcmOptions","android","apns","passthrough","createRequestStringSchema","notificationUrlModeSchema","notificationContentFieldsSchema","title","body","image","createRequestSchema","topic","url","urlMode","metadata","data","platform","normalizeNotificationActionUrl","origin","raw","base","URL","parsed","pathname","search","normalizeNotificationActionLink","hash","notificationSchema","shape","createdAt","seenAt","readAt","archivedAt","listResponseSchema","ok","error","notifications","unreadCount","number","unseenCount","createResponseSchema","markReadByUrlRequestSchema","markReadByUrlResponseSchema","matchedCount","modifiedCount","digestFrequencySchema","topicPreferenceSchema","inApp","emailDigest","push","settingsSchema","digestFrequency","topicPreferences","lastDigestSentAt","settingsResponseSchema","settings","updateSettingsRequestSchema","updateSettingsResponseSchema","digestRunRequestSchema","force","sent","skippedReason","toIso","value","Date","toISOString","undefined","isRecord","Boolean","Array","isArray","toStringMap","entries","Object","filter","entry","length","fromEntries","getForwardedHeaderValue","split","getRequestOrigin","protocol","headers","host","get","getNotificationActionLinks","notification","links","link","linkMode","platformWebpush","actionSearchParamsMatchTargetUrl","actionUrl","targetUrl","action","target","key","searchParams","from","keys","notificationActionLinkMatchesUrl","Notifications","buildDisabledTopics","map","pref","enabled","listNotifications","payload","ability","buildAbilityFromSession","can","safeParse","success","SettingsModel","models","findOne","lean","disabledTopics","NotificationModel","queryFilters","getAccessibleByQuery","$exists","$nin","query","$and","find","sort","unseenQueryFilters","unseenQuery","unreadQueryFilters","unreadQuery","Promise","all","countDocuments","now","updateMany","$set","parse","n","String","_id","createNotificationForCurrentUser","actionLink","created","createNotification","markRead","_payload","notificationId","params","updateOne","markReadByUrl","$or","$type","candidates","select","matchingIds","some","result","$in","markAllRead","archiveNotification","getSettings","digestFrequencyRaw","updateSettings","nextValues","seen","Set","next","has","add","ops","$setOnInsert","findOneAndUpdate","upsert","returnDocument","setDefaultsOnInsert","runDigest","sendNotificationsDigestForUser","api","post","put"],"mappings":";;;;AAQO,MAAMA,iBAAiBA,CAACC,QAAa;AAC1C,QAAMC,iBAAkBD,IAAIE,IAAIC,SAAmEC;AACnG,QAAMC,SAAS,OAAOJ,gBAAgBK,OAAO,WAAWL,eAAeK,GAAGC,SAAS;AACnF,QAAMC,WAAW,OAAOP,gBAAgBQ,oBAAoB,WAAWR,eAAeQ,gBAAgBF,SAAS;AAE/G,MAAI,CAACF,QAAQ;AACXL,QAAIU,IAAIC,OAAO,GAAG;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,CAACH,UAAU;AACbR,QAAIU,IAAIC,OAAO,GAAG;AAClB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IAAEN;AAAAA,IAAQG;AAAAA,EAAAA;AACnB;ACrBO,MAAMI,YAAY;AAClB,MAAMC,cAAc;AACpB,MAA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K9E,oBAAkCiD,aAAa;AACxD4B,MAAIC,KAAK9E,kBAAgC0D,WAAW;AACpDmB,MAAIC,KAAK9E,cAA4B2D,mBAAmB;AACxDkB,MAAI9F,IAAIiB,eAA6B4D,WAAW;AAChDiB,MAAIE,IAAI/E,eAA6B8D,cAAc;AACnDe,MAAIC,KAAK9E,gBAA8B2E,SAAS;AAClD;"}
|
package/dist/index.js
CHANGED
|
@@ -4700,7 +4700,7 @@ const isNotFoundFallbackRoute = (route) => {
|
|
|
4700
4700
|
if (route.children?.length) return false;
|
|
4701
4701
|
return true;
|
|
4702
4702
|
};
|
|
4703
|
-
async function applyRouteLoaders(req, dataRoutes) {
|
|
4703
|
+
async function applyRouteLoaders(req, res, dataRoutes) {
|
|
4704
4704
|
const baseUrl = `${req.protocol}://${req.get("host")}`;
|
|
4705
4705
|
const url = new URL(req.originalUrl, baseUrl);
|
|
4706
4706
|
const method = req.method;
|
|
@@ -4783,7 +4783,8 @@ async function applyRouteLoaders(req, dataRoutes) {
|
|
|
4783
4783
|
const data = await route.loader({
|
|
4784
4784
|
params,
|
|
4785
4785
|
ctx: {
|
|
4786
|
-
req
|
|
4786
|
+
req,
|
|
4787
|
+
res
|
|
4787
4788
|
}
|
|
4788
4789
|
});
|
|
4789
4790
|
return {
|
|
@@ -5113,8 +5114,8 @@ const runRtsPrepass = async (element) => {
|
|
|
5113
5114
|
}, RTS_SSR_PREPASS_TIMEOUT_MS);
|
|
5114
5115
|
});
|
|
5115
5116
|
};
|
|
5116
|
-
async function renderSSR(req, dataRoutes) {
|
|
5117
|
-
const routerContext = await applyRouteLoaders(req, dataRoutes);
|
|
5117
|
+
async function renderSSR(req, res, dataRoutes) {
|
|
5118
|
+
const routerContext = await applyRouteLoaders(req, res, dataRoutes);
|
|
5118
5119
|
const isMatched = routerContext.matches.length > 0;
|
|
5119
5120
|
if (routerContext.redirectResponse) {
|
|
5120
5121
|
return {
|
|
@@ -5339,7 +5340,7 @@ const ssrMiddleware = ({
|
|
|
5339
5340
|
redirectResponse,
|
|
5340
5341
|
redirectRouteId,
|
|
5341
5342
|
redirectRoutePath
|
|
5342
|
-
} = await renderSSR(req, dataRoutes);
|
|
5343
|
+
} = await renderSSR(req, res, dataRoutes);
|
|
5343
5344
|
if (redirectResponse) {
|
|
5344
5345
|
if (!responseCommitted) {
|
|
5345
5346
|
const location = redirectResponse.headers?.get?.("Location");
|