feat: v3 migration - 15/n

This commit is contained in:
DIYgod 2024-02-29 18:07:33 +08:00
parent 9787a92c84
commit 300d450fe0
No known key found for this signature in database
35 changed files with 38 additions and 38 deletions

View File

@ -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}`;

View File

@ -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}` : ''}`;

View File

@ -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}`}`;

View File

@ -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}`}`;

View File

@ -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);

View File

@ -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);

View File

@ -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');

View File

@ -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: {

View File

@ -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() || '考研资讯';

View File

@ -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

View File

@ -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`;

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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);

View File

@ -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`);

View File

@ -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`);

View File

@ -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 () => {

View File

@ -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`);

View File

@ -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);

View File

@ -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}` : '';

View File

@ -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,

View File

@ -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}`;

View File

@ -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);

View File

@ -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}`; // 按天统计

View File

@ -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: {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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;

View File

@ -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 = `<script>window.location = '/weibo/timeline/${uid}${routeParams ? `/${routeParams}` : ''}'</script>`;
}
} 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({