diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/bots.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts index 63280dabb..541b40e8e 100644 --- a/server/controllers/bots.ts +++ b/server/controllers/bots.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { asyncMiddleware } from '../middlewares' | 2 | import { asyncMiddleware } from '../middlewares' |
3 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' | 3 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' |
4 | import * as sitemapModule from 'sitemap' | 4 | import { SitemapStream, streamToPromise } from 'sitemap' |
5 | import { VideoModel } from '../models/video/video' | 5 | import { VideoModel } from '../models/video/video' |
6 | import { VideoChannelModel } from '../models/video/video-channel' | 6 | import { VideoChannelModel } from '../models/video/video-channel' |
7 | import { AccountModel } from '../models/account/account' | 7 | import { AccountModel } from '../models/account/account' |
@@ -33,12 +33,14 @@ async function getSitemap (req: express.Request, res: express.Response) { | |||
33 | urls = urls.concat(await getSitemapVideoChannelUrls()) | 33 | urls = urls.concat(await getSitemapVideoChannelUrls()) |
34 | urls = urls.concat(await getSitemapAccountUrls()) | 34 | urls = urls.concat(await getSitemapAccountUrls()) |
35 | 35 | ||
36 | const sitemap = sitemapModule.createSitemap({ | 36 | const sitemapStream = new SitemapStream({ hostname: WEBSERVER.URL }) |
37 | hostname: WEBSERVER.URL, | 37 | |
38 | urls: urls | 38 | for (const url of urls) { |
39 | }) | 39 | sitemapStream.write({ url }) |
40 | } | ||
41 | sitemapStream.end() | ||
40 | 42 | ||
41 | const xml = sitemap.toXML() | 43 | const xml = await streamToPromise(sitemapStream) |
42 | 44 | ||
43 | res.header('Content-Type', 'application/xml') | 45 | res.header('Content-Type', 'application/xml') |
44 | res.send(xml) | 46 | res.send(xml) |