Could someone help me to create a HOOK in FASTIFY to automatically serialize these types of values in all app.ts endpoints
I managed to solve the problem using .toString, but I wanted a way to do this automatically in all requests
Could someone help me to create a HOOK in FASTIFY to automatically serialize these types of values in all app.ts endpoints
I managed to solve the problem using .toString, but I wanted a way to do this automatically in all requests
Copyright © 2021 Jogjafile Inc.


First of all, bigint is not supported by JS standard functions:
Here is 3 solutions:
preSerializationhook. Note that thetoStringreturns a string a not a numbersetReplySerializer. Different approach but same result as before.I would use something that gives fully control over the serialization, because serializing bigint is not supported by the
JSON.*utilities and the client who parse the json must be aware of it or it will fail! See the code snippet above,JSON.parse()trims the number.