Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const requestJar = request.jar();
const requestObj = request.defaults({ jar: requestJar, ...config });
setPrototypeOf(requestObj, requestJar);
// Crawler base:
const crawler: Object = {
base: base,
opts: config,
req: SpiderRequest,
res: SpiderResponse,
request: requestObj
};
// Glues all the components together:
mixin(crawler, SpiderQueue, false);
mixin(crawler, SpiderRouter, false);
mixin(crawler, EventEmitter.prototype);
return crawler;
}
// Will be used by retry-request:
const requestJar = request.jar();
const requestObj = request.defaults({ jar: requestJar, ...config });
setPrototypeOf(requestObj, requestJar);
// Crawler base:
const crawler: Object = {
base: base,
opts: config,
req: SpiderRequest,
res: SpiderResponse,
request: requestObj
};
// Glues all the components together:
mixin(crawler, SpiderQueue, false);
mixin(crawler, SpiderRouter, false);
mixin(crawler, EventEmitter.prototype);
return crawler;
}
callActions(uri: string, req: Object, res: Object): void {
for (const index in this.callbacks) {
const parameters: Object = wildcard(uri, index);
const callback: Function = this.callbacks[index];
if (uri === index || parameters) {
// Merge request parameters with wildcard output:
// NOTE: pheraps we should override params on each callback?
mixin(req.params || {}, parameters || {});
callback({ req, res, uri });
}
}
}
};
const requestObj = request.defaults({ jar: requestJar, ...config });
setPrototypeOf(requestObj, requestJar);
// Crawler base:
const crawler: Object = {
base: base,
opts: config,
req: SpiderRequest,
res: SpiderResponse,
request: requestObj
};
// Glues all the components together:
mixin(crawler, SpiderQueue, false);
mixin(crawler, SpiderRouter, false);
mixin(crawler, EventEmitter.prototype);
return crawler;
}
constructor(context = {}, settings = {}) {
super();
this.originalApp = application;
mixin(this, omit(this.originalApp, ['listen']), false);
this.init();
this.request = request;
this.request.app = this;
this.response = response;
this.response.app = this;
Object.assign(this.request, context);
this.merge(settings);
}
(dest, src, i) => mergeDescriptors(dest, src, redefine),
args[0],