rsshub 1.0.0-master.ebff6c5 → 1.0.0-master.ec03e07
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/radar/rules/all.ts +3 -6
- package/lib/api/radar/rules/one.ts +3 -6
- package/lib/app.tsx +2 -0
- package/lib/config.ts +28 -6
- package/lib/errors/index.tsx +10 -3
- package/lib/index.ts +1 -1
- package/lib/middleware/anti-hotlink.test.ts +6 -6
- package/lib/middleware/logger.ts +5 -1
- package/lib/middleware/parameter.test.ts +22 -5
- package/lib/middleware/parameter.ts +47 -17
- package/lib/middleware/template.tsx +14 -10
- package/lib/middleware/trace.ts +25 -0
- package/lib/registry.test.ts +8 -0
- package/lib/registry.ts +8 -0
- package/lib/router.js +0 -3
- package/lib/routes/141jav/index.ts +25 -21
- package/lib/routes/141ppv/index.ts +24 -20
- package/lib/routes/51read/article.ts +82 -0
- package/lib/routes/51read/namespace.ts +6 -0
- package/lib/routes/69shu/article.ts +4 -4
- package/lib/routes/aljazeera/index.ts +2 -2
- package/lib/routes/apnews/rss.ts +2 -1
- package/lib/routes/apnews/sitemap.ts +98 -0
- package/lib/routes/apnews/topics.ts +2 -1
- package/lib/routes/apnews/utils.ts +7 -5
- package/lib/routes/apple/apps.ts +30 -8
- package/lib/routes/asmr-200/index.ts +66 -0
- package/lib/routes/asmr-200/namespace.ts +6 -0
- package/lib/routes/asmr-200/templates/work.art +7 -0
- package/lib/routes/asmr-200/type.ts +96 -0
- package/lib/routes/autocentre/index.ts +29 -0
- package/lib/routes/autocentre/namespace.ts +7 -0
- package/lib/routes/bbc/index.ts +3 -1
- package/lib/routes/bilibili/api-interface.d.ts +1 -0
- package/lib/routes/bilibili/cache.ts +3 -1
- package/lib/routes/bilibili/dynamic.ts +7 -2
- package/lib/routes/bilibili/ranking.ts +2 -1
- package/lib/routes/bilibili/video.ts +2 -1
- package/lib/routes/bing/daily-wallpaper.ts +1 -1
- package/lib/routes/bjnews/cat.ts +43 -0
- package/lib/routes/bjnews/column.ts +43 -0
- package/lib/routes/bjnews/namespace.ts +6 -0
- package/lib/routes/bjnews/utils.ts +19 -0
- package/lib/routes/bjx/fd.ts +35 -26
- package/lib/routes/bluearchive/news.ts +2 -2
- package/lib/routes/bt0/mv.ts +21 -24
- package/lib/routes/bt0/tlist.ts +19 -26
- package/lib/routes/bt0/util.ts +6 -3
- package/lib/routes/buaa/jiaowu.ts +124 -0
- package/lib/routes/buaa/lib/space/newbook.ts +171 -0
- package/lib/routes/buaa/lib/space/templates/newbook.art +44 -0
- package/lib/routes/buaa/news/index.ts +15 -13
- package/lib/routes/buaa/sme.ts +5 -3
- package/lib/routes/cccfna/index.ts +2 -2
- package/lib/routes/cctv/category.ts +16 -12
- package/lib/routes/cctv/xwlb.ts +32 -10
- package/lib/routes/cdu/jwgg.ts +79 -0
- package/lib/routes/cdu/namespace.ts +6 -0
- package/lib/routes/cffex/announcement.ts +73 -0
- package/lib/routes/cffex/namespace.ts +6 -0
- package/lib/routes/chlinlearn/daily-blog.ts +48 -0
- package/lib/routes/chlinlearn/namespcae.ts +6 -0
- package/lib/routes/cnbc/rss.ts +1 -1
- package/lib/routes/copymanga/comic.ts +3 -1
- package/lib/routes/deadbydaylight/index.ts +69 -0
- package/lib/routes/deadbydaylight/namespace.ts +12 -0
- package/lib/routes/devolverdigital/blog.ts +59 -42
- package/lib/routes/digitalcameraworld/news.ts +1 -1
- package/lib/routes/discord/channel.ts +10 -10
- package/lib/routes/discord/discord-api.ts +27 -32
- package/lib/routes/discord/templates/message.art +15 -0
- package/lib/routes/discourse/notifications.ts +2 -1
- package/lib/routes/dockerhub/build.ts +3 -2
- package/lib/routes/dongqiudi/result.ts +1 -1
- package/lib/routes/douban/other/group.ts +2 -1
- package/lib/routes/duckdb/namespace.ts +6 -0
- package/lib/routes/duckdb/news.ts +65 -0
- package/lib/routes/eastmoney/report/index.ts +63 -15
- package/lib/routes/eastmoney/templates/stock_description.art +36 -0
- package/lib/routes/eastmoney/utils.ts +35 -0
- package/lib/routes/epicgames/index.ts +14 -4
- package/lib/routes/fashionnetwork/index.ts +192 -0
- package/lib/routes/fashionnetwork/namespace.ts +8 -0
- package/lib/routes/fashionnetwork/templates/description.art +17 -0
- package/lib/routes/fediverse/timeline.ts +44 -19
- package/lib/routes/flashcat/blog.ts +61 -0
- package/lib/routes/flashcat/namespace.ts +6 -0
- package/lib/routes/foresightnews/util.ts +1 -1
- package/lib/routes/fortunechina/index.ts +24 -14
- package/lib/routes/ftm/index.ts +60 -0
- package/lib/routes/ftm/namespace.ts +6 -0
- package/lib/routes/galxe/index.ts +94 -0
- package/lib/routes/galxe/namespace.ts +9 -0
- package/lib/routes/gdut/oa-news.ts +12 -17
- package/lib/routes/getitfree/util.ts +1 -1
- package/lib/routes/gisreportsonline/index.ts +60 -0
- package/lib/routes/gisreportsonline/namespace.ts +6 -0
- package/lib/routes/github/activity.ts +56 -0
- package/lib/routes/github/issue.ts +3 -2
- package/lib/routes/github/search.ts +20 -18
- package/lib/routes/github/star.ts +4 -3
- package/lib/routes/github/trending.ts +27 -5
- package/lib/routes/google/citations.ts +2 -2
- package/lib/routes/google/research.ts +45 -0
- package/lib/routes/google/scholar.ts +2 -2
- package/lib/routes/gov/chongqing/sydwgkzp.ts +4 -4
- package/lib/routes/gov/lswz/index.ts +289 -0
- package/lib/routes/gov/stats/index.ts +8 -8
- package/lib/routes/gov/zj/ningbogzw-notice.ts +50 -0
- package/lib/routes/gov/zj/ningborsjnotice.ts +50 -0
- package/lib/routes/gq/news.ts +1 -1
- package/lib/routes/gs/developer/blog.ts +58 -0
- package/lib/routes/gs/namespace.ts +9 -0
- package/lib/routes/healthz.ts +8 -0
- package/lib/routes/hitcon/zeroday.ts +1 -1
- package/lib/routes/hket/index.ts +80 -76
- package/lib/routes/hottoys/index.ts +63 -0
- package/lib/routes/hottoys/namespace.ts +6 -0
- package/lib/routes/huxiu/util.ts +2 -2
- package/lib/routes/imhcg/blog.ts +47 -0
- package/lib/routes/imhcg/namespace.ts +7 -0
- package/lib/routes/imop/namespace.ts +10 -0
- package/lib/routes/imop/tianshu.ts +53 -0
- package/lib/routes/infzm/hot.ts +39 -0
- package/lib/routes/infzm/index.ts +3 -30
- package/lib/routes/infzm/utils.ts +34 -0
- package/lib/routes/inspirehep/author.ts +46 -0
- package/lib/routes/inspirehep/literature.ts +42 -0
- package/lib/routes/inspirehep/namespace.ts +7 -0
- package/lib/routes/inspirehep/types.ts +210 -0
- package/lib/routes/inspirehep/utils.ts +15 -0
- package/lib/routes/instagram/private-api/index.ts +20 -3
- package/lib/routes/investor/index.ts +213 -0
- package/lib/routes/investor/namespace.ts +8 -0
- package/lib/routes/iplaysoft/index.ts +68 -0
- package/lib/routes/iplaysoft/namespace.ts +6 -0
- package/lib/routes/iwara/subscriptions.ts +1 -1
- package/lib/routes/j-test/namespace.ts +6 -0
- package/lib/routes/j-test/news.ts +64 -0
- package/lib/routes/japanpost/namespace.ts +7 -1
- package/lib/routes/japanpost/router.ts +40 -0
- package/lib/routes/japanpost/track.ts +1 -23
- package/lib/routes/javbus/index.ts +2 -1
- package/lib/routes/javdb/actors.ts +6 -2
- package/lib/routes/jjwxc/book.ts +4 -3
- package/lib/routes/joins/chinese.ts +218 -0
- package/lib/routes/joins/namespace.ts +8 -0
- package/lib/routes/joins/templates/description.art +17 -0
- package/lib/routes/juejin/dynamic.ts +114 -0
- package/lib/routes/kaopu/news.ts +3 -3
- package/lib/routes/kemono/index.ts +21 -0
- package/lib/routes/keylol/index.ts +56 -11
- package/lib/routes/kurogames/namespace.ts +7 -0
- package/lib/routes/kurogames/wutheringwaves/news.ts +59 -0
- package/lib/routes/kyodonews/index.ts +1 -1
- package/lib/routes/link3/events.ts +86 -0
- package/lib/routes/link3/namespace.ts +6 -0
- package/lib/routes/link3/profile.ts +143 -0
- package/lib/routes/linkedin/cn/renderer.ts +1 -1
- package/lib/routes/lmu/jobs.ts +96 -0
- package/lib/routes/lmu/namespace.ts +17 -0
- package/lib/routes/lmu/templates/jobPosting.art +11 -0
- package/lib/routes/lofter/user.ts +2 -1
- package/lib/routes/luolei/index.ts +1 -1
- package/lib/routes/maccms/index.ts +72 -0
- package/lib/routes/maccms/namespace.ts +9 -0
- package/lib/routes/maccms/type.ts +102 -0
- package/lib/routes/mcmod/index.ts +105 -0
- package/lib/routes/mcmod/namespace.ts +6 -0
- package/lib/routes/mcmod/templates/mod.art +13 -0
- package/lib/routes/metacritic/index.ts +10 -0
- package/lib/routes/metrics.ts +12 -0
- package/lib/routes/microsoft/mcr.ts +1 -1
- package/lib/routes/mihoyo/bbs/img-ranking.ts +4 -4
- package/lib/routes/mihoyo/bbs/static-data.ts +7 -0
- package/lib/routes/minecraft/version.ts +1 -1
- package/lib/routes/mirrormedia/category.ts +101 -0
- package/lib/routes/mirrormedia/index.ts +43 -0
- package/lib/routes/mirrormedia/namespace.ts +6 -0
- package/lib/routes/mirrormedia/utils.ts +19 -0
- package/lib/routes/misskey/user-timeline.ts +42 -0
- package/lib/routes/misskey/utils.ts +41 -1
- package/lib/routes/nasa/apod.ts +4 -3
- package/lib/routes/nasa/namespace.ts +1 -1
- package/lib/routes/nationalgeographic/latest-stories.ts +1 -1
- package/lib/routes/nationalgeographic/templates/stories.art +1 -1
- package/lib/routes/neea/index.ts +47 -19
- package/lib/routes/neea/jlpt.ts +12 -15
- package/lib/routes/neea/namespace.ts +2 -2
- package/lib/routes/newyorker/news.ts +24 -17
- package/lib/routes/nextjs/blog.ts +63 -0
- package/lib/routes/nextjs/namespace.ts +6 -0
- package/lib/routes/nga/forum.ts +3 -2
- package/lib/routes/notion/release.ts +81 -0
- package/lib/routes/nyaa/main.ts +2 -3
- package/lib/routes/nyaa/namespace.ts +10 -0
- package/lib/routes/oschina/news.ts +2 -0
- package/lib/routes/people/index.ts +4 -2
- package/lib/routes/picnob/namespace.ts +1 -4
- package/lib/routes/picnob/user.ts +3 -2
- package/lib/routes/picuki/namespace.ts +1 -4
- package/lib/routes/picuki/profile.ts +11 -7
- package/lib/routes/pixiv/ranking.ts +2 -1
- package/lib/routes/pixiv/search.ts +22 -2
- package/lib/routes/pixiv/user.ts +2 -1
- package/lib/routes/pixiv/utils.ts +3 -3
- package/lib/routes/ps/monthly-games.ts +3 -2
- package/lib/routes/psyche/topic.ts +1 -1
- package/lib/routes/psyche/type.ts +1 -1
- package/lib/routes/psyche/utils.ts +1 -1
- package/lib/routes/qidian/chapter.ts +4 -3
- package/lib/routes/questn/community.ts +76 -0
- package/lib/routes/questn/events.ts +101 -0
- package/lib/routes/questn/namespace.ts +6 -0
- package/lib/routes/questn/util.ts +16 -0
- package/lib/routes/raycast/changelog.ts +54 -0
- package/lib/routes/raycast/namespace.ts +7 -0
- package/lib/routes/react/blog.ts +57 -0
- package/lib/routes/react/namespace.ts +6 -0
- package/lib/routes/readwise/list.ts +152 -0
- package/lib/routes/readwise/namespace.ts +6 -0
- package/lib/routes/rebase/geekdaily.ts +35 -0
- package/lib/routes/rebase/namespace.ts +6 -0
- package/lib/routes/reuters/common.ts +2 -1
- package/lib/routes/rss3/index.ts +157 -0
- package/lib/routes/rss3/interfaces/metadata.ts +67 -0
- package/lib/routes/rss3/namespace.ts +7 -0
- package/lib/routes/rsshub/routes.ts +20 -13
- package/lib/routes/samd/news.ts +1 -1
- package/lib/routes/sara/index.ts +1 -1
- package/lib/routes/sciencedirect/cf-email.ts +0 -1
- package/lib/routes/scut/gzic/media.ts +71 -0
- package/lib/routes/scut/gzic/news.ts +65 -0
- package/lib/routes/scut/gzic/notice.ts +88 -0
- package/lib/routes/shiep/config.ts +4 -10
- package/lib/routes/shiep/index.ts +9 -9
- package/lib/routes/showstart/artist.ts +5 -4
- package/lib/routes/showstart/brand.ts +5 -4
- package/lib/routes/showstart/event.ts +8 -7
- package/lib/routes/showstart/search.ts +43 -9
- package/lib/routes/showstart/service.ts +81 -53
- package/lib/routes/showstart/site.ts +41 -0
- package/lib/routes/showstart/utils.ts +9 -8
- package/lib/routes/sjtu/jwc.ts +4 -1
- package/lib/routes/sjtu/yzb/zkxx.ts +36 -16
- package/lib/routes/smzdm/keyword.ts +3 -2
- package/lib/routes/smzdm/product.ts +86 -0
- package/lib/routes/smzdm/ranking.ts +180 -46
- package/lib/routes/spotify/artist.ts +3 -2
- package/lib/routes/spotify/playlist.ts +3 -2
- package/lib/routes/spotify/show.ts +1 -1
- package/lib/routes/springer/journal.ts +10 -12
- package/lib/routes/sse/sselawsrules.ts +370 -0
- package/lib/routes/sspai/author.ts +1 -1
- package/lib/routes/sspai/column.ts +1 -1
- package/lib/routes/sspai/index.ts +4 -3
- package/lib/routes/sspai/matrix.ts +1 -1
- package/lib/routes/sspai/series-update.ts +1 -1
- package/lib/routes/sspai/tag.ts +1 -1
- package/lib/routes/sspai/topic.ts +1 -1
- package/lib/routes/sustainabilitymag/articles.ts +2 -0
- package/lib/routes/szse/rule.ts +315 -42
- package/lib/routes/t66y/index.ts +29 -7
- package/lib/routes/techcrunch/news.ts +20 -29
- package/lib/routes/techcrunch/templates/description.art +7 -0
- package/lib/routes/telecompaper/news.ts +1 -1
- package/lib/routes/telegram/channel.ts +38 -4
- package/lib/routes/test/index.ts +6 -36
- package/lib/routes/the/index.ts +210 -0
- package/lib/routes/the/namespace.ts +8 -0
- package/lib/routes/the/templates/description.art +27 -0
- package/lib/routes/the/util.ts +307 -0
- package/lib/routes/thoughtworks/index.ts +71 -0
- package/lib/routes/thoughtworks/namespace.ts +6 -0
- package/lib/routes/towardsdatascience/latest.ts +67 -0
- package/lib/routes/towardsdatascience/namespace.ts +6 -0
- package/lib/routes/tsdm39/bd.ts +101 -0
- package/lib/routes/tsdm39/namespace.ts +7 -0
- package/lib/routes/tvb/news.ts +1 -0
- package/lib/routes/twitter/api/index.ts +3 -1
- package/lib/routes/twitter/api/mobile-api/login.ts +155 -131
- package/lib/routes/twitter/api/web-api/api.ts +19 -0
- package/lib/routes/twitter/api/web-api/constants.ts +2 -0
- package/lib/routes/twitter/api/web-api/login.ts +66 -0
- package/lib/routes/twitter/api/web-api/utils.ts +98 -52
- package/lib/routes/twitter/home-latest.ts +60 -0
- package/lib/routes/twitter/home.ts +2 -2
- package/lib/routes/twitter/keyword.ts +3 -2
- package/lib/routes/twitter/likes.ts +1 -1
- package/lib/routes/twitter/list.ts +1 -1
- package/lib/routes/twitter/media.ts +4 -3
- package/lib/routes/twitter/namespace.ts +2 -2
- package/lib/routes/twitter/user.ts +5 -4
- package/lib/routes/twitter/utils.ts +4 -1
- package/lib/routes/uber/blog.ts +1 -1
- package/lib/routes/udn/breaking-news.ts +9 -0
- package/lib/routes/ustc/scms.ts +97 -0
- package/lib/routes/utgd/category.ts +18 -59
- package/lib/routes/utgd/timeline.ts +9 -45
- package/lib/routes/utgd/topic.ts +9 -51
- package/lib/routes/utgd/utils.ts +41 -0
- package/lib/routes/v2ex/tab.ts +3 -2
- package/lib/routes/v2ex/topics.ts +18 -3
- package/lib/routes/v2ex/xna.ts +55 -0
- package/lib/routes/watasuke/blog.ts +1 -1
- package/lib/routes/wchscu/namespace.ts +6 -0
- package/lib/routes/wchscu/recruit.ts +73 -0
- package/lib/routes/weibo/keyword.ts +3 -2
- package/lib/routes/weibo/namespace.ts +1 -1
- package/lib/routes/weibo/search/hot.ts +12 -7
- package/lib/routes/weibo/user.ts +2 -1
- package/lib/routes/weibo/utils.ts +20 -0
- package/lib/routes/wfu/news.ts +1 -1
- package/lib/routes/wordpress/util.ts +1 -1
- package/lib/routes/xiaohongshu/notes.ts +10 -2
- package/lib/routes/xiaohongshu/user.ts +23 -2
- package/lib/routes/xiaoyuzhou/podcast.ts +2 -1
- package/lib/routes/xidian/cs.ts +143 -0
- package/lib/routes/xidian/gr.ts +289 -0
- package/lib/routes/xidian/jwc.ts +1 -0
- package/lib/routes/xidian/namespace.ts +1 -1
- package/lib/routes/xinhuanet/app.ts +109 -0
- package/lib/routes/xinhuanet/namespace.ts +8 -0
- package/lib/routes/xsijishe/forum.ts +5 -0
- package/lib/routes/xsijishe/rank.ts +23 -3
- package/lib/routes/yahoo/news/index.ts +149 -0
- package/lib/routes/yahoo/news/listid.ts +67 -0
- package/lib/routes/yahoo/news/{tw/provider-helper.ts → provider-helper.ts} +9 -4
- package/lib/routes/yahoo/news/{tw/provider.ts → provider.ts} +21 -6
- package/lib/routes/yahoo/news/{tw/utils.ts → utils.ts} +24 -15
- package/lib/routes/yicai/carousel.ts +48 -0
- package/lib/routes/yicai/utils.ts +23 -17
- package/lib/routes/youtube/subscriptions.ts +1 -0
- package/lib/routes/youtube/user.ts +2 -1
- package/lib/routes/yystv/docs.ts +28 -19
- package/lib/routes/zcool/discover.ts +2 -1
- package/lib/routes/zhihu/activities.ts +2 -1
- package/lib/routes/zhihu/answers.ts +5 -1
- package/lib/routes/zhihu/execlib/x-zse-96-v3.ts +2 -0
- package/lib/routes/zhihu/hot.ts +56 -7
- package/lib/routes/zhihu/namespace.ts +3 -0
- package/lib/routes/zhihu/utils.ts +16 -6
- package/lib/routes/zhuwang/index.ts +1 -1
- package/lib/routes/zsxq/types.ts +9 -0
- package/lib/routes/zsxq/utils.ts +4 -3
- package/lib/routes.test.ts +11 -5
- package/lib/setup.test.ts +1 -1
- package/lib/types.ts +20 -0
- package/lib/utils/cache/index.ts +8 -0
- package/lib/utils/camelcase-keys.spec.ts +127 -0
- package/lib/utils/camelcase-keys.ts +27 -0
- package/lib/utils/common-utils.ts +1 -0
- package/lib/utils/ofetch.ts +14 -0
- package/lib/utils/otel/index.ts +2 -0
- package/lib/utils/otel/metric.ts +66 -0
- package/lib/utils/otel/trace.ts +28 -0
- package/lib/utils/request-rewriter/fetch.ts +8 -1
- package/lib/views/atom.tsx +2 -2
- package/lib/views/error.tsx +3 -3
- package/lib/views/index.tsx +4 -3
- package/lib/views/json.ts +1 -1
- package/lib/views/layout.tsx +1 -1
- package/lib/views/rss.tsx +2 -2
- package/package.json +60 -48
- package/lib/routes/moduzy/index.ts +0 -80
- package/lib/routes/moduzy/namespace.ts +0 -17
- package/lib/routes/moduzy/type.ts +0 -95
- package/lib/routes/sse/lawandrules.ts +0 -68
- package/lib/routes/yahoo/news/tw/index.ts +0 -80
- package/lib/routes/yahoo/news/us/index.ts +0 -55
- package/lib/routes/zhihu/hotlist.ts +0 -72
- package/lib/routes-deprecated/bjnews/news.js +0 -44
- package/lib/routes-deprecated/iplay/home.js +0 -26
- package/lib/routes-deprecated/iplay/utils.js +0 -57
- /package/lib/routes/{moduzy → maccms}/templates/vod.art +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { namespaces } from '@/registry';
|
|
2
2
|
import { parse } from 'tldts';
|
|
3
|
-
import {
|
|
3
|
+
import { RadarDomain } from '@/types';
|
|
4
4
|
import { createRoute, RouteHandler } from '@hono/zod-openapi';
|
|
5
5
|
|
|
6
6
|
const radar: {
|
|
7
|
-
[domain: string]:
|
|
8
|
-
_name: string;
|
|
9
|
-
[subdomain: string]: RadarItem[] | string;
|
|
10
|
-
};
|
|
7
|
+
[domain: string]: RadarDomain;
|
|
11
8
|
} = {};
|
|
12
9
|
|
|
13
10
|
for (const namespace in namespaces) {
|
|
@@ -23,7 +20,7 @@ for (const namespace in namespaces) {
|
|
|
23
20
|
if (!radar[domain]) {
|
|
24
21
|
radar[domain] = {
|
|
25
22
|
_name: namespaces[namespace].name,
|
|
26
|
-
};
|
|
23
|
+
} as RadarDomain;
|
|
27
24
|
}
|
|
28
25
|
if (!radar[domain][subdomain]) {
|
|
29
26
|
radar[domain][subdomain] = [];
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { namespaces } from '@/registry';
|
|
2
2
|
import { parse } from 'tldts';
|
|
3
|
-
import {
|
|
3
|
+
import { RadarDomain } from '@/types';
|
|
4
4
|
import { z, createRoute, RouteHandler } from '@hono/zod-openapi';
|
|
5
5
|
|
|
6
6
|
const radar: {
|
|
7
|
-
[domain: string]:
|
|
8
|
-
_name: string;
|
|
9
|
-
[subdomain: string]: RadarItem[] | string;
|
|
10
|
-
};
|
|
7
|
+
[domain: string]: RadarDomain;
|
|
11
8
|
} = {};
|
|
12
9
|
|
|
13
10
|
for (const namespace in namespaces) {
|
|
@@ -23,7 +20,7 @@ for (const namespace in namespaces) {
|
|
|
23
20
|
if (!radar[domain]) {
|
|
24
21
|
radar[domain] = {
|
|
25
22
|
_name: namespaces[namespace].name,
|
|
26
|
-
};
|
|
23
|
+
} as RadarDomain;
|
|
27
24
|
}
|
|
28
25
|
if (!radar[domain][subdomain]) {
|
|
29
26
|
radar[domain][subdomain] = [];
|
package/lib/app.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import debug from '@/middleware/debug';
|
|
|
12
12
|
import header from '@/middleware/header';
|
|
13
13
|
import antiHotlink from '@/middleware/anti-hotlink';
|
|
14
14
|
import parameter from '@/middleware/parameter';
|
|
15
|
+
import trace from '@/middleware/trace';
|
|
15
16
|
import { jsxRenderer } from 'hono/jsx-renderer';
|
|
16
17
|
import { trimTrailingSlash } from 'hono/trailing-slash';
|
|
17
18
|
|
|
@@ -37,6 +38,7 @@ app.use(
|
|
|
37
38
|
})
|
|
38
39
|
);
|
|
39
40
|
app.use(mLogger);
|
|
41
|
+
app.use(trace);
|
|
40
42
|
app.use(sentry);
|
|
41
43
|
app.use(accessControl);
|
|
42
44
|
app.use(debug);
|
package/lib/config.ts
CHANGED
|
@@ -39,8 +39,8 @@ export type Config = {
|
|
|
39
39
|
port?: string;
|
|
40
40
|
auth?: string;
|
|
41
41
|
url_regex: string;
|
|
42
|
+
strategy: 'on_retry' | 'all';
|
|
42
43
|
};
|
|
43
|
-
proxyStrategy: string;
|
|
44
44
|
pacUri?: string;
|
|
45
45
|
pacScript?: string;
|
|
46
46
|
accessKey?: string;
|
|
@@ -70,7 +70,9 @@ export type Config = {
|
|
|
70
70
|
temperature?: number;
|
|
71
71
|
maxTokens?: number;
|
|
72
72
|
endpoint: string;
|
|
73
|
-
|
|
73
|
+
inputOption: string;
|
|
74
|
+
promptTitle: string;
|
|
75
|
+
promptDescription: string;
|
|
74
76
|
};
|
|
75
77
|
bilibili: {
|
|
76
78
|
cookies: Record<string, string | undefined>;
|
|
@@ -168,6 +170,9 @@ export type Config = {
|
|
|
168
170
|
javdb: {
|
|
169
171
|
session?: string;
|
|
170
172
|
};
|
|
173
|
+
keylol: {
|
|
174
|
+
cookie?: string;
|
|
175
|
+
};
|
|
171
176
|
lastfm: {
|
|
172
177
|
api_key?: string;
|
|
173
178
|
};
|
|
@@ -232,6 +237,9 @@ export type Config = {
|
|
|
232
237
|
qingting: {
|
|
233
238
|
id?: string;
|
|
234
239
|
};
|
|
240
|
+
readwise: {
|
|
241
|
+
accessToken?: string;
|
|
242
|
+
};
|
|
235
243
|
saraba1st: {
|
|
236
244
|
cookie?: string;
|
|
237
245
|
};
|
|
@@ -258,11 +266,13 @@ export type Config = {
|
|
|
258
266
|
tophub: {
|
|
259
267
|
cookie?: string;
|
|
260
268
|
};
|
|
269
|
+
tsdm39: {
|
|
270
|
+
cookie: string;
|
|
271
|
+
};
|
|
261
272
|
twitter: {
|
|
262
273
|
username?: string[];
|
|
263
274
|
password?: string[];
|
|
264
275
|
authenticationSecret?: string[];
|
|
265
|
-
cookie?: string;
|
|
266
276
|
authToken?: string[];
|
|
267
277
|
};
|
|
268
278
|
weibo: {
|
|
@@ -286,6 +296,7 @@ export type Config = {
|
|
|
286
296
|
};
|
|
287
297
|
xsijishe: {
|
|
288
298
|
cookie?: string;
|
|
299
|
+
userAgent?: string;
|
|
289
300
|
};
|
|
290
301
|
xueqiu: {
|
|
291
302
|
cookies?: string;
|
|
@@ -392,8 +403,8 @@ const calculateValue = () => {
|
|
|
392
403
|
port: envs.PROXY_PORT,
|
|
393
404
|
auth: envs.PROXY_AUTH,
|
|
394
405
|
url_regex: envs.PROXY_URL_REGEX || '.*',
|
|
406
|
+
strategy: envs.PROXY_STRATEGY || 'all', // all / on_retry
|
|
395
407
|
},
|
|
396
|
-
proxyStrategy: envs.PROXY_STRATEGY || 'all', // all / on_retry
|
|
397
408
|
pacUri: envs.PAC_URI,
|
|
398
409
|
pacScript: envs.PAC_SCRIPT,
|
|
399
410
|
// access control
|
|
@@ -427,7 +438,9 @@ const calculateValue = () => {
|
|
|
427
438
|
temperature: toInt(envs.OPENAI_TEMPERATURE, 0.2),
|
|
428
439
|
maxTokens: toInt(envs.OPENAI_MAX_TOKENS, 0) || undefined,
|
|
429
440
|
endpoint: envs.OPENAI_API_ENDPOINT || 'https://api.openai.com/v1',
|
|
430
|
-
|
|
441
|
+
inputOption: envs.OPENAI_INPUT_OPTION || 'description',
|
|
442
|
+
promptDescription: envs.OPENAI_PROMPT || 'Please summarize the following article and reply with markdown format.',
|
|
443
|
+
promptTitle: envs.OPENAI_PROMPT_TITLE || 'Please translate the following title into Simplified Chinese and reply only translated text.',
|
|
431
444
|
},
|
|
432
445
|
|
|
433
446
|
// Route-specific Configurations
|
|
@@ -528,6 +541,9 @@ const calculateValue = () => {
|
|
|
528
541
|
javdb: {
|
|
529
542
|
session: envs.JAVDB_SESSION,
|
|
530
543
|
},
|
|
544
|
+
keylol: {
|
|
545
|
+
cookie: envs.KEYLOL_COOKIE,
|
|
546
|
+
},
|
|
531
547
|
lastfm: {
|
|
532
548
|
api_key: envs.LASTFM_API_KEY,
|
|
533
549
|
},
|
|
@@ -592,6 +608,9 @@ const calculateValue = () => {
|
|
|
592
608
|
qingting: {
|
|
593
609
|
id: envs.QINGTING_ID,
|
|
594
610
|
},
|
|
611
|
+
readwise: {
|
|
612
|
+
accessToken: envs.READWISE_ACCESS_TOKEN,
|
|
613
|
+
},
|
|
595
614
|
saraba1st: {
|
|
596
615
|
cookie: envs.SARABA1ST_COOKIE,
|
|
597
616
|
},
|
|
@@ -622,11 +641,13 @@ const calculateValue = () => {
|
|
|
622
641
|
tophub: {
|
|
623
642
|
cookie: envs.TOPHUB_COOKIE,
|
|
624
643
|
},
|
|
644
|
+
tsdm39: {
|
|
645
|
+
cookie: envs.TSDM39_COOKIES,
|
|
646
|
+
},
|
|
625
647
|
twitter: {
|
|
626
648
|
username: envs.TWITTER_USERNAME?.split(','),
|
|
627
649
|
password: envs.TWITTER_PASSWORD?.split(','),
|
|
628
650
|
authenticationSecret: envs.TWITTER_AUTHENTICATION_SECRET?.split(','),
|
|
629
|
-
cookie: envs.TWITTER_COOKIE,
|
|
630
651
|
authToken: envs.TWITTER_AUTH_TOKEN?.split(','),
|
|
631
652
|
},
|
|
632
653
|
weibo: {
|
|
@@ -650,6 +671,7 @@ const calculateValue = () => {
|
|
|
650
671
|
},
|
|
651
672
|
xsijishe: {
|
|
652
673
|
cookie: envs.XSIJISHE_COOKIE,
|
|
674
|
+
user_agent: envs.XSIJISHE_USER_AGENT,
|
|
653
675
|
},
|
|
654
676
|
xueqiu: {
|
|
655
677
|
cookies: envs.XUEQIU_COOKIES,
|
package/lib/errors/index.tsx
CHANGED
|
@@ -7,14 +7,20 @@ import Error from '@/views/error';
|
|
|
7
7
|
|
|
8
8
|
import NotFoundError from './types/not-found';
|
|
9
9
|
|
|
10
|
+
import { requestMetric } from '@/utils/otel';
|
|
11
|
+
|
|
10
12
|
export const errorHandler: ErrorHandler = (error, ctx) => {
|
|
11
13
|
const requestPath = ctx.req.path;
|
|
12
14
|
const matchedRoute = ctx.req.routePath;
|
|
13
15
|
const hasMatchedRoute = matchedRoute !== '/*';
|
|
14
16
|
|
|
15
17
|
const debug = getDebugInfo();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
try {
|
|
19
|
+
if (ctx.res.headers.get('RSSHub-Cache-Status')) {
|
|
20
|
+
debug.hitCache++;
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
// ignore
|
|
18
24
|
}
|
|
19
25
|
debug.error++;
|
|
20
26
|
|
|
@@ -61,8 +67,9 @@ export const errorHandler: ErrorHandler = (error, ctx) => {
|
|
|
61
67
|
const message = `${error.name}: ${errorMessage}`;
|
|
62
68
|
|
|
63
69
|
logger.error(`Error in ${requestPath}: ${message}`);
|
|
70
|
+
requestMetric.error({ path: requestPath, method: ctx.req.method, status: ctx.res.status });
|
|
64
71
|
|
|
65
|
-
return config.isPackage
|
|
72
|
+
return config.isPackage || ctx.req.query('format') === 'json'
|
|
66
73
|
? ctx.json({
|
|
67
74
|
error: {
|
|
68
75
|
message: error.message ?? error,
|
package/lib/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ const expects = {
|
|
|
36
36
|
`<a href="https://mock.com/DIYgod/RSSHub"></a>
|
|
37
37
|
<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">`,
|
|
38
38
|
],
|
|
39
|
-
desc: '<img src="http://mock.com/DIYgod/DIYgod/RSSHub"> -
|
|
39
|
+
desc: '<img src="http://mock.com/DIYgod/DIYgod/RSSHub"> - Powered by RSSHub',
|
|
40
40
|
},
|
|
41
41
|
processed: {
|
|
42
42
|
items: [
|
|
@@ -54,7 +54,7 @@ const expects = {
|
|
|
54
54
|
`<a href="https://mock.com/DIYgod/RSSHub"></a>
|
|
55
55
|
<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">`,
|
|
56
56
|
],
|
|
57
|
-
desc: '<img src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"> -
|
|
57
|
+
desc: '<img src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"> - Powered by RSSHub',
|
|
58
58
|
},
|
|
59
59
|
urlencoded: {
|
|
60
60
|
items: [
|
|
@@ -72,7 +72,7 @@ const expects = {
|
|
|
72
72
|
`<a href="https://mock.com/DIYgod/RSSHub"></a>
|
|
73
73
|
<img src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.jpg" referrerpolicy="no-referrer">`,
|
|
74
74
|
],
|
|
75
|
-
desc: '<img src="https://images.weserv.nl?url=http%3A%2F%2Fmock.com%2FDIYgod%2FDIYgod%2FRSSHub"> -
|
|
75
|
+
desc: '<img src="https://images.weserv.nl?url=http%3A%2F%2Fmock.com%2FDIYgod%2FDIYgod%2FRSSHub"> - Powered by RSSHub',
|
|
76
76
|
},
|
|
77
77
|
},
|
|
78
78
|
multimedia: {
|
|
@@ -87,7 +87,7 @@ const expects = {
|
|
|
87
87
|
<audio src="https://mock.com/DIYgod/RSSHub.mp3"></audio>
|
|
88
88
|
<iframe src="https://mock.com/DIYgod/RSSHub.html" referrerpolicy="no-referrer"></iframe>`,
|
|
89
89
|
],
|
|
90
|
-
desc: '<video src="http://mock.com/DIYgod/DIYgod/RSSHub"></video> -
|
|
90
|
+
desc: '<video src="http://mock.com/DIYgod/DIYgod/RSSHub"></video> - Powered by RSSHub',
|
|
91
91
|
},
|
|
92
92
|
relayed: {
|
|
93
93
|
items: [
|
|
@@ -100,7 +100,7 @@ const expects = {
|
|
|
100
100
|
<audio src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp3"></audio>
|
|
101
101
|
<iframe src="https://mock.com/DIYgod/RSSHub.html" referrerpolicy="no-referrer"></iframe>`,
|
|
102
102
|
],
|
|
103
|
-
desc: '<video src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"></video> -
|
|
103
|
+
desc: '<video src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"></video> - Powered by RSSHub',
|
|
104
104
|
},
|
|
105
105
|
partlyRelayed: {
|
|
106
106
|
items: [
|
|
@@ -113,7 +113,7 @@ const expects = {
|
|
|
113
113
|
<audio src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp3"></audio>
|
|
114
114
|
<iframe src="https://mock.com/DIYgod/RSSHub.html" referrerpolicy="no-referrer"></iframe>`,
|
|
115
115
|
],
|
|
116
|
-
desc: '<video src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"></video> -
|
|
116
|
+
desc: '<video src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"></video> - Powered by RSSHub',
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
119
|
};
|
package/lib/middleware/logger.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requestMetric } from '@/utils/otel';
|
|
1
2
|
import { MiddlewareHandler } from 'hono';
|
|
2
3
|
import logger from '@/utils/logger';
|
|
3
4
|
import { getPath, time } from '@/utils/helpers';
|
|
@@ -34,7 +35,10 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
|
34
35
|
|
|
35
36
|
await next();
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
const status = ctx.res.status;
|
|
39
|
+
|
|
40
|
+
logger.info(`${LogPrefix.Outgoing} ${method} ${path} ${colorStatus(status)} ${time(start)}`);
|
|
41
|
+
requestMetric.success(Date.now() - start, { path, method, status });
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
export default middleware;
|
|
@@ -427,7 +427,8 @@ describe('multi parameter', () => {
|
|
|
427
427
|
});
|
|
428
428
|
|
|
429
429
|
describe('openai', () => {
|
|
430
|
-
it(
|
|
430
|
+
it('processes both title and description', async () => {
|
|
431
|
+
config.openai.inputOption = 'both';
|
|
431
432
|
const responseWithGpt = await app.request('/test/gpt?chatgpt=true');
|
|
432
433
|
const responseNormal = await app.request('/test/gpt');
|
|
433
434
|
|
|
@@ -437,9 +438,25 @@ describe('openai', () => {
|
|
|
437
438
|
const parsedGpt = await parser.parseString(await responseWithGpt.text());
|
|
438
439
|
const parsedNormal = await parser.parseString(await responseNormal.text());
|
|
439
440
|
|
|
440
|
-
expect(parsedGpt.items[0].
|
|
441
|
-
expect(parsedGpt.items[0].
|
|
442
|
-
expect(parsedGpt.items[
|
|
443
|
-
expect(parsedGpt.items[
|
|
441
|
+
expect(parsedGpt.items[0].title).not.toBe(parsedNormal.items[0].title);
|
|
442
|
+
expect(parsedGpt.items[0].title).toContain('AI processed content.');
|
|
443
|
+
expect(parsedGpt.items[0].content).not.toBe(parsedNormal.items[0].content);
|
|
444
|
+
expect(parsedGpt.items[0].content).toContain('AI processed content.');
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it('processes title or description', async () => {
|
|
448
|
+
// test title
|
|
449
|
+
config.openai.inputOption = 'title';
|
|
450
|
+
const responseTitleOnly = await app.request('/test/gpt?chatgpt=true');
|
|
451
|
+
const parsedTitleOnly = await parser.parseString(await responseTitleOnly.text());
|
|
452
|
+
expect(parsedTitleOnly.items[0].title).toContain('AI processed content.');
|
|
453
|
+
expect(parsedTitleOnly.items[0].content).not.toContain('AI processed content.');
|
|
454
|
+
|
|
455
|
+
// test description
|
|
456
|
+
config.openai.inputOption = 'description';
|
|
457
|
+
const responseDescriptionOnly = await app.request('/test/gpt?chatgpt=true');
|
|
458
|
+
const parsedDescriptionOnly = await parser.parseString(await responseDescriptionOnly.text());
|
|
459
|
+
expect(parsedDescriptionOnly.items[0].title).not.toContain('AI processed content.');
|
|
460
|
+
expect(parsedDescriptionOnly.items[0].content).toContain('AI processed content.');
|
|
444
461
|
});
|
|
445
462
|
});
|
|
@@ -32,7 +32,7 @@ const resolveRelativeLink = ($: CheerioAPI, elem: Element, attr: string, baseUrl
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const getAiCompletion = async (prompt: string, text: string) => {
|
|
36
36
|
const apiUrl = `${config.openai.endpoint}/chat/completions`;
|
|
37
37
|
const response = await ofetch(apiUrl, {
|
|
38
38
|
method: 'POST',
|
|
@@ -40,8 +40,8 @@ const summarizeArticle = async (articleText: string) => {
|
|
|
40
40
|
model: config.openai.model,
|
|
41
41
|
max_tokens: config.openai.maxTokens,
|
|
42
42
|
messages: [
|
|
43
|
-
{ role: 'system', content:
|
|
44
|
-
{ role: 'user', content:
|
|
43
|
+
{ role: 'system', content: prompt },
|
|
44
|
+
{ role: 'user', content: text },
|
|
45
45
|
],
|
|
46
46
|
temperature: config.openai.temperature,
|
|
47
47
|
},
|
|
@@ -327,23 +327,53 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
|
327
327
|
if (ctx.req.query('chatgpt') && config.openai.apiKey) {
|
|
328
328
|
data.item = await Promise.all(
|
|
329
329
|
data.item.map(async (item) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const summary_md = await summarizeArticle(text);
|
|
338
|
-
return md.render(summary_md);
|
|
330
|
+
try {
|
|
331
|
+
// handle description
|
|
332
|
+
if (config.openai.inputOption === 'description' && item.description) {
|
|
333
|
+
const description = await cache.tryGet(`openai:description:${item.link}`, async () => {
|
|
334
|
+
const description = convert(item.description!);
|
|
335
|
+
const descriptionMd = await getAiCompletion(config.openai.promptDescription, description);
|
|
336
|
+
return md.render(descriptionMd);
|
|
339
337
|
});
|
|
340
|
-
//
|
|
341
|
-
if (
|
|
342
|
-
item.description =
|
|
338
|
+
// add it to the description
|
|
339
|
+
if (description !== '') {
|
|
340
|
+
item.description = description + '<hr/><br/>' + item.description;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// handle title
|
|
344
|
+
else if (config.openai.inputOption === 'title' && item.title) {
|
|
345
|
+
const title = await cache.tryGet(`openai:title:${item.link}`, async () => {
|
|
346
|
+
const title = convert(item.title!);
|
|
347
|
+
return await getAiCompletion(config.openai.promptTitle, title);
|
|
348
|
+
});
|
|
349
|
+
// replace the title
|
|
350
|
+
if (title !== '') {
|
|
351
|
+
item.title = title + '';
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// handle both
|
|
355
|
+
else if (config.openai.inputOption === 'both' && item.title && item.description) {
|
|
356
|
+
const title = await cache.tryGet(`openai:title:${item.link}`, async () => {
|
|
357
|
+
const title = convert(item.title!);
|
|
358
|
+
return await getAiCompletion(config.openai.promptTitle, title);
|
|
359
|
+
});
|
|
360
|
+
// replace the title
|
|
361
|
+
if (title !== '') {
|
|
362
|
+
item.title = title + '';
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const description = await cache.tryGet(`openai:description:${item.link}`, async () => {
|
|
366
|
+
const description = convert(item.description!);
|
|
367
|
+
const descriptionMd = await getAiCompletion(config.openai.promptDescription, description);
|
|
368
|
+
return md.render(descriptionMd);
|
|
369
|
+
});
|
|
370
|
+
// add it to the description
|
|
371
|
+
if (description !== '') {
|
|
372
|
+
item.description = description + '<hr/><br/>' + item.description;
|
|
343
373
|
}
|
|
344
|
-
} catch {
|
|
345
|
-
// when openai failed, return default description and not write cache
|
|
346
374
|
}
|
|
375
|
+
} catch {
|
|
376
|
+
// when openai failed, return default content and not write cache
|
|
347
377
|
}
|
|
348
378
|
return item;
|
|
349
379
|
})
|
|
@@ -94,18 +94,22 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
|
94
94
|
return ctx.json(result);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
if (outputType === 'ums' || outputType === 'rss3') {
|
|
99
|
-
return ctx.json(rss3(result));
|
|
100
|
-
} else if (outputType === 'json') {
|
|
101
|
-
ctx.header('Content-Type', 'application/feed+json; charset=UTF-8');
|
|
102
|
-
return ctx.body(json(result));
|
|
103
|
-
} else if (ctx.get('no-content')) {
|
|
97
|
+
if (ctx.get('no-content')) {
|
|
104
98
|
return ctx.body(null);
|
|
105
|
-
} else if (outputType === 'atom') {
|
|
106
|
-
return ctx.render(<Atom data={result} />);
|
|
107
99
|
} else {
|
|
108
|
-
|
|
100
|
+
// retain .ums for backward compatibility
|
|
101
|
+
switch (outputType) {
|
|
102
|
+
case 'ums':
|
|
103
|
+
case 'rss3':
|
|
104
|
+
return ctx.json(rss3(result));
|
|
105
|
+
case 'json':
|
|
106
|
+
ctx.header('Content-Type', 'application/feed+json; charset=UTF-8');
|
|
107
|
+
return ctx.body(json(result));
|
|
108
|
+
case 'atom':
|
|
109
|
+
return ctx.render(<Atom data={result} />);
|
|
110
|
+
default:
|
|
111
|
+
return ctx.render(<RSS data={result} />);
|
|
112
|
+
}
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MiddlewareHandler } from 'hono';
|
|
2
|
+
import { getPath } from '@/utils/helpers';
|
|
3
|
+
import { config } from '@/config';
|
|
4
|
+
import { tracer } from '@/utils/otel';
|
|
5
|
+
|
|
6
|
+
const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
7
|
+
if (config.debugInfo) {
|
|
8
|
+
// Only enable tracing in debug mode
|
|
9
|
+
const { method, raw } = ctx.req;
|
|
10
|
+
const path = getPath(raw);
|
|
11
|
+
|
|
12
|
+
const span = tracer.startSpan(`${method} ${path}`, {
|
|
13
|
+
kind: 1, // server
|
|
14
|
+
attributes: {},
|
|
15
|
+
});
|
|
16
|
+
span.addEvent('invoking handleRequest');
|
|
17
|
+
await next();
|
|
18
|
+
span.end();
|
|
19
|
+
} else {
|
|
20
|
+
// Skip
|
|
21
|
+
await next();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default middleware;
|
package/lib/registry.test.ts
CHANGED
|
@@ -29,4 +29,12 @@ describe('registry', () => {
|
|
|
29
29
|
const response = await app.request('/favicon.ico');
|
|
30
30
|
expect(response.status).toBe(200);
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
// healthz
|
|
34
|
+
it('/healthz', async () => {
|
|
35
|
+
const response = await app.request('/healthz');
|
|
36
|
+
expect(response.status).toBe(200);
|
|
37
|
+
expect(response.headers.get('cache-control')).toBe('no-cache');
|
|
38
|
+
expect(await response.text()).toBe('ok');
|
|
39
|
+
});
|
|
32
40
|
});
|
package/lib/registry.ts
CHANGED
|
@@ -4,9 +4,12 @@ import { Hono, type Handler } from 'hono';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
7
|
+
import { config } from '@/config';
|
|
7
8
|
|
|
8
9
|
import index from '@/routes/index';
|
|
10
|
+
import healthz from '@/routes/healthz';
|
|
9
11
|
import robotstxt from '@/routes/robots.txt';
|
|
12
|
+
import metrics from '@/routes/metrics';
|
|
10
13
|
|
|
11
14
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
15
|
|
|
@@ -98,7 +101,12 @@ for (const namespace in namespaces) {
|
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
app.get('/', index);
|
|
104
|
+
app.get('/healthz', healthz);
|
|
101
105
|
app.get('/robots.txt', robotstxt);
|
|
106
|
+
if (config.debugInfo) {
|
|
107
|
+
// Only enable tracing in debug mode
|
|
108
|
+
app.get('/metrics', metrics);
|
|
109
|
+
}
|
|
102
110
|
app.use(
|
|
103
111
|
'/*',
|
|
104
112
|
serveStatic({
|
package/lib/router.js
CHANGED
|
@@ -66,9 +66,6 @@ router.get('/konachan.net/post/popular_recent/:period', lazyloadRouteHandler('./
|
|
|
66
66
|
// EZTV
|
|
67
67
|
router.get('/eztv/torrents/:imdb_id', lazyloadRouteHandler('./routes/eztv/imdb'));
|
|
68
68
|
|
|
69
|
-
// 新京报
|
|
70
|
-
router.get('/bjnews/:cat', lazyloadRouteHandler('./routes/bjnews/news'));
|
|
71
|
-
|
|
72
69
|
// 米哈游
|
|
73
70
|
router.get('/mihoyo/bh3/:type', lazyloadRouteHandler('./routes/mihoyo/bh3'));
|
|
74
71
|
router.get('/mihoyo/bh2/:type', lazyloadRouteHandler('./routes/mihoyo/bh2'));
|
|
@@ -10,49 +10,53 @@ import { art } from '@/utils/render';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
12
|
export const route: Route = {
|
|
13
|
-
path: '
|
|
13
|
+
path: '/:type/:keyword{.*}?',
|
|
14
14
|
categories: ['multimedia'],
|
|
15
15
|
name: '通用',
|
|
16
16
|
maintainers: ['cgkings', 'nczitzk'],
|
|
17
|
+
parameters: { type: '类型,可查看下表的类型说明', keyword: '关键词,可查看下表的关键词说明' },
|
|
18
|
+
handler,
|
|
17
19
|
description: `**类型**
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
| 最新 | 热门 | 随机 | 指定演员 | 指定标签 | 日期 |
|
|
22
|
+
| ---- | ------- | ------ | -------- | -------- | ---- |
|
|
23
|
+
| new | popular | random | actress | tag | date |
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
**关键词**
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
| 空 | 日期范围 | 演员名 | 标签名 | 年月日 |
|
|
28
|
+
| -- | ----------- | ------------ | -------------- | ---------- |
|
|
29
|
+
| | 7 / 30 / 60 | Yua%20Mikami | Adult%20Awards | 2020/07/30 |
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
**示例说明**
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
- \`/141jav/new\`
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
仅当类型为 \`new\` \`popular\` 或 \`random\` 时关键词为 **空**
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
- \`/141jav/popular/30\`
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
\`popular\` \`random\` 类型的关键词可填写 \`7\` \`30\` 或 \`60\` 三个 **日期范围** 之一,分别对应 **7 天**、**30 天** 或 **60 天内**
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
- \`/141jav/actress/Yua%20Mikami\`
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
\`actress\` 类型的关键词必须填写 **演员名** ,可在 [此处](https://141jav.com/actress/) 演员单页链接中获取
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
- \`/141jav/tag/Adult%20Awards\`
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
\`tag\` 类型的关键词必须填写 **标签名** 且标签中的 \`/\` 必须替换为 \`%2F\` ,可在 [此处](https://141jav.com/tag/) 标签单页链接中获取
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
- \`/141jav/date/2020/07/30\`
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
handler,
|
|
51
|
+
\`date\` 类型的关键词必须填写 **日期(年/月/日)**`,
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
async function handler(ctx) {
|
|
54
55
|
const rootUrl = 'https://www.141jav.com';
|
|
55
|
-
const
|
|
56
|
+
const type = ctx.req.param('type');
|
|
57
|
+
const keyword = ctx.req.param('keyword') ?? '';
|
|
58
|
+
|
|
59
|
+
const currentUrl = `${rootUrl}/${type}${keyword ? `/${keyword}` : ''}`;
|
|
56
60
|
|
|
57
61
|
const response = await got({
|
|
58
62
|
method: 'get',
|