Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

619 B
Raw Blame
import { isNil } from '@activepieces/core-utils'
import { FastifyBaseLogger } from 'fastify'



export const hooksFactory = {
    create<T>(defaultHooks: (log: FastifyBaseLogger) => T) {
        let hooksCreator: (log: FastifyBaseLogger) => T
        return {
            set(newHooksCreator: (log: FastifyBaseLogger) => T): void {
                hooksCreator = newHooksCreator
            },
            get(log: FastifyBaseLogger): T {
                if (isNil(hooksCreator)) {
                    return defaultHooks(log)
                }
                return hooksCreator(log)
            },
        }
    },
}