feat(core): add a new environment variable to configure the output format (#22738)

This commit is contained in:
Serhii Hospodarchuk
2026-07-16 18:01:26 +03:00
committed by GitHub
parent fd185c3edb
commit bd24a2fdcd
3 changed files with 5 additions and 2 deletions
+3
View File
@@ -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',
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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) {