-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f5e407
commit 67eb496
Showing
5 changed files
with
73 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { headers } from 'next/headers'; | ||
|
||
import { Feed } from '../../../models/feed'; | ||
import { getFeed } from '../../../api/feed'; | ||
import { generateFeedsString } from '../../../services/feeds'; | ||
import { url } from '../../../../config'; | ||
import { getRequestContext } from '../../../utils/requestContext'; | ||
|
||
//export async function get(ctx: any) { | ||
export async function GET() { | ||
const response: Response = await getFeed(getRequestContext(headers())); | ||
// ctx.res.statusCode = response.status; // TODO | ||
|
||
if (response.status !== 200) { | ||
return new Response(new Blob(), { status: 404 }); | ||
} | ||
let feedResponses = await response.json() as Array<Feed>; | ||
const feeds = feedResponses.map(feed => { | ||
return { | ||
title: feed.title, | ||
link: feed.link, | ||
id: feed.id, | ||
published: feed.published, | ||
updated: feed.updated | ||
} | ||
}) as Array<Feed>; | ||
|
||
const feedXmlString = await generateFeedsString(url, feeds); | ||
return new Response(feedXmlString, { | ||
headers: { | ||
"Content-Type": "text/xml", | ||
}, | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { headers } from 'next/headers'; | ||
|
||
import { Sitemap } from '../../models/sitemap'; | ||
import { getSitemap } from '../../api/sitemap'; | ||
import { generateSitemapString } from '../../services/sitemap'; | ||
import { url } from '../../../config'; | ||
import { getRequestContext } from '../../utils/requestContext'; | ||
|
||
export async function GET() { | ||
const response: Response = await getSitemap(getRequestContext(headers())); | ||
|
||
/* TODO | ||
ctx.res.statusCode = response.status; | ||
let sitemapResponse = null; | ||
if (response.status !== 200) { | ||
return { | ||
props: { | ||
statusCode: 404 | ||
} | ||
} | ||
} | ||
*/ | ||
let sitemapResponse = await response.json() as Array<Sitemap>; | ||
const sitemap = sitemapResponse.map(sitemap => { | ||
return { | ||
loc: sitemap.loc, | ||
lastMod: sitemap.lastMod | ||
} | ||
}) as Array<Sitemap>; | ||
|
||
const sitemapXmlString = await generateSitemapString(url, sitemap); | ||
return new Response(sitemapXmlString, { | ||
headers: { | ||
"Content-Type": "text/xml", | ||
}, | ||
}); | ||
} |