helper.js — fastify Source File
Architecture documentation for helper.js, a javascript file in the fastify codebase.
Entity Profile
Relationship Graph
Source Code
'use strict'
const dns = require('node:dns').promises
const stream = require('node:stream')
const { promisify } = require('node:util')
const symbols = require('../lib/symbols')
const { waitForCb } = require('./toolkit')
const assert = require('node:assert')
module.exports.sleep = promisify(setTimeout)
/**
* @param method HTTP request method
* @param t node:test instance
* @param isSetErrorHandler true: using setErrorHandler
*/
module.exports.payloadMethod = function (method, t, isSetErrorHandler = false) {
const test = t.test
const fastify = require('..')()
if (isSetErrorHandler) {
fastify.setErrorHandler(function (err, request, reply) {
assert.ok(request instanceof fastify[symbols.kRequest].parent)
assert.strictEqual(typeof request, 'object')
reply
.code(err.statusCode)
.type('application/json; charset=utf-8')
.send(err)
})
}
const upMethod = method.toUpperCase()
const loMethod = method.toLowerCase()
const schema = {
schema: {
response: {
'2xx': {
type: 'object',
properties: {
hello: {
type: 'string'
}
}
}
}
}
}
test(`${upMethod} can be created`, t => {
t.plan(1)
try {
fastify[loMethod]('/', schema, function (req, reply) {
reply.code(200).send(req.body)
})
t.assert.ok(true)
} catch (e) {
t.assert.fail()
}
})
// ... (437 more lines)
Domain
Subdomains
Source
Frequently Asked Questions
What does helper.js do?
helper.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, InstanceFactory subdomain.
What functions are defined in helper.js?
helper.js defines 5 function(s): getLoopbackHost, getServerUrl, lookupToIp, payloadMethod, plainTextParser.
Where is helper.js in the architecture?
helper.js is located at test/helper.js (domain: CoreKernel, subdomain: InstanceFactory, directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free