fix: image paths
This commit is contained in:
parent
960183c9c4
commit
91ba71cc23
|
|
@ -61,8 +61,8 @@ export const createApp = (): Application => {
|
|||
});
|
||||
|
||||
// API info endpoint
|
||||
app.get('/api/info', (_req, res) => {
|
||||
const info = {
|
||||
app.get('/api/info', async (req: any, res) => {
|
||||
const info: any = {
|
||||
name: 'Banatie - Nano Banana Image Generation API',
|
||||
version: '1.0.0',
|
||||
description: 'REST API service for AI-powered image generation using Gemini Flash Image model',
|
||||
|
|
@ -80,6 +80,52 @@ export const createApp = (): Application => {
|
|||
}
|
||||
};
|
||||
|
||||
// If API key is provided, validate and return key info
|
||||
const providedKey = req.headers['x-api-key'] as string;
|
||||
if (providedKey) {
|
||||
try {
|
||||
const { ApiKeyService } = await import('./services/ApiKeyService');
|
||||
const apiKeyService = new ApiKeyService();
|
||||
const apiKey = await apiKeyService.validateKey(providedKey);
|
||||
|
||||
if (apiKey) {
|
||||
// Query org and project names
|
||||
let organizationName = apiKey.organizationId;
|
||||
let projectName = apiKey.projectId;
|
||||
|
||||
try {
|
||||
const { db } = await import('./db');
|
||||
const { organizations, projects } = await import('@banatie/database');
|
||||
const { eq } = await import('drizzle-orm');
|
||||
|
||||
if (apiKey.organizationId) {
|
||||
const org = await db.select().from(organizations).where(eq(organizations.id, apiKey.organizationId)).limit(1);
|
||||
if (org.length > 0) organizationName = org[0].name;
|
||||
}
|
||||
|
||||
if (apiKey.projectId) {
|
||||
const proj = await db.select().from(projects).where(eq(projects.id, apiKey.projectId)).limit(1);
|
||||
if (proj.length > 0) projectName = proj[0].name;
|
||||
}
|
||||
} catch (dbError) {
|
||||
// Fallback to IDs if DB query fails
|
||||
}
|
||||
|
||||
info.authenticated = true;
|
||||
info.keyInfo = {
|
||||
type: apiKey.keyType,
|
||||
organizationId: apiKey.organizationId,
|
||||
organizationName,
|
||||
projectId: apiKey.projectId,
|
||||
projectName,
|
||||
expiresAt: apiKey.expiresAt
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore errors, just don't add key info
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`[${new Date().toISOString()}] API info requested`);
|
||||
res.json(info);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,11 +40,8 @@ export class MinioStorageService implements StorageService {
|
|||
category: 'uploads' | 'generated' | 'references',
|
||||
filename: string
|
||||
): string {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
|
||||
return `${orgId}/${projectId}/${category}/${year}-${month}/${filename}`;
|
||||
// Simplified path without date folder for now
|
||||
return `${orgId}/${projectId}/${category}/${filename}`;
|
||||
}
|
||||
|
||||
private generateUniqueFilename(originalFilename: string): string {
|
||||
|
|
|
|||
|
|
@ -69,14 +69,21 @@ export default function DemoTTIPage() {
|
|||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setApiKeyValidated(true);
|
||||
// Try to extract org/project info if available
|
||||
// For now, we'll set placeholder - this would come from API response
|
||||
// Extract org/project info from API response
|
||||
if (data.keyInfo) {
|
||||
setApiKeyInfo({
|
||||
organizationName: 'Your Organization',
|
||||
projectName: 'Your Project',
|
||||
organizationName: data.keyInfo.organizationName || data.keyInfo.organizationId,
|
||||
projectName: data.keyInfo.projectName || data.keyInfo.projectId,
|
||||
});
|
||||
} else {
|
||||
setApiKeyInfo({
|
||||
organizationName: 'Unknown',
|
||||
projectName: 'Unknown',
|
||||
});
|
||||
}
|
||||
} else{
|
||||
const error = await response.json();
|
||||
setApiKeyError(error.message || 'Invalid API key');
|
||||
setApiKeyValidated(false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue