Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Nov 21, 2024
2 parents 1170b00 + e7d732b commit 3c217a7
Show file tree
Hide file tree
Showing 1,720 changed files with 19,154 additions and 4,995 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/issue-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,31 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
issues: write
attestations: write
issues: write
pull-requests: write
steps:
- name: Fetch PR data (for PR)
if: github.event.issue.pull_request
uses: octokit/request-action@v2.x
id: pr-data
with:
route: GET /repos/{repo}/pulls/{number}
repo: ${{ github.repository }}
number: ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
if: ${{ !github.event.issue.pull_request }}
uses: actions/checkout@v4

- name: Checkout PR
if: github.event.issue.pull_request
uses: actions/checkout@v4
with:
ref: ${{ fromJson(steps.pr-data.outputs.data).head.ref }}

- name: Install pnpm
uses: pnpm/action-setup@v4

Expand Down Expand Up @@ -105,7 +124,7 @@ jobs:
await test({ github, context, core }, link, routes, number)
- name: Print logs
if: (env.TEST_CONTINUE)
if: env.TEST_CONTINUE
run: cat ${{ github.workspace }}/logs/combined.log

- name: Upload Artifact
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
# pinned to 18 until https://github.com/compulim/version-from-git/issues/16 is fixed
node-version: 18
node-version: lts/*
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies (pnpm)
Expand Down
35 changes: 5 additions & 30 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,6 @@ permissions:
checks: write

jobs:
fix-pnpm-lock:
# workaround for https://github.com/dependabot/dependabot-core/issues/7258
# until https://github.com/pnpm/pnpm/issues/6530 is fixed
if: github.triggering_actor == 'dependabot[bot]' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'pnpm'
- run: |
rm pnpm-lock.yaml
pnpm i
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'chore: fix pnpm install'
commit_user_name: dependabot[bot]
commit_user_email: 49699333+dependabot[bot]@users.noreply.github.com
commit_author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

vitest:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand All @@ -52,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [ 20, 22 ]
node-version: [ latest, lts/*, lts/-1 ]
name: Vitest on Node ${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
Expand All @@ -72,8 +47,8 @@ jobs:
env:
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/
- name: Upload coverage to Codecov
if: ${{ matrix.node-version == '20' }}
uses: codecov/codecov-action@v4
if: ${{ matrix.node-version == 'lts/*' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos as documented, but seems broken

Expand All @@ -83,7 +58,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [ 20, 22 ]
node-version: [ latest, lts/*, lts/-1 ]
chromium:
- name: bundled Chromium
dependency: ''
Expand Down Expand Up @@ -140,7 +115,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [ 20, 22 ]
node-version: [ 23, 22, 20 ]
name: Build radar and maintainer on Node ${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
Expand Down
31 changes: 29 additions & 2 deletions lib/api/category/one.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,50 @@ const ParamsSchema = z.object({
}),
});

const QuerySchema = z.object({
categories: z
.string()
.transform((val) => val.split(','))
.optional(),
lang: z.string().optional(),
});

const route = createRoute({
method: 'get',
path: '/category/{category}',
tags: ['Category'],
request: {
query: QuerySchema,
params: ParamsSchema,
},
responses: {
200: {
description: 'Namespace list by category',
description: 'Namespace list by categories and language',
},
},
});

const handler: RouteHandler<typeof route> = (ctx) => {
const { categories, lang } = ctx.req.valid('query');
const { category } = ctx.req.valid('param');
return ctx.json(categoryList[category]);

let allCategories = [category];
if (categories && categories.length > 0) {
allCategories = [...allCategories, ...categories];
}

// Get namespaces that exist in all requested categories
const commonNamespaces = Object.keys(categoryList[category] || {}).filter((namespace) => allCategories.every((cat) => categoryList[cat]?.[namespace]));

// Create result directly from common namespaces
let result = Object.fromEntries(commonNamespaces.map((namespace) => [namespace, categoryList[category][namespace]]));

// Filter by language if provided
if (lang) {
result = Object.fromEntries(Object.entries(result).filter(([, value]) => value.lang === lang));
}

return ctx.json(result);
};

export { route, handler };
64 changes: 63 additions & 1 deletion lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { ofetch } from 'ofetch';
let envs = process.env;

export type Config = {
// app config
disallowRobot: boolean;
enableCluster?: string;
isPackage: boolean;
nodeName?: string;
puppeteerWSEndpoint?: string;
chromiumExecutablePath?: string;
// network
connect: {
port: number;
};
Expand All @@ -20,6 +22,7 @@ export type Config = {
ua: string;
trueUA: string;
allowOrigin?: string;
// cache
cache: {
type: string;
requestTimeout: number;
Expand All @@ -32,6 +35,7 @@ export type Config = {
redis: {
url: string;
};
// proxy
proxyUri?: string;
proxy: {
protocol?: string;
Expand All @@ -43,7 +47,9 @@ export type Config = {
};
pacUri?: string;
pacScript?: string;
// access control
accessKey?: string;
// logging
debugInfo: string;
loggerLevel: string;
noLogfiles?: boolean;
Expand All @@ -56,6 +62,8 @@ export type Config = {
dsn?: string;
routeTimeout: number;
};
enableRemoteDebugging?: boolean;
// feed config
hotlink: {
template?: string;
includePaths?: string[];
Expand All @@ -78,6 +86,8 @@ export type Config = {
promptTitle: string;
promptDescription: string;
};

// Route-specific Configurations
bilibili: {
cookies: Record<string, string | undefined>;
dmImgList?: string;
Expand All @@ -94,9 +104,15 @@ export type Config = {
bupt: {
portal_cookie?: string;
};
caixin: {
cookie?: string;
};
civitai: {
cookie?: string;
};
dianping: {
cookie?: string;
};
dida365: {
username?: string;
password?: string;
Expand Down Expand Up @@ -151,6 +167,9 @@ export type Config = {
google: {
fontsApiKey?: string;
};
guozaoke: {
cookies?: string;
};
hefeng: {
key?: string;
};
Expand Down Expand Up @@ -233,6 +252,9 @@ export type Config = {
notion: {
key?: string;
};
patreon: {
sessionId?: string;
};
pianyuan: {
cookie?: string;
};
Expand Down Expand Up @@ -267,9 +289,15 @@ export type Config = {
scihub: {
host?: string;
};
sis001: {
baseUrl?: string;
};
skeb: {
bearerToken?: string;
};
sorrycc: {
cookie?: string;
};
spotify: {
clientId?: string;
clientSecret?: string;
Expand All @@ -280,6 +308,15 @@ export type Config = {
};
telegram: {
token?: string;
session?: string;
apiId?: number;
apiHash?: string;
maxConcurrentDownloads?: number;
proxy?: {
host?: string;
port?: number;
secret?: string;
};
};
tophub: {
cookie?: string;
Expand All @@ -291,6 +328,7 @@ export type Config = {
username?: string[];
password?: string[];
authenticationSecret?: string[];
phoneOrEmail?: string[];
authToken?: string[];
};
uestc: {
Expand Down Expand Up @@ -404,7 +442,6 @@ const calculateValue = () => {
requestTimeout: toInt(envs.REQUEST_TIMEOUT, 30000), // Milliseconds to wait for the server to end the response before aborting the request
ua: envs.UA ?? (toBoolean(envs.NO_RANDOM_UA, false) ? TRUE_UA : randUserAgent({ browser: 'chrome', os: 'mac os', device: 'desktop' })),
trueUA: TRUE_UA,
// cors request
allowOrigin: envs.ALLOW_ORIGIN,
// cache
cache: {
Expand Down Expand Up @@ -448,6 +485,7 @@ const calculateValue = () => {
dsn: envs.SENTRY,
routeTimeout: toInt(envs.SENTRY_ROUTE_TIMEOUT, 30000),
},
enableRemoteDebugging: toBoolean(envs.ENABLE_REMOTE_DEBUGGING, false),
// feed config
hotlink: {
template: envs.HOTLINK_TEMPLATE,
Expand Down Expand Up @@ -489,9 +527,15 @@ const calculateValue = () => {
bupt: {
portal_cookie: envs.BUPT_PORTAL_COOKIE,
},
caixin: {
cookie: envs.CAIXIN_COOKIE,
},
civitai: {
cookie: envs.CIVITAI_COOKIE,
},
dianping: {
cookie: envs.DIANPING_COOKIE,
},
dida365: {
username: envs.DIDA365_USERNAME,
password: envs.DIDA365_PASSWORD,
Expand Down Expand Up @@ -546,6 +590,9 @@ const calculateValue = () => {
google: {
fontsApiKey: envs.GOOGLE_FONTS_API_KEY,
},
guozaoke: {
cookies: envs.GUOZAOKE_COOKIES,
},
hefeng: {
// weather
key: envs.HEFENG_KEY,
Expand Down Expand Up @@ -629,6 +676,9 @@ const calculateValue = () => {
notion: {
key: envs.NOTION_TOKEN,
},
patreon: {
sessionId: envs.PATREON_SESSION_ID,
},
pianyuan: {
cookie: envs.PIANYUAN_COOKIE,
},
Expand Down Expand Up @@ -663,9 +713,15 @@ const calculateValue = () => {
scihub: {
host: envs.SCIHUB_HOST || 'https://sci-hub.se/',
},
sis001: {
baseUrl: envs.SIS001_BASE_URL || 'https://sis001.com',
},
skeb: {
bearerToken: envs.SKEB_BEARER_TOKEN,
},
sorrycc: {
cookie: envs.SORRYCC_COOKIES,
},
spotify: {
clientId: envs.SPOTIFY_CLIENT_ID,
clientSecret: envs.SPOTIFY_CLIENT_SECRET,
Expand All @@ -680,6 +736,11 @@ const calculateValue = () => {
apiId: envs.TELEGRAM_API_ID,
apiHash: envs.TELEGRAM_API_HASH,
maxConcurrentDownloads: envs.TELEGRAM_MAX_CONCURRENT_DOWNLOADS,
proxy: {
host: envs.TELEGRAM_PROXY_HOST,
port: envs.TELEGRAM_PROXY_PORT,
secret: envs.TELEGRAM_PROXY_SECRET,
},
},
tophub: {
cookie: envs.TOPHUB_COOKIE,
Expand All @@ -691,6 +752,7 @@ const calculateValue = () => {
username: envs.TWITTER_USERNAME?.split(','),
password: envs.TWITTER_PASSWORD?.split(','),
authenticationSecret: envs.TWITTER_AUTHENTICATION_SECRET?.split(','),
phoneOrEmail: envs.TWITTER_PHONE_OR_EMAIL?.split(','),
authToken: envs.TWITTER_AUTH_TOKEN?.split(','),
},
uestc: {
Expand Down
Loading

0 comments on commit 3c217a7

Please sign in to comment.