From 300d450fe076133fe1e76e769ed136e128524cb5 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 29 Feb 2024 18:07:33 +0800 Subject: [PATCH] feat: v3 migration - 15/n --- lib/v2/18comic/album.js | 2 +- lib/v2/18comic/blogs.js | 2 +- lib/v2/18comic/index.js | 2 +- lib/v2/18comic/search.js | 2 +- lib/v2/91porn/author.js | 2 +- lib/v2/91porn/index.js | 2 +- lib/v2/caixin/blog.js | 2 +- lib/v2/cast/index.js | 2 +- lib/v2/chsi/kyzx.js | 2 +- lib/v2/domp4/detail.js | 2 +- lib/v2/domp4/latest.js | 2 +- lib/v2/dxy/profile/thread.js | 2 +- lib/v2/dxy/special.js | 2 +- lib/v2/followin/index.js | 2 +- lib/v2/followin/kol.js | 2 +- lib/v2/followin/news.js | 2 +- lib/v2/followin/tag.js | 2 +- lib/v2/followin/topic.js | 2 +- lib/v2/hoyolab/news.js | 2 +- lib/v2/linkedin/cn/utils.js | 2 +- lib/v2/mail/imap.js | 2 +- lib/v2/notefolio/search.js | 2 +- lib/v2/nowcoder/experience.js | 2 +- lib/v2/npm/package.js | 2 +- lib/v2/pixiv/novels.js | 2 +- lib/v2/sina/chuangshiji.js | 2 +- lib/v2/sina/discovery.js | 2 +- lib/v2/sina/finance/china.js | 2 +- lib/v2/sina/finance/stock/usstock.js | 2 +- lib/v2/sina/rollnews.js | 2 +- lib/v2/taptap/changelog.js | 2 +- lib/v2/taptap/review.js | 2 +- lib/v2/telegram/tglib/channel.js | 2 +- lib/v2/tfc-taiwan/index.js | 2 +- lib/v2/weibo/timeline.js | 8 ++++---- 35 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/v2/18comic/album.js b/lib/v2/18comic/album.js index 93b20305f..46c178bf9 100644 --- a/lib/v2/18comic/album.js +++ b/lib/v2/18comic/album.js @@ -7,7 +7,7 @@ const { defaultDomain, getRootUrl } = require('./utils'); module.exports = async (ctx) => { const id = ctx.req.param('id'); - const { domain = defaultDomain } = ctx.query; + const { domain = defaultDomain } = ctx.req.query(); const rootUrl = getRootUrl(domain); const currentUrl = `${rootUrl}/album/${id}`; diff --git a/lib/v2/18comic/blogs.js b/lib/v2/18comic/blogs.js index 82d492a3b..ef1485e4e 100644 --- a/lib/v2/18comic/blogs.js +++ b/lib/v2/18comic/blogs.js @@ -7,7 +7,7 @@ const { defaultDomain, getRootUrl } = require('./utils'); module.exports = async (ctx) => { const category = ctx.req.param('category') ?? ''; - const { domain = defaultDomain } = ctx.query; + const { domain = defaultDomain } = ctx.req.query(); const rootUrl = getRootUrl(domain); const currentUrl = `${rootUrl}/blogs${category ? `/${category}` : ''}`; diff --git a/lib/v2/18comic/index.js b/lib/v2/18comic/index.js index 46e498a30..a05db6c5b 100644 --- a/lib/v2/18comic/index.js +++ b/lib/v2/18comic/index.js @@ -5,7 +5,7 @@ module.exports = async (ctx) => { const keyword = ctx.req.param('keyword') ?? ''; const time = ctx.req.param('time') ?? 'a'; const order = ctx.req.param('order') ?? 'mr'; - const { domain = defaultDomain } = ctx.query; + const { domain = defaultDomain } = ctx.req.query(); const rootUrl = getRootUrl(domain); const currentUrl = `${rootUrl}/albums${category === 'all' ? '' : `/${category}`}${keyword ? `?screen=${keyword}` : '?'}${time === 'a' ? '' : `&t=${time}`}${order === 'mr' ? '' : `&o=${order}`}`; diff --git a/lib/v2/18comic/search.js b/lib/v2/18comic/search.js index 5e8552572..2c01ed9df 100644 --- a/lib/v2/18comic/search.js +++ b/lib/v2/18comic/search.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const keyword = ctx.req.param('keyword') ?? ''; const time = ctx.req.param('time') ?? 'a'; const order = ctx.req.param('order') ?? 'mr'; - const { domain = defaultDomain } = ctx.query; + const { domain = defaultDomain } = ctx.req.query(); const rootUrl = getRootUrl(domain); const currentUrl = `${rootUrl}/search/${option}${category === 'all' ? '' : `/${category}`}${keyword ? `?search_query=${keyword}` : '?'}${time === 'a' ? '' : `&t=${time}`}${order === 'mr' ? '' : `&o=${order}`}`; diff --git a/lib/v2/91porn/author.js b/lib/v2/91porn/author.js index a799a3218..242946bbc 100644 --- a/lib/v2/91porn/author.js +++ b/lib/v2/91porn/author.js @@ -7,7 +7,7 @@ import * as path from 'node:path'; const { domainValidation } = require('./utils'); module.exports = async (ctx) => { - const { domain = '91porn.com' } = ctx.query; + const { domain = '91porn.com' } = ctx.req.query(); const { uid, lang = 'en_US' } = ctx.req.param(); const siteUrl = `https://${domain}/uvideos.php?UID=${uid}&type=public`; domainValidation(domain); diff --git a/lib/v2/91porn/index.js b/lib/v2/91porn/index.js index 472c9f77c..89acec5aa 100644 --- a/lib/v2/91porn/index.js +++ b/lib/v2/91porn/index.js @@ -7,7 +7,7 @@ import * as path from 'node:path'; const { domainValidation } = require('./utils'); module.exports = async (ctx) => { - const { domain = '91porn.com' } = ctx.query; + const { domain = '91porn.com' } = ctx.req.query(); const siteUrl = `https://${domain}/index.php`; const { lang = 'en_US' } = ctx.req.param(); domainValidation(domain); diff --git a/lib/v2/caixin/blog.js b/lib/v2/caixin/blog.js index d951708d6..55b34fb82 100644 --- a/lib/v2/caixin/blog.js +++ b/lib/v2/caixin/blog.js @@ -7,7 +7,7 @@ const { parseBlogArticle } = require('./utils'); module.exports = async (ctx) => { const column = ctx.req.param('column'); - const { limit = 20 } = ctx.query; + const { limit = 20 } = ctx.req.query(); if (column) { if (!isValidHost(column)) { throw new Error('Invalid column'); diff --git a/lib/v2/cast/index.js b/lib/v2/cast/index.js index 013a4bfd2..d8e9b4d86 100644 --- a/lib/v2/cast/index.js +++ b/lib/v2/cast/index.js @@ -7,7 +7,7 @@ const baseUrl = 'https://www.cast.org.cn'; module.exports = async (ctx) => { const { column = 457 } = ctx.req.param(); - const { limit = 10 } = ctx.query; + const { limit = 10 } = ctx.req.query(); const link = `${baseUrl}/col/col${column}/index.html`; const { data: response } = await got.post(`${baseUrl}/module/web/jpage/dataproxy.jsp`, { searchParams: { diff --git a/lib/v2/chsi/kyzx.js b/lib/v2/chsi/kyzx.js index 60b03d91f..45bd73aa2 100644 --- a/lib/v2/chsi/kyzx.js +++ b/lib/v2/chsi/kyzx.js @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; const host = 'https://yz.chsi.com.cn'; module.exports = async (ctx) => { - const { type } = ctx.request.params; + const { type } = ctx.req.param(); const response = await got(`${host}/kyzx/${type}`); const $ = load(response.data); const typeName = $('.bread-nav .location a').last().text() || '考研资讯'; diff --git a/lib/v2/domp4/detail.js b/lib/v2/domp4/detail.js index 93199493a..bf9135e99 100644 --- a/lib/v2/domp4/detail.js +++ b/lib/v2/domp4/detail.js @@ -71,7 +71,7 @@ function getMetaInfo($) { module.exports = async (ctx) => { const id = ctx.req.param('id'); - const { domain, second } = ctx.query; + const { domain, second } = ctx.req.query(); let pureId = id; let detailType = 'html'; // compatible for .html suffix in radar diff --git a/lib/v2/domp4/latest.js b/lib/v2/domp4/latest.js index bc9feb744..6bfaaeddd 100644 --- a/lib/v2/domp4/latest.js +++ b/lib/v2/domp4/latest.js @@ -18,7 +18,7 @@ function getItemList($, type) { module.exports = async (ctx) => { const { type = 'vod' } = ctx.req.param(); - const { domain } = ctx.query; + const { domain } = ctx.req.query(); const hostUrl = ensureDomain(ctx, domain); const latestUrl = `${hostUrl}/custom/update.html`; diff --git a/lib/v2/dxy/profile/thread.js b/lib/v2/dxy/profile/thread.js index f3863f36b..e1b3e1242 100644 --- a/lib/v2/dxy/profile/thread.js +++ b/lib/v2/dxy/profile/thread.js @@ -6,7 +6,7 @@ import { config } from '@/config'; module.exports = async (ctx) => { const userId = ctx.req.param('userId'); - const { limit = '30' } = ctx.query; + const { limit = '30' } = ctx.req.query(); const userInfo = await cache.tryGet(`dxy:user-info:${userId}`, async () => { const userInfoParams = { diff --git a/lib/v2/dxy/special.js b/lib/v2/dxy/special.js index 5ce645f0b..c05d27fa4 100644 --- a/lib/v2/dxy/special.js +++ b/lib/v2/dxy/special.js @@ -6,7 +6,7 @@ import { config } from '@/config'; module.exports = async (ctx) => { const specialId = ctx.req.param('specialId'); - const { limit = '10' } = ctx.query; + const { limit = '10' } = ctx.req.query(); const specialDetail = await cache.tryGet(`dxy:special:detail:${specialId}`, async () => { const detailParams = { diff --git a/lib/v2/followin/index.js b/lib/v2/followin/index.js index b2de4b58a..f202935cf 100644 --- a/lib/v2/followin/index.js +++ b/lib/v2/followin/index.js @@ -4,7 +4,7 @@ const { apiUrl, favicon, getBParam, getBuildId, getGToken, parseList, parseItem module.exports = async (ctx) => { const { categoryId = '1', lang = 'en' } = ctx.req.param(); - const { limit = 20 } = ctx.query; + const { limit = 20 } = ctx.req.query(); const gToken = await getGToken(cache.tryGet); const bParam = getBParam(lang); diff --git a/lib/v2/followin/kol.js b/lib/v2/followin/kol.js index 158af4ead..ee85269ef 100644 --- a/lib/v2/followin/kol.js +++ b/lib/v2/followin/kol.js @@ -4,7 +4,7 @@ const { baseUrl, getBuildId, parseList, parseItem } = require('./utils'); module.exports = async (ctx) => { const { kolId, lang = 'en' } = ctx.req.param(); - const { limit = 10 } = ctx.query; + const { limit = 10 } = ctx.req.query(); const buildId = await getBuildId(cache.tryGet); const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/${lang}/kol/${kolId}.json`); diff --git a/lib/v2/followin/news.js b/lib/v2/followin/news.js index 926645e95..000f18686 100644 --- a/lib/v2/followin/news.js +++ b/lib/v2/followin/news.js @@ -4,7 +4,7 @@ const { baseUrl, favicon, getBuildId, parseList, parseItem } = require('./utils' module.exports = async (ctx) => { const { lang = 'en' } = ctx.req.param(); - const { limit = 20 } = ctx.query; + const { limit = 20 } = ctx.req.query(); const buildId = await getBuildId(cache.tryGet); const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/${lang}/news.json`); diff --git a/lib/v2/followin/tag.js b/lib/v2/followin/tag.js index 2653100dd..5eb5ddde1 100644 --- a/lib/v2/followin/tag.js +++ b/lib/v2/followin/tag.js @@ -4,7 +4,7 @@ const { apiUrl, baseUrl, getBParam, getBuildId, getGToken, parseList, parseItem module.exports = async (ctx) => { const { tagId, lang = 'en' } = ctx.req.param(); - const { limit = 20 } = ctx.query; + const { limit = 20 } = ctx.req.query(); const buildId = await getBuildId(cache.tryGet); const tagInfo = await cache.tryGet(`followin:tag:${tagId}:${lang}`, async () => { diff --git a/lib/v2/followin/topic.js b/lib/v2/followin/topic.js index 3c09c1292..12567547c 100644 --- a/lib/v2/followin/topic.js +++ b/lib/v2/followin/topic.js @@ -4,7 +4,7 @@ const { baseUrl, getBuildId, parseList, parseItem } = require('./utils'); module.exports = async (ctx) => { const { topicId, lang = 'en' } = ctx.req.param(); - const { limit = 20 } = ctx.query; + const { limit = 20 } = ctx.req.query(); const buildId = await getBuildId(cache.tryGet); const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/${lang}/topic/${topicId}.json`); diff --git a/lib/v2/hoyolab/news.js b/lib/v2/hoyolab/news.js index dcea080f9..41934c19a 100644 --- a/lib/v2/hoyolab/news.js +++ b/lib/v2/hoyolab/news.js @@ -77,7 +77,7 @@ module.exports = async (ctx) => { type, gids, language, - size: Number.parseInt(ctx.query?.limit) || 15, + size: Number.parseInt(ctx.req.query('limit')) || 15, }; const gameInfo = await getI18nGameInfo(gids, language, cache.tryGet); const typeInfo = await getI18nType(language, cache.tryGet); diff --git a/lib/v2/linkedin/cn/utils.js b/lib/v2/linkedin/cn/utils.js index 5e3a93144..006483233 100644 --- a/lib/v2/linkedin/cn/utils.js +++ b/lib/v2/linkedin/cn/utils.js @@ -56,7 +56,7 @@ const makeBody = (body) => { const ctxToTitle = (ctx) => { const keywords = ctx.req.param('keywords'); - const { geo, remote, location, period, relevant } = ctx.query; + const { geo, remote, location, period, relevant } = ctx.req.query(); const g = location || geo || 'China'; const r = remote ? '远程' : ''; const p = period ? `近${period}天` : ''; diff --git a/lib/v2/mail/imap.js b/lib/v2/mail/imap.js index 8ed84381a..d9d2afe28 100644 --- a/lib/v2/mail/imap.js +++ b/lib/v2/mail/imap.js @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; module.exports = async (ctx) => { const { email, folder = 'INBOX' } = ctx.req.param(); - const { limit = 10 } = ctx.query; + const { limit = 10 } = ctx.req.query(); const mailConfig = { username: email, port: 993, diff --git a/lib/v2/notefolio/search.js b/lib/v2/notefolio/search.js index d241650a0..e1b9a5f32 100644 --- a/lib/v2/notefolio/search.js +++ b/lib/v2/notefolio/search.js @@ -68,7 +68,7 @@ module.exports = async (ctx) => { // 分类、排序、时间范围、搜索词 const { category = 'all', order = 'pick', time = 'all', query = '' } = ctx.req.param(); // 分页 - const { limit } = ctx.query; + const { limit } = ctx.req.query(); // 请求链接 let searchUrl = `https://api.stunning.kr/api/v1/dantats/portfolio?state=Public&limit=${limit ? Number.parseInt(limit, 10) : 20}&search=${query}&orderBy=${order}`; diff --git a/lib/v2/nowcoder/experience.js b/lib/v2/nowcoder/experience.js index 796d661c4..7619e6104 100644 --- a/lib/v2/nowcoder/experience.js +++ b/lib/v2/nowcoder/experience.js @@ -7,7 +7,7 @@ import timezone from '@/utils/timezone'; const host = 'https://www.nowcoder.com'; module.exports = async (ctx) => { - const params = new URLSearchParams(ctx.query); + const params = new URLSearchParams(ctx.req.query()); params.append('tagId', ctx.req.param('tagId')); const link = new URL('/discuss/experience/json', host); diff --git a/lib/v2/npm/package.js b/lib/v2/npm/package.js index d99078efa..c721ff453 100644 --- a/lib/v2/npm/package.js +++ b/lib/v2/npm/package.js @@ -3,7 +3,7 @@ import { art } from '@/utils/render'; import * as path from 'node:path'; module.exports = async (ctx) => { - const name = ctx.request.url.split('package/')[1]; + const name = ctx.req.url.split('package/')[1]; const packageDownloadLastMonthAPI = `https://api.npmjs.org/downloads/point/last-month/${name}`; // 按月统计 const packageDownloadLastWeekAPI = `https://api.npmjs.org/downloads/point/last-week/${name}`; // 按周统计 const packageDownloadLastDayAPI = `https://api.npmjs.org/downloads/point/last-day/${name}`; // 按天统计 diff --git a/lib/v2/pixiv/novels.js b/lib/v2/pixiv/novels.js index d5d46462a..ef24d57c8 100644 --- a/lib/v2/pixiv/novels.js +++ b/lib/v2/pixiv/novels.js @@ -4,7 +4,7 @@ const baseUrl = 'https://www.pixiv.net'; module.exports = async (ctx) => { const id = ctx.req.param('id'); - const { limit = 100 } = ctx.query; + const { limit = 100 } = ctx.req.query(); const url = `${baseUrl}/users/${id}/novels`; const { data: allData } = await got(`${baseUrl}/ajax/user/${id}/profile/all`, { headers: { diff --git a/lib/v2/sina/chuangshiji.js b/lib/v2/sina/chuangshiji.js index b57b6dcb4..ca5b90d14 100644 --- a/lib/v2/sina/chuangshiji.js +++ b/lib/v2/sina/chuangshiji.js @@ -4,7 +4,7 @@ const { getRollNewsList, parseRollNewsList, parseArticle } = require('./utils'); module.exports = async (ctx) => { const pageid = '402'; const lid = '2559'; - const { limit = '50' } = ctx.query; + const { limit = '50' } = ctx.req.query(); const response = await getRollNewsList(pageid, lid, limit); const list = parseRollNewsList(response.data.result.data); diff --git a/lib/v2/sina/discovery.js b/lib/v2/sina/discovery.js index 2217b5a78..b94e53063 100644 --- a/lib/v2/sina/discovery.js +++ b/lib/v2/sina/discovery.js @@ -18,7 +18,7 @@ module.exports = async (ctx) => { const lid = map.get(type).id; const title = map.get(type).title; const pageid = '207'; - const { limit = '50' } = ctx.query; + const { limit = '50' } = ctx.req.query(); const response = await getRollNewsList(pageid, lid, limit); const list = parseRollNewsList(response.data.result.data); diff --git a/lib/v2/sina/finance/china.js b/lib/v2/sina/finance/china.js index a9a64c8b8..1559d1fd4 100644 --- a/lib/v2/sina/finance/china.js +++ b/lib/v2/sina/finance/china.js @@ -12,7 +12,7 @@ module.exports = async (ctx) => { }; const pageid = '155'; const { lid = '1686' } = ctx.req.param(); - const { limit = '50' } = ctx.query; + const { limit = '50' } = ctx.req.query(); const response = await getRollNewsList(pageid, lid, limit); const list = parseRollNewsList(response.data.result.data); diff --git a/lib/v2/sina/finance/stock/usstock.js b/lib/v2/sina/finance/stock/usstock.js index d680322f8..e54d1b0b8 100644 --- a/lib/v2/sina/finance/stock/usstock.js +++ b/lib/v2/sina/finance/stock/usstock.js @@ -5,7 +5,7 @@ const { parseArticle } = require('../../utils'); module.exports = async (ctx) => { const { cids = '57045' } = ctx.req.param(); - const { limit = '50' } = ctx.query; + const { limit = '50' } = ctx.req.query(); const { data: response } = await got('https://interface.sina.cn/pc_api/public_news_data.d.json', { searchParams: { cids, diff --git a/lib/v2/sina/rollnews.js b/lib/v2/sina/rollnews.js index 69d155b74..eb2fd7b10 100644 --- a/lib/v2/sina/rollnews.js +++ b/lib/v2/sina/rollnews.js @@ -18,7 +18,7 @@ module.exports = async (ctx) => { const pageid = '153'; const { lid = '2509' } = ctx.req.param(); - const { limit = '50' } = ctx.query; + const { limit = '50' } = ctx.req.query(); const response = await getRollNewsList(pageid, lid, limit); const list = parseRollNewsList(response.data.result.data); diff --git a/lib/v2/taptap/changelog.js b/lib/v2/taptap/changelog.js index 38d321325..b54c758da 100644 --- a/lib/v2/taptap/changelog.js +++ b/lib/v2/taptap/changelog.js @@ -3,7 +3,7 @@ import { parseDate } from '@/utils/parse-date'; const { getRootUrl, appDetail, X_UA } = require('./utils'); module.exports = async (ctx) => { - const is_intl = ctx.request.url.indexOf('/intl/') === 0; + const is_intl = ctx.req.url.indexOf('/intl/') === 0; const id = ctx.req.param('id'); const lang = ctx.req.param('lang') ?? (is_intl ? 'en_US' : 'zh_CN'); diff --git a/lib/v2/taptap/review.js b/lib/v2/taptap/review.js index 3ab8ce533..037cbd3c2 100644 --- a/lib/v2/taptap/review.js +++ b/lib/v2/taptap/review.js @@ -104,7 +104,7 @@ const fetchIntlItems = async (params) => { }; module.exports = async (ctx) => { - const is_intl = ctx.request.url.indexOf('/intl/') === 0; + const is_intl = ctx.req.url.indexOf('/intl/') === 0; const id = ctx.req.param('id'); const order = ctx.req.param('order') ?? 'default'; const lang = ctx.req.param('lang') ?? (is_intl ? 'en_US' : 'zh_CN'); diff --git a/lib/v2/telegram/tglib/channel.js b/lib/v2/telegram/tglib/channel.js index 9a634eab7..066a82a2c 100644 --- a/lib/v2/telegram/tglib/channel.js +++ b/lib/v2/telegram/tglib/channel.js @@ -49,7 +49,7 @@ async function getMedia(ctx) { if (media.document) { ctx.status = 200; let stream; - if ('thumb' in ctx.query) { + if ('thumb' in ctx.req.query()) { try { stream = streamThumbnail(media); ctx.set('Content-Type', 'image/jpeg'); diff --git a/lib/v2/tfc-taiwan/index.js b/lib/v2/tfc-taiwan/index.js index dce45d6bd..c89c579a9 100644 --- a/lib/v2/tfc-taiwan/index.js +++ b/lib/v2/tfc-taiwan/index.js @@ -4,7 +4,7 @@ import { load } from 'cheerio'; const { baseUrl, parseList, parseItems } = require('./utils'); module.exports = async (ctx) => { - const requestPath = ctx.request.path; + const requestPath = ctx.req.path; const isTopic = requestPath.startsWith('/topic/'); let link = baseUrl; diff --git a/lib/v2/weibo/timeline.js b/lib/v2/weibo/timeline.js index 864f4cf2b..23ff67ba5 100644 --- a/lib/v2/weibo/timeline.js +++ b/lib/v2/weibo/timeline.js @@ -56,7 +56,7 @@ module.exports = async (ctx) => { ); // 检查token失效 if (response.error !== undefined) { - const { app_key = '', redirect_url = ctx.request.origin + '/weibo/timeline/0' } = config.weibo; + const { app_key = '', redirect_url = ctx.req.origin + '/weibo/timeline/0' } = config.weibo; ctx.status = 302; ctx.set({ @@ -128,8 +128,8 @@ module.exports = async (ctx) => { item: resultItem, }) ); - } else if (uid === '0' || ctx.querystring) { - const { app_key = '', redirect_url = ctx.request.origin + '/weibo/timeline/0', app_secret = '' } = config.weibo; + } else if (uid === '0' || ctx.req.query()) { + const { app_key = '', redirect_url = ctx.req.origin + '/weibo/timeline/0', app_secret = '' } = config.weibo; const code = ctx.req.query('code'); const routeParams = ctx.req.query('state'); @@ -147,7 +147,7 @@ module.exports = async (ctx) => { ctx.body = ``; } } else { - const { app_key = '', redirect_url = ctx.request.origin + '/weibo/timeline/0' } = config.weibo; + const { app_key = '', redirect_url = ctx.req.origin + '/weibo/timeline/0' } = config.weibo; ctx.status = 302; ctx.set({