MCPcopy Index your code
hub / github.com/deployd/deployd / createResourceClient

Function createResourceClient

lib/internal-client.js:181–252  ·  view source on GitHub ↗
(resource, baseMethods)

Source from the content-addressed store, hash-verified

179};
180
181function createResourceClient(resource, baseMethods) {
182
183 var r = {
184 get: function(func, p, query, fn) {
185
186 var settings = parseGetSignature(arguments);
187
188 settings.path = joinPath(resource.path, settings.path);
189
190 return baseMethods.get.call(this, settings, settings.fn);
191 }
192 , post: function(p, query, body, fn) {
193 var settings = parsePostSignature(arguments);
194 settings.path = joinPath(resource.path, settings.path);
195
196 return baseMethods.post.call(this, settings, settings.fn);
197 }
198 , put: function(p, query, body, fn) {
199 var settings = parsePostSignature(arguments);
200 settings.path = joinPath(resource.path, settings.path);
201
202 return baseMethods.put.call(this, settings, settings.fn);
203 }
204 , del: function(p, query, fn) {
205 var settings = parseGetSignature(arguments);
206 settings.path = joinPath(resource.path, settings.path);
207
208 return baseMethods.del.call(this, settings, settings.fn);
209 }
210 };
211
212 r.exec = function(func, path, body, fn) {
213 var settings = {}
214 , i = 0;
215
216 settings.func = arguments[i];
217 i++;
218
219 // path
220 if (typeof arguments[i] === 'string') {
221 settings.path = arguments[i];
222 i++;
223 }
224
225 // body
226 if (typeof arguments[i] === 'object') {
227 settings.body = arguments[i];
228 i++;
229 }
230
231 fn = arguments[i];
232
233 settings.path = joinPath(resource.path, settings.func, settings.path);
234 return baseMethods.post(settings, fn);
235 };
236
237 resource.clientGenerationGet.forEach(function(func) {
238 r[func] = function(path, query, fn) {

Callers 1

internal-client.jsFile · 0.85

Calls 3

parseGetSignatureFunction · 0.85
joinPathFunction · 0.85
parsePostSignatureFunction · 0.85

Tested by

no test coverage detected