run() — fastify Function Reference
Architecture documentation for the run() function in content-type-parser.js from the fastify codebase.
Entity Profile
Dependency Diagram
graph TD 2cc48675_3506_ea24_6a37_4a303bc97431["run()"] b47c11f3_fe3b_64dc_0f58_921e5921ec45["content-type-parser.js"] 2cc48675_3506_ea24_6a37_4a303bc97431 -->|defined in| b47c11f3_fe3b_64dc_0f58_921e5921ec45 85b7c491_fec4_f37f_2d94_fa3bd924a97b["getParser()"] 2cc48675_3506_ea24_6a37_4a303bc97431 -->|calls| 85b7c491_fec4_f37f_2d94_fa3bd924a97b 4b3409ec_16d6_e0f9_062f_5a23bc15485a["rawBody()"] 2cc48675_3506_ea24_6a37_4a303bc97431 -->|calls| 4b3409ec_16d6_e0f9_062f_5a23bc15485a style 2cc48675_3506_ea24_6a37_4a303bc97431 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
lib/content-type-parser.js lines 185–231
ContentTypeParser.prototype.run = function (contentType, handler, request, reply) {
const parser = this.getParser(contentType)
if (parser === undefined) {
if (request.is404 === true) {
handler(request, reply)
return
}
reply[kReplyIsError] = true
reply.send(new FST_ERR_CTP_INVALID_MEDIA_TYPE(contentType || undefined))
return
}
const resource = new AsyncResource('content-type-parser:run', request)
const done = resource.bind(onDone)
if (parser.asString === true || parser.asBuffer === true) {
rawBody(
request,
reply,
reply[kRouteContext]._parserOptions,
parser,
done
)
return
}
const result = parser.fn(request, request[kRequestPayloadStream], done)
if (result && typeof result.then === 'function') {
result.then(body => { done(null, body) }, done)
}
function onDone (error, body) {
resource.emitDestroy()
if (error != null) {
// We must close the connection as the client may
// send more data
reply.header('connection', 'close')
reply[kReplyIsError] = true
reply.send(error)
return
}
request.body = body
handler(request, reply)
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does run() do?
run() is a function in the fastify codebase, defined in lib/content-type-parser.js.
Where is run() defined?
run() is defined in lib/content-type-parser.js at line 185.
What does run() call?
run() calls 2 function(s): getParser, rawBody.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free