Add authentication check and require user ID for story creation

This commit is contained in:
Riccardo Giorato
2025-12-25 14:21:41 +01:00
parent 8bc68eb102
commit d5b163e586
3 changed files with 29 additions and 18 deletions
+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 }): Promise<Story> {
export async function createStory(data: { title: string; description?: string; userId: string }): Promise<Story> {
// Generate a unique slug
let slug = generateComicSlug();
let attempts = 0;
+1 -1
View File
@@ -7,7 +7,7 @@ export const stories = pgTable('stories', {
title: text('title').notNull(),
slug: text('slug').notNull().unique(),
description: text('description'),
userId: uuid('user_id'), // Optional - for future Clerk auth
userId: uuid('user_id').notNull(), // Required Clerk user ID
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});