UNPKG

@casoon/auditmysite

Version:

Professional website analysis suite with robust accessibility testing, Core Web Vitals performance monitoring, SEO analysis, and content optimization insights. Features isolated browser contexts, retry mechanisms, and comprehensive API endpoints for profe

57 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SitemapService = void 0; const parsers_1 = require("../../core/parsers"); /** * SitemapService - Returns SitemapResult (same type used in FullAuditResult) * Used by API endpoint: GET /api/v2/sitemap/:domain */ class SitemapService { constructor() { this.parser = new parsers_1.SitemapParser(); } async getUrls(sitemapUrl) { try { // Parse sitemap const rawUrls = await this.parser.parseSitemap(sitemapUrl); const allUrls = rawUrls.map((url) => url.loc || url); // Apply basic filters (same as pipeline) const filterPatterns = ['[...slug]', '[category]', '/demo/', '/test/']; const filteredUrls = this.parser.filterUrls(allUrls.map(url => ({ loc: url })), { filterPatterns }); const finalUrls = filteredUrls.map((url) => url.loc); return { sourceUrl: sitemapUrl, urls: finalUrls, parsedAt: new Date().toISOString(), totalUrls: allUrls.length, filteredUrls: allUrls.length - filteredUrls.length, filterPatterns }; } catch (error) { throw new Error(`Failed to parse sitemap: ${error.message}`); } } /** * Get domain from sitemap URL for convenience */ async getUrlsFromDomain(domain) { // Try common sitemap paths const sitemapPaths = [ `https://${domain}/sitemap.xml`, `http://${domain}/sitemap.xml`, `https://${domain}/sitemap_index.xml` ]; for (const sitemapUrl of sitemapPaths) { try { return await this.getUrls(sitemapUrl); } catch (error) { // Continue to next path } } throw new Error(`No sitemap found for domain: ${domain}`); } } exports.SitemapService = SitemapService; //# sourceMappingURL=sitemap.service.js.map