usesOwnApiKey
This commit is contained in:
@@ -64,6 +64,7 @@ export async function POST(request: NextRequest) {
|
|||||||
// Determine which API key to use
|
// Determine which API key to use
|
||||||
let finalApiKey = apiKey;
|
let finalApiKey = apiKey;
|
||||||
const isUsingFreeTier = !apiKey;
|
const isUsingFreeTier = !apiKey;
|
||||||
|
const usesOwnApiKey = !!apiKey;
|
||||||
|
|
||||||
if (isUsingFreeTier) {
|
if (isUsingFreeTier) {
|
||||||
// Use default API key for free tier
|
// Use default API key for free tier
|
||||||
@@ -115,6 +116,7 @@ export async function POST(request: NextRequest) {
|
|||||||
description: undefined,
|
description: undefined,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
style,
|
style,
|
||||||
|
usesOwnApiKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
page = await createPage({
|
page = await createPage({
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ import { stories, pages, type Story, type Page } from './schema';
|
|||||||
import { eq } from 'drizzle-orm';
|
import { eq } from 'drizzle-orm';
|
||||||
import { generateComicSlug } from './slug-generator';
|
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
|
// Generate a unique slug
|
||||||
let slug = generateComicSlug();
|
let slug = generateComicSlug();
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
|
|||||||
+2
-1
@@ -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';
|
import { relations } from 'drizzle-orm';
|
||||||
|
|
||||||
// Stories table
|
// Stories table
|
||||||
@@ -9,6 +9,7 @@ export const stories = pgTable('stories', {
|
|||||||
description: text('description'),
|
description: text('description'),
|
||||||
style: text('style').default('noir').notNull(),
|
style: text('style').default('noir').notNull(),
|
||||||
userId: text('user_id').notNull(),
|
userId: text('user_id').notNull(),
|
||||||
|
usesOwnApiKey: boolean('uses_own_api_key').default(false),
|
||||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||||
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user