aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/bots.ts14
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { asyncMiddleware } from '../middlewares' 2import { asyncMiddleware } from '../middlewares'
3import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' 3import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
4import * as sitemapModule from 'sitemap' 4import { SitemapStream, streamToPromise } from 'sitemap'
5import { VideoModel } from '../models/video/video' 5import { VideoModel } from '../models/video/video'
6import { VideoChannelModel } from '../models/video/video-channel' 6import { VideoChannelModel } from '../models/video/video-channel'
7import { AccountModel } from '../models/account/account' 7import { 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)