MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / wrapServiceClassMethods

Function wrapServiceClassMethods

src/utils/serviceErrorBoundary.js:100–123  ·  view source on GitHub ↗
(ServiceClass, optionsFactory)

Source from the content-addressed store, hash-verified

98}
99
100export function wrapServiceClassMethods(ServiceClass, optionsFactory) {
101 const methodNames = Object.getOwnPropertyNames(ServiceClass)
102 .filter((name) => name !== 'length' && name !== 'name' && name !== 'prototype')
103 .filter((name) => typeof ServiceClass[name] === 'function');
104
105 for (const methodName of methodNames) {
106 ServiceClass[methodName] = wrapServiceBoundary(
107 ServiceClass[methodName],
108 (...args) => {
109 const baseOptions = typeof optionsFactory === 'function'
110 ? optionsFactory(methodName, ...args)
111 : {};
112
113 return {
114 service: ServiceClass.name || 'ServiceClass',
115 operation: methodName,
116 ...baseOptions
117 };
118 }
119 );
120 }
121
122 return ServiceClass;
123}

Callers 2

configService.jsFile · 0.90
economyService.jsFile · 0.90

Calls 1

wrapServiceBoundaryFunction · 0.85

Tested by

no test coverage detected