usesOwnApiKey

This commit is contained in:
Riccardo Giorato
2026-01-29 16:47:51 +01:00
parent 268453886f
commit 6ed91fffec
3 changed files with 5 additions and 2 deletions
+2
View File
@@ -64,6 +64,7 @@ export async function POST(request: NextRequest) {
// Determine which API key to use
let finalApiKey = apiKey;
const isUsingFreeTier = !apiKey;
const usesOwnApiKey = !!apiKey;
if (isUsingFreeTier) {
// Use default API key for free tier
@@ -115,6 +116,7 @@ export async function POST(request: NextRequest) {
description: undefined,
userId: userId,
style,
usesOwnApiKey,
});
page = await createPage({
+1 -1
View File
@@ -3,7 +3,7 @@ import { stories, pages, type Story, type Page } from './schema';
import { eq } from 'drizzle-orm';
import { generateComicSlug } from './slug-generator';
export async function createStory(data: { title: string; description?: string; userId: string; style?: string }): Promise<Story> {
export async function createStory(data: { title: string; description?: string; userId: string; style?: string; usesOwnApiKey?: boolean }): Promise<Story> {
// Generate a unique slug
let slug = generateComicSlug();
let attempts = 0;
+2 -1
View File
@@ -1,4 +1,4 @@
import { pgTable, text, integer, timestamp, uuid, jsonb } from 'drizzle-orm/pg-core';
import { pgTable, text, integer, timestamp, uuid, jsonb, boolean } from 'drizzle-orm/pg-core';
import { relations } from 'drizzle-orm';
// Stories table
@@ -9,6 +9,7 @@ export const stories = pgTable('stories', {
description: text('description'),
style: text('style').default('noir').notNull(),
userId: text('user_id').notNull(),
usesOwnApiKey: boolean('uses_own_api_key').default(false),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});