Skip to content

Commit

Permalink
Merge pull request #22 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 Mar 22, 2024
2 parents f72aeaa + 3e91889 commit 012e52c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 138 deletions.
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ updates:
ignore:
- dependency-name: jsrsasign
versions: ['>=11.0.0'] # no longer includes KJUR.crypto.Cipher for RSA
# ESM only packages
- dependency-name: got
versions: ['>=12.0.0']
- dependency-name: unified
versions: ['>=10.0.0']

Expand Down
11 changes: 6 additions & 5 deletions lib/routes/abc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export const route: Route = {
},
name: 'Channel & Topic',
categories: ['traditional-media'],
description: `:::tip
All Topics in [Topic Library](https://abc.net.au/news/topics) are supported, you can fill in the field after \`topic\` in its URL, or fill in the \`documentId\`.
description: `
:::tip
All Topics in [Topic Library](https://abc.net.au/news/topics) are supported, you can fill in the field after \`topic\` in its URL, or fill in the \`documentId\`.
For example, the URL for [Computer Science](https://www.abc.net.au/news/topic/computer-science) is \`https://www.abc.net.au/news/topic/computer-science\`, the \`category\` is \`news/topic/computer-science\`, and the \`documentId\` of the Topic is \`2302\`, so the route is [/abc/news/topic/computer-science](https://rsshub.app/abc/news/topic/computer-science) and [/abc/2302](https://rsshub.app/abc/2302).
For example, the URL for [Computer Science](https://www.abc.net.au/news/topic/computer-science) is \`https://www.abc.net.au/news/topic/computer-science\`, the \`category\` is \`news/topic/computer-science\`, and the \`documentId\` of the Topic is \`2302\`, so the route is [/abc/news/topic/computer-science](https://rsshub.app/abc/news/topic/computer-science) and [/abc/2302](https://rsshub.app/abc/2302).
The supported channels are all listed in the table below. For other channels, please find the \`documentId\` in the source code of the channel page and fill it in as above.
:::`,
The supported channels are all listed in the table below. For other channels, please find the \`documentId\` in the source code of the channel page and fill it in as above.
:::`,
maintainers: ['nczitzk'],
handler,
};
Expand Down
18 changes: 5 additions & 13 deletions lib/utils/got.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logger from '@/utils/logger';
import { config } from '@/config';
import got, { CancelableRequest, Response as GotResponse, NormalizedOptions, Options, Got } from 'got';
import got, { CancelableRequest, Response as GotResponse, OptionsInit, Options, Got } from 'got';

type Response<T> = GotResponse<string> & {
data: T;
Expand All @@ -25,22 +25,14 @@ const custom: {
delete: GotRequestFunction;
} & GotRequestFunction &
Got = got.extend({
get: got.get,
retry: {
limit: config.requestRetry,
statusCodes: [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 424, 426, 428, 429, 431, 451, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511, 521, 522, 524],
},
hooks: {
beforeRetry: [
(
options: NormalizedOptions & {
retryCount?: number;
},
err,
count
) => {
logger.error(`Request ${options.url} fail, retry attempt #${count}: ${err}`);
options.retryCount = count;
(err, count) => {
logger.error(`Request ${err.options.url} fail, retry attempt #${count}: ${err}`);
},
],
beforeRedirect: [
Expand All @@ -63,7 +55,7 @@ const custom: {
],
init: [
(
options: Options & {
options: OptionsInit & {
data?: string;
}
) => {
Expand All @@ -84,4 +76,4 @@ const custom: {
custom.all = (list) => Promise.all(list);

export default custom;
export type { Response, NormalizedOptions, Options } from 'got';
export type { Response, Options } from 'got';
1 change: 1 addition & 0 deletions lib/utils/request-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const requestWrapper = (url: string, options: http.RequestOptions = {}) => {
if (config.proxyStrategy === 'all') {
prxied = proxyWrapper(url, optionsWithHeaders);
} else if (config.proxyStrategy === 'on_retry' && (optionsWithHeaders as any).retryCount) {
// TODO
prxied = proxyWrapper(url, optionsWithHeaders);
}
if (prxied) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"dependencies": {
"@hono/node-server": "1.8.2",
"@hono/swagger-ui": "0.2.1",
"@hono/zod-openapi": "0.9.8",
"@hono/zod-openapi": "0.9.9",
"@notionhq/client": "2.2.14",
"@postlight/parser": "2.2.3",
"@sentry/node": "7.107.0",
Expand All @@ -70,7 +70,7 @@
"fanfou-sdk": "5.0.0",
"git-rev-sync": "3.0.2",
"googleapis": "134.0.0",
"got": "11.8.6",
"got": "14.2.1",
"hono": "4.1.3",
"html-to-text": "9.0.5",
"https-proxy-agent": "7.0.4",
Expand Down
Loading

0 comments on commit 012e52c

Please sign in to comment.