Add error logs for server functions. Add cache dynamic function.

This commit is contained in:
2026-03-27 05:22:31 +01:00
parent 572f739b5c
commit 950bdc3dca
10 changed files with 157 additions and 32 deletions
+13 -2
View File
@@ -188,7 +188,10 @@ export type BunextPageServerFn<T extends {
[k: string]: any;
}> = (ctx: Omit<BunxRouteParams, "body">) => Promise<BunextPageModuleServerReturn<T>>;
export type BunextRouteConfig = {
cachePage?: boolean;
/**
* Whether to cache the current page
*/
cachePage?: BunextCachePageType;
/**
* Expiry time of the cache in seconds
*/
@@ -207,13 +210,21 @@ export type BunextPageModuleServerReturn<T extends {
query?: Q;
redirect?: BunextPageModuleServerRedirect;
responseOptions?: ResponseInit;
cachePage?: boolean;
/**
* Whether to cache the current page
*/
cachePage?: BunextCachePageType;
/**
* Expiry time of the cache in seconds
*/
cacheExpiry?: number;
url?: BunextPageModuleServerReturnURLObject;
error?: string;
};
export type BunextCachePageType = boolean | ((params: {
ctx: Omit<BunxRouteParams, "body">;
serverRes?: BunextPageModuleServerReturn;
}) => Promise<boolean> | boolean);
export type BunextPageProps<T extends {
[k: string]: any;
} = {