Allow all users to generate AI text for posts

Change API endpoint `/api/ai/generate` from `requireAdmin` to `requireAuth` middleware and update OpenRouterService to use shared admin configuration instead of per-user config.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/tWDOGLP
This commit is contained in:
michaelschal committed 2025-10-14 13:58:28 +00:00
1 parent ec2e634956
commit f2672727b8
4 files changed
+12 -5

No files matched your search

+6
View File
@@ -85,6 +85,7 @@ export interface IStorage {
// OpenRouter Config
getOpenrouterConfig(userId: string): Promise<OpenrouterConfig | undefined>;
getAnyOpenrouterConfig(): Promise<OpenrouterConfig | undefined>;
createOpenrouterConfig(config: InsertOpenrouterConfig): Promise<OpenrouterConfig>;
updateOpenrouterConfig(userId: string, config: Partial<InsertOpenrouterConfig>): Promise<OpenrouterConfig>;
@@ -336,6 +337,11 @@ export class DatabaseStorage implements IStorage {
return config || undefined;
}
async getAnyOpenrouterConfig(): Promise<OpenrouterConfig | undefined> {
const [config] = await db.select().from(openrouterConfig).limit(1);
return config || undefined;
}
async createOpenrouterConfig(config: InsertOpenrouterConfig): Promise<OpenrouterConfig> {
const [newConfig] = await db.insert(openrouterConfig).values(config).returning();
return newConfig;