Simplify Replit deployment
This commit is contained in:
+22
-8
@@ -55,31 +55,45 @@ function argFlag(name: string): boolean {
|
||||
return process.argv.includes(`--${name}`);
|
||||
}
|
||||
|
||||
function envValue(name: string): string | undefined {
|
||||
const value = process.env[name];
|
||||
return value && value.length > 0 ? value : undefined;
|
||||
}
|
||||
|
||||
function applyArgOverrides(base: AppConfig): AppConfig {
|
||||
const rawPort = argValue("port");
|
||||
const rawPort = argValue("port") ?? envValue("PORT");
|
||||
const port = rawPort === undefined ? base.server.port : Number(rawPort);
|
||||
if (!Number.isInteger(port) || port <= 0) {
|
||||
throw new Error(`Invalid CLI value "--port": ${rawPort}`);
|
||||
throw new Error(`Invalid port value: ${rawPort}`);
|
||||
}
|
||||
|
||||
const host = argValue("host") ?? envValue("HOST") ?? base.server.host;
|
||||
const proxyApiKey = argValue("proxy-api-key") ?? envValue("PROXY_API_KEY") ?? base.proxy.apiKey;
|
||||
const openaiBaseURL = argValue("openai-base-url") ?? envValue("AI_INTEGRATIONS_OPENAI_BASE_URL");
|
||||
const openaiApiKey = argValue("openai-api-key") ?? envValue("AI_INTEGRATIONS_OPENAI_API_KEY");
|
||||
const anthropicBaseURL =
|
||||
argValue("anthropic-base-url") ?? envValue("AI_INTEGRATIONS_ANTHROPIC_BASE_URL");
|
||||
const anthropicApiKey =
|
||||
argValue("anthropic-api-key") ?? envValue("AI_INTEGRATIONS_ANTHROPIC_API_KEY");
|
||||
|
||||
return {
|
||||
server: {
|
||||
host: argValue("host") ?? base.server.host,
|
||||
host,
|
||||
port,
|
||||
},
|
||||
proxy: {
|
||||
apiKey: argValue("proxy-api-key") ?? base.proxy.apiKey,
|
||||
apiKey: proxyApiKey,
|
||||
},
|
||||
providers: {
|
||||
openai: {
|
||||
...base.providers.openai,
|
||||
...(argValue("openai-base-url") ? { baseURL: argValue("openai-base-url") } : {}),
|
||||
...(argValue("openai-api-key") ? { apiKey: argValue("openai-api-key") } : {}),
|
||||
...(openaiBaseURL ? { baseURL: openaiBaseURL } : {}),
|
||||
...(openaiApiKey ? { apiKey: openaiApiKey } : {}),
|
||||
},
|
||||
anthropic: {
|
||||
...base.providers.anthropic,
|
||||
...(argValue("anthropic-base-url") ? { baseURL: argValue("anthropic-base-url") } : {}),
|
||||
...(argValue("anthropic-api-key") ? { apiKey: argValue("anthropic-api-key") } : {}),
|
||||
...(anthropicBaseURL ? { baseURL: anthropicBaseURL } : {}),
|
||||
...(anthropicApiKey ? { apiKey: anthropicApiKey } : {}),
|
||||
},
|
||||
},
|
||||
logging: {
|
||||
|
||||
Reference in New Issue
Block a user