import Decimal from 'decimal.js'; import superjson from 'superjson'; export function registerSerializers() { superjson.registerCustom( { isApplicable: (v): v is Buffer => Buffer.isBuffer(v), serialize: (v) => JSON.stringify(v.toJSON().data), deserialize: (v) => Buffer.from(JSON.parse(v)), }, 'Buffer' ); superjson.registerCustom( { isApplicable: (v): v is Decimal => Decimal.isDecimal(v), serialize: (v) => v.toJSON(), deserialize: (v) => new Decimal(v), }, 'decimal.js' ); }