diff --git a/lib/routes/mckinsey/cn/index.ts b/lib/routes/mckinsey/cn/index.ts index 95f4ae76408340..2ca56154073dc4 100644 --- a/lib/routes/mckinsey/cn/index.ts +++ b/lib/routes/mckinsey/cn/index.ts @@ -1,8 +1,5 @@ import { Route } from '@/types'; -// use stock `got` package as a workaround for -// https://github.com/DIYgod/RSSHub/issues/8239 -// https://github.com/DIYgod/RSSHub/pull/8288 -import got from 'got'; +import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; import { categories } from './category-map'; @@ -53,12 +50,12 @@ async function handler(ctx) { categories.find((c) => c.slug === category); } - const posts = await got(`${endpoint}/wp/v2/posts`, { - searchParams: { + const posts = await ofetch(`${endpoint}/wp/v2/posts`, { + query: { per_page: ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 50, categories: category, }, - }).json(); + }); const items = posts.map((item) => ({ title: item.title.rendered, diff --git a/package.json b/package.json index ec46fe7f01186a..44112cad17eb31 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "tiny-async-pool": "2.1.0", "title": "3.5.3", "tldts": "6.1.18", + "tosource": "2.0.0-alpha.3", "tough-cookie": "4.1.3", "tsx": "4.7.2", "twitter-api-v2": "1.16.3", @@ -173,7 +174,6 @@ "prettier": "3.2.5", "remark-parse": "11.0.0", "supertest": "7.0.0", - "tosource": "2.0.0-alpha.3", "typescript": "5.4.5", "unified": "11.0.4", "vite-tsconfig-paths": "4.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8079c8b150be40..46b1fb97dec75d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -197,6 +197,9 @@ dependencies: tldts: specifier: 6.1.18 version: 6.1.18 + tosource: + specifier: 2.0.0-alpha.3 + version: 2.0.0-alpha.3 tough-cookie: specifier: 4.1.3 version: 4.1.3 @@ -370,9 +373,6 @@ devDependencies: supertest: specifier: 7.0.0 version: 7.0.0 - tosource: - specifier: 2.0.0-alpha.3 - version: 2.0.0-alpha.3 typescript: specifier: 5.4.5 version: 5.4.5 @@ -3005,8 +3005,8 @@ packages: resolution: {integrity: sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==} dev: true - /@types/superagent@8.1.3: - resolution: {integrity: sha512-R/CfN6w2XsixLb1Ii8INfn+BT9sGPvw74OavfkW4SwY+jeUcAwLZv2+bXLJkndnimxjEBm0RPHgcjW9pLCa8cw==} + /@types/superagent@8.1.6: + resolution: {integrity: sha512-yzBOv+6meEHSzV2NThYYOA6RtqvPr3Hbob9ZLp3i07SH27CrYVfm8CrF7ydTmidtelsFiKx2I4gZAiAOamGgvQ==} dependencies: '@types/cookiejar': 2.1.5 '@types/methods': 1.1.4 @@ -3017,7 +3017,7 @@ packages: resolution: {integrity: sha512-137ypx2lk/wTQbW6An6safu9hXmajAifU/s7szAHLN/FeIm5w7yR0Wkl9fdJMRSHwOn4HLAI0DaB2TOORuhPDg==} dependencies: '@types/methods': 1.1.4 - '@types/superagent': 8.1.3 + '@types/superagent': 8.1.6 dev: true /@types/tiny-async-pool@2.0.3: @@ -7822,7 +7822,7 @@ packages: dependencies: nanoid: 3.3.7 picocolors: 1.0.0 - source-map-js: 1.2.0 + source-map-js: 1.0.2 dev: false /postcss@8.4.38: @@ -8679,9 +8679,15 @@ packages: atomic-sleep: 1.0.0 dev: false + /source-map-js@1.0.2: + resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} + engines: {node: '>=0.10.0'} + dev: false + /source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} + dev: true /source-map@0.5.7: resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} @@ -9150,7 +9156,7 @@ packages: /tosource@2.0.0-alpha.3: resolution: {integrity: sha512-KAB2lrSS48y91MzFPFuDg4hLbvDiyTjOVgaK7Erw+5AmZXNq4sFRVn8r6yxSLuNs15PaokrDRpS61ERY9uZOug==} engines: {node: '>=10'} - dev: true + dev: false /tough-cookie@2.5.0: resolution: {integrity: sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==}