@a11ywatch/core
Version:
a11ywatch central API
51 lines • 2.31 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.getCrawlConfig = void 0;
const extracter_1 = require("../../web/params/extracter");
const config_1 = require("../../config/config");
const websites_1 = require("../controllers/websites");
const getCrawlConfig = ({ id, role, url, tld, subdomains, sitemap, robots = true, }) => __awaiter(void 0, void 0, void 0, function* () {
let subdomainsEnabled = config_1.SUPER_MODE ? subdomains : role && subdomains;
let tldEnabled = config_1.SUPER_MODE ? tld : role && tld;
let sitemapEnabled = config_1.SUPER_MODE ? sitemap : role && sitemap;
let agent = "";
if ((role && (0, extracter_1.validateUID)(id)) || config_1.SUPER_MODE) {
if (!subdomainsEnabled || !tldEnabled) {
const [website] = yield (0, websites_1.getWebsite)({ userId: id, url });
if (website) {
if (!subdomainsEnabled) {
subdomainsEnabled = !!website.subdomains;
}
if (!tldEnabled) {
tldEnabled = !!website.tld;
}
if (website.ua) {
agent = website.ua;
}
if (typeof sitemap === "undefined" && website.sitemap) {
sitemapEnabled = true;
}
}
}
}
return {
url,
userId: id,
subdomains: subdomainsEnabled,
tld: tldEnabled,
robots,
agent,
sitemap: sitemapEnabled,
};
});
exports.getCrawlConfig = getCrawlConfig;
//# sourceMappingURL=crawl-config.js.map
;