@rpcbase/server 0.564.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.
|
@@ -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"}
|
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");
|