Refactor Server Paradigm.

This commit is contained in:
2026-03-24 07:18:57 +01:00
parent 342f56f3f5
commit 60ee353bf0
34 changed files with 425 additions and 279 deletions
+44
View File
@@ -0,0 +1,44 @@
import _ from "lodash";
export default async function grabPageServerRes({ url, query, routeParams, server_function, }) {
const default_props = {
url: url
? {
..._.pick(url, [
"host",
"hostname",
"pathname",
"origin",
"port",
"search",
"searchParams",
"hash",
"href",
"password",
"protocol",
"username",
]),
}
: null,
query,
};
try {
if (routeParams) {
const serverData = await server_function({
...routeParams,
query: { ...routeParams.query, ...query },
});
return {
...serverData,
...default_props,
};
}
return {
...default_props,
};
}
catch (error) {
return {
...default_props,
};
}
}