MCPcopy
hub / github.com/fastify/fastify / serialize

Function serialize

lib/reply.js:1073–1079  ·  view source on GitHub ↗

* This function runs when a payload that is not a string|buffer|stream or null * should be serialized to be streamed to the response. * This is the default serializer that can be customized by the user using the replySerializer * * @param {object} context the request context * @param {object} d

(context, data, statusCode, contentType)

Source from the content-addressed store, hash-verified

1071 * @returns {string} the serialized payload
1072 */
1073function serialize (context, data, statusCode, contentType) {
1074 const fnSerialize = getSchemaSerializer(context, statusCode, contentType)
1075 if (fnSerialize) {
1076 return fnSerialize(data)
1077 }
1078 return JSON.stringify(data)
1079}
1080
1081function noop () { }
1082

Callers 3

reply.jsFile · 0.85
preSerializationHookEndFunction · 0.85

Calls 1

getSchemaSerializerFunction · 0.85

Tested by

no test coverage detected