decorate.js — fastify Source File
Architecture documentation for decorate.js, a javascript file in the fastify codebase.
Entity Profile
Relationship Graph
Source Code
'use strict'
const {
kReply,
kRequest,
kState,
kHasBeenDecorated
} = require('./symbols.js')
const {
FST_ERR_DEC_ALREADY_PRESENT,
FST_ERR_DEC_MISSING_DEPENDENCY,
FST_ERR_DEC_AFTER_START,
FST_ERR_DEC_REFERENCE_TYPE,
FST_ERR_DEC_DEPENDENCY_INVALID_TYPE,
FST_ERR_DEC_UNDECLARED
} = require('./errors')
function decorate (instance, name, fn, dependencies) {
if (Object.hasOwn(instance, name)) {
throw new FST_ERR_DEC_ALREADY_PRESENT(name)
}
checkDependencies(instance, name, dependencies)
if (fn && (typeof fn.getter === 'function' || typeof fn.setter === 'function')) {
Object.defineProperty(instance, name, {
get: fn.getter,
set: fn.setter
})
} else {
instance[name] = fn
}
}
function getInstanceDecorator (name) {
if (!checkExistence(this, name)) {
throw new FST_ERR_DEC_UNDECLARED(name, 'instance')
}
if (typeof this[name] === 'function') {
return this[name].bind(this)
}
return this[name]
}
function decorateConstructor (konstructor, name, fn, dependencies) {
const instance = konstructor.prototype
if (Object.hasOwn(instance, name) || hasKey(konstructor, name)) {
throw new FST_ERR_DEC_ALREADY_PRESENT(name)
}
konstructor[kHasBeenDecorated] = true
checkDependencies(konstructor, name, dependencies)
if (fn && (typeof fn.getter === 'function' || typeof fn.setter === 'function')) {
Object.defineProperty(instance, name, {
get: fn.getter,
set: fn.setter
// ... (93 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does decorate.js do?
decorate.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, LifecycleManager subdomain.
What functions are defined in decorate.js?
decorate.js defines 13 function(s): assertNotStarted, checkDependencies, checkExistence, checkReferenceType, checkReplyExistence, checkRequestExistence, decorate, decorateConstructor, decorateFastify, decorateReply, and 3 more.
Where is decorate.js in the architecture?
decorate.js is located at lib/decorate.js (domain: CoreKernel, subdomain: LifecycleManager, directory: lib).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free