Track uploads util; ignore only runtime /uploads directory.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+2
-2
@@ -18,8 +18,8 @@ prisma/dev.db-journal
|
|||||||
# local runtime toggles
|
# local runtime toggles
|
||||||
data/
|
data/
|
||||||
|
|
||||||
# uploaded tenant assets
|
# uploaded tenant assets (runtime dir at repo root — keep src/uploads source tracked)
|
||||||
uploads/
|
/uploads/
|
||||||
|
|
||||||
# logs & ide
|
# logs & ide
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { existsSync, mkdirSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
export const UPLOADS_ROOT = join(process.cwd(), 'uploads');
|
||||||
|
export const AVATARS_DIR = join(UPLOADS_ROOT, 'avatars');
|
||||||
|
|
||||||
|
export function ensureUploadsDirs() {
|
||||||
|
if (!existsSync(AVATARS_DIR)) {
|
||||||
|
mkdirSync(AVATARS_DIR, { recursive: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function publicApiBase(config: {
|
||||||
|
get: (key: string, defaultValue?: string) => string | undefined;
|
||||||
|
}): string {
|
||||||
|
const fromEnv = config.get('PUBLIC_API_URL')?.replace(/\/$/, '');
|
||||||
|
if (fromEnv) return fromEnv;
|
||||||
|
const port = config.get('PORT', '3001') ?? '3001';
|
||||||
|
return `http://localhost:${port}`;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user