events and gallery backend fix
@ -94,7 +94,7 @@ const eventsRoute: FastifyPluginAsync = async (fastify) => {
|
|||||||
|
|
||||||
// Prepare directories - use persistent volume for Fly.io
|
// Prepare directories - use persistent volume for Fly.io
|
||||||
const dataDir = process.env.GIT_WORKSPACE_DIR || path.join(process.cwd(), 'data');
|
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 });
|
if (!fs.existsSync(uploadDir)) fs.mkdirSync(uploadDir, { recursive: true });
|
||||||
|
|
||||||
// Read uploaded stream into buffer
|
// Read uploaded stream into buffer
|
||||||
@ -133,7 +133,7 @@ const eventsRoute: FastifyPluginAsync = async (fastify) => {
|
|||||||
fs.writeFileSync(destPath, outBuffer);
|
fs.writeFileSync(destPath, outBuffer);
|
||||||
|
|
||||||
// Public URL (served via /static)
|
// Public URL (served via /static)
|
||||||
const publicUrl = `/static/images/events/${filename}`;
|
const publicUrl = `/images/events/${filename}`;
|
||||||
|
|
||||||
return reply.code(201).send({ imageUrl: publicUrl });
|
return reply.code(201).send({ imageUrl: publicUrl });
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ const galleryRoute: FastifyPluginAsync = async (fastify) => {
|
|||||||
|
|
||||||
// Prepare directories - use persistent volume for Fly.io
|
// Prepare directories - use persistent volume for Fly.io
|
||||||
const dataDir = process.env.GIT_WORKSPACE_DIR || path.join(process.cwd(), 'data');
|
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 });
|
if (!fs.existsSync(uploadDir)) fs.mkdirSync(uploadDir, { recursive: true });
|
||||||
|
|
||||||
// Read uploaded stream into buffer
|
// Read uploaded stream into buffer
|
||||||
@ -125,7 +125,7 @@ const galleryRoute: FastifyPluginAsync = async (fastify) => {
|
|||||||
fs.writeFileSync(destPath, outBuffer);
|
fs.writeFileSync(destPath, outBuffer);
|
||||||
|
|
||||||
// Public URL (served via /static)
|
// Public URL (served via /static)
|
||||||
const publicUrl = `/static/images/gallery/${filename}`;
|
const publicUrl = `/images/gallery/${filename}`;
|
||||||
|
|
||||||
// Store in DB (optional but useful)
|
// Store in DB (optional but useful)
|
||||||
const [row] = await db.insert(galleryImages).values({
|
const [row] = await db.insert(galleryImages).values({
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 800 KiB |
|
Before Width: | Height: | Size: 747 KiB |
|
Before Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 567 KiB |
|
Before Width: | Height: | Size: 800 KiB |
|
Before Width: | Height: | Size: 523 KiB |