fix: urls and storage structure

This commit is contained in:
Oleg Proskurin 2025-12-26 01:10:14 +07:00
parent 7e04fcbbb0
commit b0e6304e07
5 changed files with 11 additions and 5 deletions

View File

@ -422,6 +422,8 @@ cdnRouter.get(
const generation = await genService.create({
projectId: project.id,
apiKeyId: null as unknown as string, // System generation for live URLs
organizationSlug: orgSlug,
projectSlug: projectSlug,
prompt,
aspectRatio: (aspectRatio as string) || GENERATION_LIMITS.DEFAULT_ASPECT_RATIO,
autoEnhance: normalizedAutoEnhance,

View File

@ -40,8 +40,8 @@ uploadRouter.post(
}
// Extract org/project slugs from validated API key
const orgSlug = req.apiKey?.organizationSlug || process.env.DEFAULT_ORG_SLUG || 'default';
const projectSlug = req.apiKey?.projectSlug || process.env.DEFAULT_PROJECT_SLUG || 'main'; // Guaranteed by requireProjectKey middleware
const orgSlug = req.apiKey?.organizationSlug || process.env['DEFAULT_ORG_SLUG'] || 'default';
const projectSlug = req.apiKey?.projectSlug || process.env['DEFAULT_PROJECT_SLUG'] || 'main'; // Guaranteed by requireProjectKey middleware
console.log(
`[${timestamp}] [${requestId}] Starting file upload for org:${orgSlug}, project:${projectSlug}`,

View File

@ -114,8 +114,8 @@ generationsRouter.post(
const projectId = req.apiKey.projectId;
const apiKeyId = req.apiKey.id;
const organizationSlug = req.apiKey.organizationSlug || process.env.DEFAULT_ORG_SLUG || 'default';
const projectSlug = req.apiKey.projectSlug || process.env.DEFAULT_PROJECT_SLUG || 'main';
const organizationSlug = req.apiKey.organizationSlug || process.env['DEFAULT_ORG_SLUG'] || 'default';
const projectSlug = req.apiKey.projectSlug || process.env['DEFAULT_PROJECT_SLUG'] || 'main';
const generation = await service.create({
projectId,

View File

@ -65,6 +65,8 @@ liveRouter.get(
const projectId = req.apiKey.projectId;
const apiKeyId = req.apiKey.id;
const organizationSlug = req.apiKey.organizationSlug || process.env['DEFAULT_ORG_SLUG'] || 'default';
const projectSlug = req.apiKey.projectSlug || process.env['DEFAULT_PROJECT_SLUG'] || 'main';
try {
// Compute prompt hash for cache lookup
@ -122,6 +124,8 @@ liveRouter.get(
const generation = await genService.create({
projectId,
apiKeyId,
organizationSlug,
projectSlug,
prompt,
aspectRatio: (aspectRatio as string) || GENERATION_LIMITS.DEFAULT_ASPECT_RATIO,
requestId: req.requestId,

View File

@ -1,7 +1,7 @@
import { randomUUID } from 'crypto';
import { eq, desc, count, and, isNull, inArray } from 'drizzle-orm';
import { db } from '@/db';
import { generations, flows, images, projects, organizations } from '@banatie/database';
import { generations, flows, images, projects } from '@banatie/database';
import type {
Generation,
NewGeneration,