Files
Tony 08a38f0a5e refactor: typing house-keeping (#23074)
* refactor: typing house-keeping

* fix: fix parse date not accepting strict mode

* refactor: use npm package

* fix: address review
2026-08-22 23:58:30 +08:00

33 lines
723 B
TypeScript

import Parser from 'rss-parser';
import { config } from '@/config';
import type { DataItem, Language } from '@/types';
interface ParsedFeed {
author?: string;
copyright?: string;
creator?: string;
generator?: string;
language?: Language;
lastBuildDate?: string;
managingEditor?: string;
pubDate?: string;
publisher?: string;
webMaster?: string;
}
type ParsedItem = Pick<DataItem, 'author' | 'category' | 'description' | 'enclosure_type' | 'enclosure_url' | 'id'> & {
magnet?: string;
};
const parser = new Parser<ParsedFeed, ParsedItem>({
customFields: {
item: ['magnet'],
},
headers: {
'User-Agent': config.ua,
},
});
export default parser;