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({ const generation = await genService.create({
projectId: project.id, projectId: project.id,
apiKeyId: null as unknown as string, // System generation for live URLs apiKeyId: null as unknown as string, // System generation for live URLs
organizationSlug: orgSlug,
projectSlug: projectSlug,
prompt, prompt,
aspectRatio: (aspectRatio as string) || GENERATION_LIMITS.DEFAULT_ASPECT_RATIO, aspectRatio: (aspectRatio as string) || GENERATION_LIMITS.DEFAULT_ASPECT_RATIO,
autoEnhance: normalizedAutoEnhance, autoEnhance: normalizedAutoEnhance,

View File

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

View File

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

View File

@ -65,6 +65,8 @@ liveRouter.get(
const projectId = req.apiKey.projectId; const projectId = req.apiKey.projectId;
const apiKeyId = req.apiKey.id; 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 { try {
// Compute prompt hash for cache lookup // Compute prompt hash for cache lookup
@ -122,6 +124,8 @@ liveRouter.get(
const generation = await genService.create({ const generation = await genService.create({
projectId, projectId,
apiKeyId, apiKeyId,
organizationSlug,
projectSlug,
prompt, prompt,
aspectRatio: (aspectRatio as string) || GENERATION_LIMITS.DEFAULT_ASPECT_RATIO, aspectRatio: (aspectRatio as string) || GENERATION_LIMITS.DEFAULT_ASPECT_RATIO,
requestId: req.requestId, requestId: req.requestId,

View File

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