@a11ywatch/core
Version:
a11ywatch central API
42 lines • 1.92 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.watcherCrawl = void 0;
const website_source_builder_1 = require("@a11ywatch/website-source-builder");
const utils_1 = require("../../utils");
const calls_1 = require("../../../proto/actions/calls");
const UA = process.env.A11YWATCH_UA ? process.env.A11YWATCH_UA : undefined;
const watcherCrawl = ({ url, userId, scan = false, robots = true, subdomains = false, tld = false, agent, proxy, sitemap = false, delay, }, deciphered) => __awaiter(void 0, void 0, void 0, function* () {
const crawlParams = {
url: (0, website_source_builder_1.initUrl)(url, true),
id: userId,
norobots: !robots,
subdomains,
tld,
agent: agent !== null && agent !== void 0 ? agent : UA,
proxy: proxy && !deciphered ? (0, utils_1.decipher)(proxy) : proxy,
sitemap,
delay,
};
try {
if (scan) {
yield calls_1.controller.crawlerScan(crawlParams);
}
else {
yield calls_1.controller.crawlerCrawl(crawlParams);
}
}
catch (e) {
console.error(e);
}
});
exports.watcherCrawl = watcherCrawl;
//# sourceMappingURL=watcher_crawl.js.map
;