events and gallery backend fix

This commit is contained in:
2025-12-09 19:25:17 +01:00
parent 5d0c0a0b17
commit 901223fcd9
11 changed files with 4 additions and 4 deletions

View File

@ -94,7 +94,7 @@ const eventsRoute: FastifyPluginAsync = async (fastify) => {
// Prepare directories - use persistent volume for Fly.io
const dataDir = process.env.GIT_WORKSPACE_DIR || path.join(process.cwd(), 'data');
const uploadDir = path.join(dataDir, 'images', 'events');
const uploadDir = path.join(dataDir, 'public', 'images', 'events');
if (!fs.existsSync(uploadDir)) fs.mkdirSync(uploadDir, { recursive: true });
// Read uploaded stream into buffer
@ -133,7 +133,7 @@ const eventsRoute: FastifyPluginAsync = async (fastify) => {
fs.writeFileSync(destPath, outBuffer);
// Public URL (served via /static)
const publicUrl = `/static/images/events/${filename}`;
const publicUrl = `/images/events/${filename}`;
return reply.code(201).send({ imageUrl: publicUrl });

View File

@ -86,7 +86,7 @@ const galleryRoute: FastifyPluginAsync = async (fastify) => {
// Prepare directories - use persistent volume for Fly.io
const dataDir = process.env.GIT_WORKSPACE_DIR || path.join(process.cwd(), 'data');
const uploadDir = path.join(dataDir, 'images', 'gallery');
const uploadDir = path.join(dataDir, 'public', 'images', 'gallery');
if (!fs.existsSync(uploadDir)) fs.mkdirSync(uploadDir, { recursive: true });
// Read uploaded stream into buffer
@ -125,7 +125,7 @@ const galleryRoute: FastifyPluginAsync = async (fastify) => {
fs.writeFileSync(destPath, outBuffer);
// Public URL (served via /static)
const publicUrl = `/static/images/gallery/${filename}`;
const publicUrl = `/images/gallery/${filename}`;
// Store in DB (optional but useful)
const [row] = await db.insert(galleryImages).values({