MCPcopy
hub / github.com/thinkjs/thinkjs / service

Function service

lib/extend/controller.js:248–263  ·  view source on GitHub ↗

* get service * @param {String} name * @param {String} m

(...args)

Source from the content-addressed store, hash-verified

246 * @param {String} m
247 */
248 service(...args) {
249 const {modules, services} = think.app;
250 if (!modules.length) {
251 return think.service(...args);
252 }
253
254 const {module} = this.ctx;
255 const haveSetModule = args.length > 1 && modules.includes(args[1]);
256 const existInContextModule = services[module] && services[module][args[0]];
257 if (haveSetModule || !existInContextModule) {
258 return think.service(...args);
259 }
260
261 const name = args.shift();
262 return think.service(name, module, ...args);
263 },
264 /**
265 * execute action
266 * @param {String} controller

Callers

nothing calls this directly

Calls 1

serviceMethod · 0.65

Tested by

no test coverage detected