Skip to content

Commit

Permalink
Merge pull request #1339 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Apr 4, 2024
2 parents 2de1cc1 + 3ba4a63 commit db42428
Show file tree
Hide file tree
Showing 503 changed files with 928 additions and 633 deletions.
4 changes: 2 additions & 2 deletions .puppeteerrc.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { join } = require('path');
const path = require('path');

/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: join(__dirname, 'node_modules', '.cache', 'puppeteer'),
cacheDirectory: path.join(__dirname, 'node_modules', '.cache', 'puppeteer'),
};
11 changes: 5 additions & 6 deletions lib/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ const app = new Hono();

app.use(compress());

app.use(jsxRenderer(
({ children }) => <>{children}</>,
{
app.use(
jsxRenderer(({ children }) => <>{children}</>, {
docType: '<?xml version="1.0" encoding="UTF-8"?>',
stream: {}
}
));
stream: {},
})
);
app.use(mLogger);
app.use(sentry);
app.use(accessControl);
Expand Down
19 changes: 7 additions & 12 deletions lib/errors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,13 @@ export const errorHandler: ErrorHandler = (error, ctx) => {

logger.error(`Error in ${requestPath}: ${message}`);

return config.isPackage ? ctx.json({
error: {
message: error.message ?? error,
},
}) : ctx.html((
<Error
requestPath={requestPath}
message={message}
errorRoute={hasMatchedRoute ? matchedRoute : requestPath}
nodeVersion={process.version}
/>
));
return config.isPackage
? ctx.json({
error: {
message: error.message ?? error,
},
})
: ctx.html(<Error requestPath={requestPath} message={message} errorRoute={hasMatchedRoute ? matchedRoute : requestPath} nodeVersion={process.version} />);
};

export const notFoundHandler: NotFoundHandler = (ctx) => errorHandler(new NotFoundError(), ctx);
4 changes: 0 additions & 4 deletions lib/middleware/template.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { rss3Ums, json, RSS, Atom } from '@/utils/render';
import * as path from 'node:path';
import { config } from '@/config';
import { collapseWhitespace, convertDateToISO8601 } from '@/utils/common-utils';
import type { MiddlewareHandler } from 'hono';
import { Data } from '@/types';

import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

// Set RSS <ttl> (minute) according to the availability of cache
// * available: max(config.cache.routeExpire / 60, 1)
// * unavailable: 1
Expand Down
2 changes: 1 addition & 1 deletion lib/registry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Namespace, Route } from '@/types';
import { directoryImport } from 'directory-import';
import { Hono, type Handler } from 'hono';
import * as path from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { serveStatic } from '@hono/node-server/serve-static';

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/005/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const handler = async (ctx) => {
const { category = 'zx' } = ctx.req.param();
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/12306/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';
import { config } from '@/config';

const rootUrl = 'https://kyfw.12306.cn';
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/141jav/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/{.*}?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/141ppv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/{.*}?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

const root_url = 'https://inf.ds.163.com';

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/exclusive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

const ids = {
'': {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/music/artist-songs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);

import got from '@/utils/got';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/music/artist/songs/:id',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/music/artist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);

import got from '@/utils/got';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/music/artist/:id',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/music/djradio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/music/djradio/:id',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/music/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { config } from '@/config';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/music/playlist/:id',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/music/userevents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Route } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

import * as path from 'node:path';
import path from 'node:path';
import got from '@/utils/got';
import { art } from '@/utils/render';
const renderDescription = (info) => art(path.join(__dirname, '../templates/music/userevents.art'), info);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/music/userplaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);

import got from '@/utils/got';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/music/user/playlist/:uid',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/music/userplayrecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { config } from '@/config';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

const headers = {
cookie: config.ncm.cookies,
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/open/vip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/open/vip',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

const parseDyArticle = (item, tryGet) =>
tryGet(item.link, async () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/18comic/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';
import { config } from '@/config';

const defaultDomain = 'jmcomic1.me';
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/1point3acres/offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { art } from '@/utils/render';
import { parseDate } from '@/utils/parse-date';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/offer/:year?/:major?/:school?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/1point3acres/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';
import bbcode from 'bbcodejs';

const rootUrl = 'https://instant.1point3acres.com';
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/1x/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const handler = async (ctx) => {
const { category = 'latest/awarded' } = ctx.req.param();
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/2048/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/:id?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/3kns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import { load } from 'cheerio';
import { Context } from 'hono';
import * as path from 'node:path';
import path from 'node:path';
const __dirname = getCurrentPath(import.meta.url);

export const route: Route = {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/4gamers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

import got from '@/utils/got';
import * as path from 'node:path';
import path from 'node:path';
import { art } from '@/utils/render';
import { parseDate } from '@/utils/parse-date';

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/4ksj/forum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';
import iconv from 'iconv-lite';

export const route: Route = {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/500px/tribe-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

import { baseUrl, getTribeDetail, getTribeSets } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/500px/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const __dirname = getCurrentPath(import.meta.url);
import cache from '@/utils/cache';
import { art } from '@/utils/render';
import { parseDate } from '@/utils/parse-date';
import * as path from 'node:path';
import path from 'node:path';
import { baseUrl, getUserInfoFromUsername, getUserInfoFromId, getUserWorks } from './utils';

export const route: Route = {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/56kog/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import iconv from 'iconv-lite';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

const rootUrl = 'https://www.56kog.com';

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/591/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Route } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

import * as path from 'node:path';
import path from 'node:path';

import { CookieJar } from 'tough-cookie';
import { load } from 'cheerio';
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/78dm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '*',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/7mmtv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/:language?/:category?/:type?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/8264/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import iconv from 'iconv-lite';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/list/:id?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/91porn/author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';
import { domainValidation } from './utils';

export const route: Route = {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/91porn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';
import { domainValidation } from './utils';

export const route: Route = {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/95mm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

const rootUrl = 'https://www.95mm.vip';

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/abc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';

export const route: Route = {
path: '/:category{.+}?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/acs/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import * as path from 'node:path';
import path from 'node:path';
import { config } from '@/config';
import puppeteer from '@/utils/puppeteer';

Expand Down
Loading

0 comments on commit db42428

Please sign in to comment.