Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default [
{
ignores: ['**/coverage', '**/.vscode', '**/docker-compose.yml', '!.github', 'assets/build', 'lib/routes-deprecated', 'lib/router.js', '**/babel.config.js', 'scripts/docker/minify-docker.js', 'dist', 'dist-lib'],
},
...compat.extends('eslint:recommended', 'plugin:yml/recommended', 'plugin:@typescript-eslint/recommended'),
...compat.extends('eslint:recommended', 'plugin:yml/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/stylistic'),
n.configs['flat/recommended-script'],
unicorn.configs.recommended,
{
Expand Down Expand Up @@ -147,8 +147,16 @@ export default [
'require-await': 'error',

// typescript
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],

'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off', // stylistic
'@typescript-eslint/consistent-type-definitions': 'off', // stylistic
'@typescript-eslint/no-empty-function': 'off', // stylistic && tests
'@typescript-eslint/no-explicit-any': 'off',

'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true, ignoreProperties: true }],

'@typescript-eslint/no-var-requires': 'off',

'@typescript-eslint/no-unused-expressions': [
Expand All @@ -167,6 +175,8 @@ export default [
},
],

'@typescript-eslint/prefer-for-of': 'error',

// unicorn
'unicorn/consistent-function-scoping': 'warn',
'unicorn/explicit-length-check': 'off',
Expand All @@ -184,6 +194,7 @@ export default [
'unicorn/no-array-sort': 'warn',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-empty-file': 'warn',
'unicorn/no-for-loop': 'off',
'unicorn/no-hex-escape': 'warn',
'unicorn/no-null': 'off',
'unicorn/no-object-as-default-parameter': 'warn',
Expand Down
4 changes: 2 additions & 2 deletions lib/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ for (const namespace in namespaces) {
continue;
}

const sortedRoutes = Object.entries(namespaceData.apiRoutes) as [
const sortedRoutes = Object.entries(namespaceData.apiRoutes) as Array<[
string,
APIRoute & {
location: string;
module?: () => Promise<{ apiRoute: APIRoute }>;
},
][];
]>;

for (const [path, routeData] of sortedRoutes) {
const wrappedHandler: Handler = async (ctx) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/routes-deprecated/lolapp/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = async (ctx) => {
const name = data[0].feedNews.footer.source;
const newData = [];
let pubDate = [];
for (const [i, datum] of data.entries()) {
newData[i] = datum.feedNews.body;
for (let i = 0; i < data.length; i++) {
newData[i] = data[i].feedNews.body;
newData[i].link = 'https://mlol.qt.qq.com/go/mlol_news/varcache_article?is_lqt=true&docid=' + newData[i].commentID;
pubDate[i] = getPublishedDate(newData[i].link);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function checkRSS(response) {
checkDate(parsed.lastBuildDate);

// check items
const guids: (string | undefined)[] = [];
const guids: Array<string | undefined> = [];
for (const item of parsed.items) {
expect(item).toEqual(expect.any(Object));
expect(item.title).toEqual(expect.any(String));
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/0xxx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { filter } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10);

const baseUrl: string = 'https://0xxx.ws';
const baseUrl = 'https://0xxx.ws';
const targetUrl: string = new URL(filter ? `?${filter}` : '', baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/10000link/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { category = 'newslists', id } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const baseUrl: string = 'https://info.10000link.com';
const baseUrl = 'https://info.10000link.com';
const targetUrl: string = new URL(`${category}.aspx${id ? `?chid=${id}` : ''}`, baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down Expand Up @@ -109,7 +109,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
)
).filter((_): _ is DataItem => true);

const author: string = '10000万联网';
const author = '10000万联网';
const title: string = $('h1').contents().first().text();

return {
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/121/weather-live.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const renderDescription = (description, images) =>
export const handler = async (ctx: Context): Promise<Data> => {
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10);

const baseUrl: string = 'https://tf.121.com.cn';
const imgBaseUrl: string = 'https://wx.121.com.cn';
const baseUrl = 'https://tf.121.com.cn';
const imgBaseUrl = 'https://wx.121.com.cn';
const targetUrl: string = new URL('web/weatherLive/', baseUrl).href;
const apiUrl: string = new URL('weather/weibo/message.js', baseUrl).href;

Expand All @@ -52,7 +52,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
);
const pubDate: number | string = item.DDatetime;
const linkUrl: string | undefined = targetUrl;
const guid: string = `121-${title}-${pubDate}`;
const guid = `121-${title}-${pubDate}`;
const image: string | undefined = item.Img?.length > 0 ? new URL(`WeChat/data/weiweb/images/lwspic/${item.Img[0]}`, imgBaseUrl).href : undefined;
const updated: number | string = pubDate;

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/199it/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { category = 'newly' } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const baseUrl: string = 'https://www.199it.com';
const baseUrl = 'https://www.199it.com';
const targetUrl: string = new URL(category, baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
8 changes: 4 additions & 4 deletions lib/routes/21caijing/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { name = '热点' } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const domain: string = 'm.21jingji.com';
const baseUrl: string = `https://${domain}`;
const staticBaseUrl: string = 'https://static.21jingji.com';
const domain = 'm.21jingji.com';
const baseUrl = `https://${domain}`;
const staticBaseUrl = 'https://static.21jingji.com';
const menuUrl: string = new URL('m/webMenu.json', staticBaseUrl).href;

const menuResponse = await ofetch(menuUrl);
Expand Down Expand Up @@ -97,7 +97,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const authors: DataItem['author'] = [...new Set([item.mp?.name, item.author, item.editor, item.source].filter(Boolean))].map((name) => ({
name,
}));
const guid: string = `21jingji-${item.id}`;
const guid = `21jingji-${item.id}`;
const image: string | undefined = item.image ?? item.thumb ?? item.listthumb;
const updated: number | string = item.updatetime;

Expand Down
5 changes: 2 additions & 3 deletions lib/routes/5eplay/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ const getAcwScV2ByArg1 = (arg1) => {
const unsbox = function (str: string) {
const code = [15, 35, 29, 24, 33, 16, 1, 38, 10, 9, 19, 31, 40, 27, 22, 23, 25, 13, 6, 11, 39, 18, 20, 8, 14, 21, 32, 26, 2, 30, 7, 4, 17, 5, 3, 28, 34, 37, 12, 36];
const res: string[] = [];
// eslint-disable-next-line unicorn/no-for-loop
for (let i = 0; i < str.length; i++) {
const cur = str[i];
for (const [j, element] of code.entries()) {
if (element === i + 1) {
for (let j = 0; j < code.length; j++) {
if (code[j] === i + 1) {
res[j] = cur;
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/routes/6v123/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { category = 'dy' } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '25', 10);

const encoding: string = 'gb2312';
const encoding = 'gb2312';

const baseUrl: string = 'https://www.hao6v.me';
const baseUrl = 'https://www.hao6v.me';
const targetUrl: string = new URL(category.startsWith('gvod') ? `${category}.html` : category, baseUrl).href;

const response = await ofetch(targetUrl, {
Expand All @@ -39,7 +39,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
.text()
.replaceAll(/(\[|\])/g, '');
const linkUrl: string | undefined = $el.find('a').attr('href');
const guid: string = `${linkUrl}#${title}`;
const guid = `${linkUrl}#${title}`;
const upDatedStr: string | undefined = pubDateStr;

const processedItem: DataItem = {
Expand Down Expand Up @@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const enclosureUrl: string | undefined = $enclosureEl.attr('href');

if (enclosureUrl) {
const enclosureType: string = 'application/x-bittorrent';
const enclosureType = 'application/x-bittorrent';
const enclosureTitle: string = $enclosureEl.text();

processedItem = {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/aa1/60s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10);

const apiSlug = 'wp-json/wp/v2';
const baseUrl: string = 'https://60s.aa1.cn';
const baseUrl = 'https://60s.aa1.cn';

const apiUrl = new URL(`${apiSlug}/posts`, baseUrl).href;
const apiSearchUrl = new URL(`${apiSlug}/categories`, baseUrl).href;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/adquan/case-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { renderDescription } from './templates/description';
export const handler = async (ctx: Context): Promise<Data> => {
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '24', 10);

const baseUrl: string = 'https://www.adquan.com';
const baseUrl = 'https://www.adquan.com';
const targetUrl: string = new URL('case_library/index', baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/adquan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { renderDescription } from './templates/description';
export const handler = async (ctx: Context): Promise<Data> => {
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const baseUrl: string = 'https://www.adquan.com';
const baseUrl = 'https://www.adquan.com';
const targetUrl: string = baseUrl;

const response = await ofetch(targetUrl);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/aflcio/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { parseDate } from '@/utils/parse-date';
export const handler = async (ctx: Context): Promise<Data> => {
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '5', 10);

const baseUrl: string = 'https://aflcio.org';
const baseUrl = 'https://aflcio.org';
const targetUrl: string = new URL('blog', baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/ali213/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { category = 'new' } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const rootUrl: string = 'https://www.ali213.net';
const rootUrl = 'https://www.ali213.net';
const targetUrl: string = new URL(`news/${category.endsWith('/') ? category : `${category}/`}`, rootUrl).href;

const response = await ofetch(targetUrl);
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/ali213/zl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { category } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '1', 10);

const rootUrl: string = 'https://www.ali213.net';
const apiRootUrl: string = 'https://mp.ali213.net';
const rootUrl = 'https://www.ali213.net';
const apiRootUrl = 'https://mp.ali213.net';
const targetUrl: string = new URL(`/news/zl/${category ? (category.endsWith('/') ? category : `${category}/`) : ''}`, rootUrl).href;
const apiUrl: string = new URL('ajax/newslist', apiRootUrl).href;

Expand All @@ -37,7 +37,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const description: string = renderDescription({
intro: item.GuideRead ?? '',
});
const guid: string = `ali213-zl-${item.ID}`;
const guid = `ali213-zl-${item.ID}`;
const image: string | undefined = item.PicPath ? `https:${item.PicPath}` : undefined;

const author: DataItem['author'] = item.xiaobian;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/amazfitwatchfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { device, sort, searchParams } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const baseUrl: string = 'https://amazfitwatchfaces.com';
const baseUrl = 'https://amazfitwatchfaces.com';
const targetUrl: string = new URL(`${device}/${sort}${searchParams ? `?${searchParams}` : ''}`, baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/anytxt/release-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { parseDate } from '@/utils/parse-date';
export const handler = async (ctx: Context): Promise<Data> => {
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const baseUrl: string = 'https://anytxt.net';
const baseUrl = 'https://anytxt.net';
const targetUrl: string = new URL('download/', baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/app-sales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
});
const $: CheerioAPI = load(response);
const language = $('html').attr('lang') ?? 'en';
const selector: string = 'div.card-panel';
const selector = 'div.card-panel';

const items: DataItem[] = await fetchItems($, selector, targetUrl, country, limit);

Expand Down
6 changes: 3 additions & 3 deletions lib/routes/app-sales/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { renderToString } from 'hono/jsx/dom/server';
import type { DataItem } from '@/types';
import ofetch from '@/utils/ofetch';

const baseUrl: string = 'https://www.app-sales.net';
const baseUrl = 'https://www.app-sales.net';
const renderDescription = ({
images,
appName,
Expand All @@ -20,7 +20,7 @@ const renderDescription = ({
priceDisco,
linkUrl,
}: {
images?: { alt?: string; src?: string }[];
images?: Array<{ alt?: string; src?: string }>;
appName?: string;
appDev?: string;
appNote?: string;
Expand Down Expand Up @@ -150,7 +150,7 @@ const processItems = ($: CheerioAPI, selector: string): DataItem[] =>
const isHot: boolean = $el.hasClass('sale-hot');
const isFree: boolean = priceNew?.toLocaleUpperCase() === 'FREE';

const title: string = `${appName} ${formatPriceChangeTag(priceOld, priceNew, priceDisco)}`;
const title = `${appName} ${formatPriceChangeTag(priceOld, priceNew, priceDisco)}`;
const image: string | undefined = $el.find('div.app-icon img').attr('src');
const linkUrl: string | undefined = $el.find('div.sale-list-action a').attr('href');
const description: string | undefined = renderDescription({
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/apple/security-releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { language = 'en-us' } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const baseUrl: string = 'https://support.apple.com';
const baseUrl = 'https://support.apple.com';
const targetUrl: string = new URL(`${language}/100100`, baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/artstation/templates/description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ type DescriptionData = {
src?: string;
title?: string;
};
assets?: {
assets?: Array<{
asset_type?: string;
player_embedded?: string;
image_url?: string;
}[];
}>;
};

const ArtstationDescription = ({ description, image, assets }: DescriptionData) => (
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/asiafruitchina/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const { category = 'all' } = ctx.req.param();
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10);

const baseUrl: string = 'https://asiafruitchina.net';
const baseUrl = 'https://asiafruitchina.net';
const targetUrl: string = new URL(`categories?gspx=${category}`, baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/asiafruitchina/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { renderDescription } from './templates/description';
export const handler = async (ctx: Context): Promise<Data> => {
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);

const baseUrl: string = 'https://asiafruitchina.net';
const baseUrl = 'https://asiafruitchina.net';
const targetUrl: string = new URL('category/news', baseUrl).href;

const response = await ofetch(targetUrl);
Expand Down
Loading