mirror of https://github.com/ghostfolio/ghostfolio
Thomas Kaul
1 year ago
committed by
GitHub
8 changed files with 89 additions and 40 deletions
@ -0,0 +1,36 @@ |
|||||
|
import * as fs from 'fs'; |
||||
|
import * as path from 'path'; |
||||
|
|
||||
|
import { |
||||
|
DATE_FORMAT, |
||||
|
getYesterday, |
||||
|
interpolate |
||||
|
} from '@ghostfolio/common/helper'; |
||||
|
import { Controller, Get, Res, VERSION_NEUTRAL, Version } from '@nestjs/common'; |
||||
|
import { format } from 'date-fns'; |
||||
|
import { Response } from 'express'; |
||||
|
|
||||
|
@Controller('/sitemap.xml') |
||||
|
export class SitemapController { |
||||
|
public sitemapXml = ''; |
||||
|
|
||||
|
public constructor() { |
||||
|
try { |
||||
|
this.sitemapXml = fs.readFileSync( |
||||
|
path.join(__dirname, 'assets', 'sitemap.xml'), |
||||
|
'utf8' |
||||
|
); |
||||
|
} catch {} |
||||
|
} |
||||
|
|
||||
|
@Get() |
||||
|
@Version(VERSION_NEUTRAL) |
||||
|
public async flushCache(@Res() response: Response): Promise<void> { |
||||
|
response.setHeader('content-type', 'application/xml'); |
||||
|
response.send( |
||||
|
interpolate(this.sitemapXml, { |
||||
|
currentDate: format(getYesterday(), DATE_FORMAT) |
||||
|
}) |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module'; |
||||
|
import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module'; |
||||
|
import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering/data-gathering.module'; |
||||
|
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module'; |
||||
|
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.module'; |
||||
|
import { PrismaModule } from '@ghostfolio/api/services/prisma/prisma.module'; |
||||
|
import { SymbolProfileModule } from '@ghostfolio/api/services/symbol-profile/symbol-profile.module'; |
||||
|
import { Module } from '@nestjs/common'; |
||||
|
|
||||
|
import { SitemapController } from './sitemap.controller'; |
||||
|
|
||||
|
@Module({ |
||||
|
controllers: [SitemapController], |
||||
|
imports: [ |
||||
|
ConfigurationModule, |
||||
|
DataGatheringModule, |
||||
|
DataProviderModule, |
||||
|
ExchangeRateDataModule, |
||||
|
PrismaModule, |
||||
|
RedisCacheModule, |
||||
|
SymbolProfileModule |
||||
|
] |
||||
|
}) |
||||
|
export class SitemapModule {} |
Loading…
Reference in new issue