mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
core: add server-loader (#816)
This commit is contained in:
1 parent
3302480348
commit
97720efb65
57 files changed
+1328
-1131
No files matched your search
@@ -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;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user