mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-16 23:00:51 +00:00
refactor: Replace inline type definitions with RSSItem type for improved readability and consistency
This commit is contained in:
parent
52c42dae1e
commit
cfbb65f7ae
1 changed files with 10 additions and 8 deletions
|
|
@ -11,6 +11,13 @@ import { JSONObject, JSONArray } from "Common/Types/JSON";
|
|||
import logger from "Common/Server/Utils/Logger";
|
||||
import { getStatusPageData, StatusPageData } from "../Utils/StatusPage";
|
||||
|
||||
type RSSItem = {
|
||||
title: string;
|
||||
description: string;
|
||||
link: string;
|
||||
pubDate: string;
|
||||
};
|
||||
|
||||
export const handleRSS: (
|
||||
req: ExpressRequest,
|
||||
res: ExpressResponse,
|
||||
|
|
@ -65,12 +72,7 @@ export const handleRSS: (
|
|||
},
|
||||
});
|
||||
|
||||
const items: Array<{
|
||||
title: string;
|
||||
description: string;
|
||||
link: string;
|
||||
pubDate: string;
|
||||
}> = [];
|
||||
const items: RSSItem[] = [];
|
||||
|
||||
const isPreview: boolean = req.path.includes("/status-page/");
|
||||
const baseUrl: string = isPreview
|
||||
|
|
@ -132,7 +134,7 @@ export const handleRSS: (
|
|||
}
|
||||
|
||||
// Sort items by pubDate descending
|
||||
items.sort((a: (typeof items)[0], b: (typeof items)[0]) => {
|
||||
items.sort((a: RSSItem, b: RSSItem) => {
|
||||
return new Date(b.pubDate).getTime() - new Date(a.pubDate).getTime();
|
||||
});
|
||||
|
||||
|
|
@ -148,7 +150,7 @@ export const handleRSS: (
|
|||
<atom:link href="${feedUrl}" rel="self" type="application/rss+xml" />
|
||||
`;
|
||||
|
||||
items.forEach((item: (typeof items)[0]) => {
|
||||
items.forEach((item: RSSItem) => {
|
||||
rssXml += `
|
||||
<item>
|
||||
<title><![CDATA[${item.title}]]></title>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue