Skip to content

Commit

Permalink
refactor: typedefination for rss parsed data
Browse files Browse the repository at this point in the history
  • Loading branch information
Insiro committed Jul 25, 2022
1 parent f3f9345 commit 77eed0d
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/newsUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,31 @@ import AppDataSource from './data-sources';

const newsRepository = AppDataSource.getRepository(NewsDate);

async function getData(url: string): Promise<Array<any>> {
interface CyphersRssItem {
title: [string];
link: [string];
description: [string];
category: [string];
pubDate: [string];
guid: [string];
}
interface CyphersRss {
rss: {
version: [string];
channel: [
{
title: string;
link: string;
description: string;
item: [CyphersRssItem];
}
];
};
}

async function getData(url: string): Promise<Array<CyphersRssItem>> {
const re = await axios.get(url);
const result= await parseStringPromise(re.data, {
const result: CyphersRss = await parseStringPromise(re.data, {
mergeAttrs: true,
});

Expand All @@ -29,7 +51,7 @@ async function sendEmbed(client: Client, embed: MessageEmbed): Promise<void> {
}

function pushEmbedList(
parsedData: any[],
parsedData: CyphersRssItem[],
compareDate: Date | null,
embedList: Array<MessageEmbed>
): void {
Expand Down

0 comments on commit 77eed0d

Please sign in to comment.