Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/optimize performance of sitemap service (#5309)
Thomas Kaul76d053fc85b1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ad73d85d14..f57367bdf3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed+- Enhanced the performance of the dynamically composed sitemap- Improved the language localization for Polish (`pl`)- Improved the language localization for Spanish (`es`)diff --git a/apps/api/src/app/endpoints/sitemap/sitemap.service.ts b/apps/api/src/app/endpoints/sitemap/sitemap.service.tsindex d18fe884a6..3774d2274a 100644--- a/apps/api/src/app/endpoints/sitemap/sitemap.service.ts+++ b/apps/api/src/app/endpoints/sitemap/sitemap.service.ts@@ -21,18 +21,42 @@ export class SitemapService {const rootUrl = this.configurationService.get('ROOT_URL');return SUPPORTED_LANGUAGE_CODES.flatMap((languageCode) => {+ const resourcesPath = this.i18nService.getTranslation({+ languageCode,+ id: publicRoutes.resources.path.match(+ SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX+ ).groups.id+ });++ const personalFinanceToolsPath = this.i18nService.getTranslation({+ languageCode,+ id: publicRoutes.resources.subRoutes.personalFinanceTools.path.match(+ SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX+ ).groups.id+ });++ const productPath = this.i18nService.getTranslation({+ languageCode,+ id: publicRoutes.resources.subRoutes.personalFinanceTools.subRoutes.product.path.match(+ SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX+ ).groups.id+ });+return personalFinanceTools.map(({ alias, key }) => {- const route =- publicRoutes.resources.subRoutes.personalFinanceTools.subRoutes- .product;- const params = {- currentDate,- languageCode,+ const location = [rootUrl,- urlPostfix: alias ?? key- };-- return this.createRouteSitemapUrl({ ...params, route });+ languageCode,+ resourcesPath,+ personalFinanceToolsPath,+ `${productPath}-${alias ?? key}`+ ].join('/');++ return [+ ' <url>',+ ` <loc>${location}</loc>`,+ ` <lastmod>${currentDate}T00:00:00+00:00</lastmod>`,+ ' </url>'+ ].join('\n');});}).join('\n');}@@ -58,14 +82,12 @@ export class SitemapService {currentDate,languageCode,rootUrl,- route,- urlPostfix+ route}: {currentDate: string;languageCode: string;rootUrl: string;route?: PublicRoute;- urlPostfix?: string;}): string {const segments =route?.routerLink.map((link) => {@@ -83,9 +105,7 @@ export class SitemapService {return segment.replace(/^\/+|\/+$/, '');}) ?? [];- const location =- [rootUrl, languageCode, ...segments].join('/') +- (urlPostfix ? `-${urlPostfix}` : '');+ const location = [rootUrl, languageCode, ...segments].join('/');return [' <url>',diff --git a/apps/api/src/middlewares/html-template.middleware.ts b/apps/api/src/middlewares/html-template.middleware.tsindex 5cf353e9a0..75ec374802 100644--- a/apps/api/src/middlewares/html-template.middleware.ts+++ b/apps/api/src/middlewares/html-template.middleware.ts@@ -154,13 +154,9 @@ export class HtmlTemplateMiddleware implements NestMiddleware {if (filename === '/assets/LICENSE') {return true;} else if (- filename.includes('auth/ey') ||- filename.includes(- 'personal-finance-tools/open-source-alternative-to-de.fi'- ) ||- filename.includes(- 'personal-finance-tools/open-source-alternative-to-markets.sh'- )+ filename.endsWith('-de.fi') ||+ filename.endsWith('-markets.sh') ||+ filename.includes('auth/ey')) {return false;}