mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-08-31 01:01:11 +08:00
feat(core): add a new environment variable to configure the output format (#22738)
This commit is contained in:
committed by
GitHub
parent
fd185c3edb
commit
bd24a2fdcd
@@ -67,6 +67,7 @@ type ConfigEnvKeys =
|
||||
| 'DISABLE_NSFW'
|
||||
| 'SUFFIX'
|
||||
| 'TITLE_LENGTH_LIMIT'
|
||||
| 'FORMAT'
|
||||
// OpenAI
|
||||
| 'OPENAI_API_KEY'
|
||||
| 'OPENAI_MODEL'
|
||||
@@ -340,6 +341,7 @@ export type Config = {
|
||||
};
|
||||
suffix?: string;
|
||||
titleLengthLimit: number;
|
||||
format: string;
|
||||
openai: {
|
||||
apiKey?: string;
|
||||
model?: string;
|
||||
@@ -842,6 +844,7 @@ const calculateValue = () => {
|
||||
},
|
||||
suffix: envs.SUFFIX,
|
||||
titleLengthLimit: toInt(envs.TITLE_LENGTH_LIMIT, 150),
|
||||
format: envs.FORMAT || 'rss',
|
||||
openai: {
|
||||
apiKey: envs.OPENAI_API_KEY,
|
||||
model: envs.OPENAI_MODEL || 'gpt-3.5-turbo-16k',
|
||||
|
||||
@@ -19,7 +19,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
||||
}
|
||||
|
||||
const requestPath = ctx.req.path;
|
||||
const format = `:${ctx.req.query('format') || 'rss'}`;
|
||||
const format = `:${ctx.req.query('format') || config.format}`;
|
||||
const limit = ctx.req.query('limit') ? `:${ctx.req.query('limit')}` : '';
|
||||
const key = 'rsshub:koa-redis-cache:' + h64ToString(requestPath + format + limit);
|
||||
const controlKey = 'rsshub:path-requested:' + h64ToString(requestPath + format + limit);
|
||||
|
||||
@@ -20,7 +20,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
||||
}
|
||||
|
||||
const data: Data = ctx.get('data');
|
||||
const outputType = ctx.req.query('format') || 'rss';
|
||||
const outputType = ctx.req.query('format') || config.format;
|
||||
|
||||
// only enable when debugInfo=true
|
||||
if (config.debugInfo) {
|
||||
|
||||
Reference in New Issue
Block a user