core: add server-loader (#816)

This commit is contained in:
undefined authored and GitHub committed 2024-06-03 19:29:41 +08:00
1 parent 3302480348
commit 97720efb65
57 files changed
+1328 -1131

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import type { HandlerCommon } from './server';
export default function serializer(ignoreSerializeFunction = false, h?: HandlerCommon) {
return (k: string, v: any) => {
if (k.startsWith('_') && k !== '_id') return undefined;
if (typeof v === 'bigint') return `BigInt::${v.toString()}`;
if (!ignoreSerializeFunction && v && typeof v === 'object'
&& 'serialize' in v && typeof v.serialize === 'function') return v.serialize(h);
return v;
};
}