x
This commit is contained in:
1 parent
406cad801b
commit
a2da091b15
21 files changed
+2454
-63
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { Elysia, t } from "elysia";
|
||||
import prisma from "../lib/prisma";
|
||||
import { LocalizedStringSchema, HeroSectionPayloadSchema, CategoriesSectionPayloadSchema, ProductsSectionPayloadSchema, BannerSectionPayloadSchema, TextSectionPayloadSchema, AnnouncementBarSectionPayloadSchema, NewsletterSectionPayloadSchema, EditorialTileSectionPayloadSchema, EditorialCarouselSectionPayloadSchema, HeroArticleSectionPayloadSchema, RichTextSectionPayloadSchema, ScentNotesBreakdownSectionPayloadSchema, QuoteCalloutSectionPayloadSchema, ProductCarouselSectionPayloadSchema, AccordionSectionPayloadSchema, ContactInfoSectionPayloadSchema, ContactFormSectionPayloadSchema, } from "@homaroma/types";
|
||||
import { LocalizedStringSchema, HeroSectionPayloadSchema, CategoriesSectionPayloadSchema, ProductsSectionPayloadSchema, BannerSectionPayloadSchema, TextSectionPayloadSchema, AnnouncementBarSectionPayloadSchema, NewsletterSectionPayloadSchema, EditorialTileSectionPayloadSchema, FeaturedTilesSectionPayloadSchema, EditorialCarouselSectionPayloadSchema, HeroArticleSectionPayloadSchema, RichTextSectionPayloadSchema, ScentNotesBreakdownSectionPayloadSchema, QuoteCalloutSectionPayloadSchema, ProductCarouselSectionPayloadSchema, AccordionSectionPayloadSchema, ContactInfoSectionPayloadSchema, ContactFormSectionPayloadSchema, HeroV2SectionPayloadSchema, HeroVideoSectionPayloadSchema, UspBarSectionPayloadSchema, CustomSectionPayloadSchema } from "@homaroma/types";
|
||||
import { z } from "zod";
|
||||
import { adminOnly } from "../middleware/auth";
|
||||
const RESERVED_SLUGS = [
|
||||
@@ -487,6 +487,9 @@ function validateSectionPayload(type, payload) {
|
||||
case "EDITORIAL_TILE":
|
||||
schema = EditorialTileSectionPayloadSchema;
|
||||
break;
|
||||
case "FEATURED_TILES":
|
||||
schema = FeaturedTilesSectionPayloadSchema;
|
||||
break;
|
||||
case "EDITORIAL_CAROUSEL":
|
||||
schema = EditorialCarouselSectionPayloadSchema;
|
||||
break;
|
||||
@@ -508,8 +511,11 @@ function validateSectionPayload(type, payload) {
|
||||
case "ACCORDION":
|
||||
schema = AccordionSectionPayloadSchema;
|
||||
break;
|
||||
case "CONTACT_INFO":
|
||||
schema = ContactInfoSectionPayloadSchema;
|
||||
case "HERO_V2":
|
||||
schema = HeroV2SectionPayloadSchema;
|
||||
break;
|
||||
case "HERO_VIDEO":
|
||||
schema = HeroVideoSectionPayloadSchema;
|
||||
break;
|
||||
case "CONTACT_FORM":
|
||||
schema = ContactFormSectionPayloadSchema;
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
AnnouncementBarSectionPayloadSchema,
|
||||
NewsletterSectionPayloadSchema,
|
||||
EditorialTileSectionPayloadSchema,
|
||||
FeaturedTilesSectionPayloadSchema,
|
||||
EditorialCarouselSectionPayloadSchema,
|
||||
HeroArticleSectionPayloadSchema,
|
||||
RichTextSectionPayloadSchema,
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
ContactInfoSectionPayloadSchema,
|
||||
ContactFormSectionPayloadSchema,
|
||||
HeroV2SectionPayloadSchema,
|
||||
HeroVideoSectionPayloadSchema,
|
||||
UspBarSectionPayloadSchema,
|
||||
CustomSectionPayloadSchema,
|
||||
PAGE_SECTION_LOCALIZED_PATHS,
|
||||
@@ -1098,6 +1100,9 @@ export function validateSectionPayload(
|
||||
case "EDITORIAL_TILE":
|
||||
schema = EditorialTileSectionPayloadSchema;
|
||||
break;
|
||||
case "FEATURED_TILES":
|
||||
schema = FeaturedTilesSectionPayloadSchema;
|
||||
break;
|
||||
case "EDITORIAL_CAROUSEL":
|
||||
schema = EditorialCarouselSectionPayloadSchema;
|
||||
break;
|
||||
@@ -1162,6 +1167,9 @@ export function validateSectionPayload(
|
||||
case "HERO_V2":
|
||||
schema = HeroV2SectionPayloadSchema;
|
||||
break;
|
||||
case "HERO_VIDEO":
|
||||
schema = HeroVideoSectionPayloadSchema;
|
||||
break;
|
||||
case "USP_BAR":
|
||||
schema = UspBarSectionPayloadSchema;
|
||||
break;
|
||||
|
||||
@@ -11,9 +11,9 @@ export const uploadRoute = new Elysia({ prefix: "/upload" })
|
||||
return { error: "No file uploaded" };
|
||||
}
|
||||
// Validate file type
|
||||
if (!file.type.startsWith("image/")) {
|
||||
if (!file.type.startsWith("image/") && !file.type.startsWith("video/")) {
|
||||
set.status = 400;
|
||||
return { error: "Only image files are allowed" };
|
||||
return { error: "Only image and video files are allowed" };
|
||||
}
|
||||
console.log(`[Upload] Processing: ${file.name} (${(file.size / 1024).toFixed(2)} KB, ${file.type})`);
|
||||
// Generate unique filename
|
||||
|
||||
@@ -14,9 +14,9 @@ export const uploadRoute = new Elysia({ prefix: "/upload" })
|
||||
}
|
||||
|
||||
// Validate file type
|
||||
if (!file.type.startsWith("image/")) {
|
||||
if (!file.type.startsWith("image/") && !file.type.startsWith("video/")) {
|
||||
set.status = 400;
|
||||
return { error: "Only image files are allowed" };
|
||||
return { error: "Only image and video files are allowed" };
|
||||
}
|
||||
|
||||
console.log(`[Upload] Processing: ${file.name} (${(file.size / 1024).toFixed(2)} KB, ${file.type})`);
|
||||
@@ -66,12 +66,15 @@ export const uploadRoute = new Elysia({ prefix: "/upload" })
|
||||
}, {
|
||||
body: t.Object({
|
||||
file: t.File({
|
||||
maxSize: '5m',
|
||||
type: ['image/jpeg', 'image/png', 'image/webp', 'image/gif']
|
||||
maxSize: '100m',
|
||||
type: [
|
||||
'image/jpeg', 'image/png', 'image/webp', 'image/gif',
|
||||
'video/mp4', 'video/webm', 'video/ogg', 'video/quicktime'
|
||||
]
|
||||
})
|
||||
}),
|
||||
detail: {
|
||||
summary: "Upload product image",
|
||||
summary: "Upload product image or video",
|
||||
tags: ["upload"]
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user