- Update schema: add images relation list and linkVideo field - API: support multiple image upload and YouTube link in create/update - Admin create page: add gallery upload (max 10) and YouTube embed preview - Admin edit page: manage existing/new gallery images and YouTube link - Admin detail page: display gallery grid and YouTube video embed - Public detail page: show gallery images and YouTube video with responsive layout - State: add imageIds[] and linkVideo fields with proper type handling - Music player: fix seek functionality and ESLint warnings Breaking changes: - Prisma schema updated - requires migration - API create/update endpoints now expect imageIds array and linkVideo string Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import Elysia, { t } from "elysia";
|
|
import beritaFindMany from "./find-many";
|
|
import beritaCreate from "./create";
|
|
import beritaDelete from "./del";
|
|
import beritaUpdate from "./updt";
|
|
import findBeritaById from "./find-by-id";
|
|
import beritaFindFirst from "./findFirst";
|
|
import findRecentBerita from "./findRecent";
|
|
|
|
const Berita = new Elysia({ prefix: "/berita", tags: ["Desa/Berita"] })
|
|
.get("/find-many", beritaFindMany)
|
|
.get("/find-many-ui", beritaFindMany)
|
|
.get("/:id", async (context) => {
|
|
const response = await findBeritaById(new Request(context.request));
|
|
return response;
|
|
})
|
|
.post("/create", beritaCreate, {
|
|
body: t.Object({
|
|
judul: t.String(),
|
|
deskripsi: t.String(),
|
|
imageId: t.String(),
|
|
content: t.String(),
|
|
kategoriBeritaId: t.Union([t.String(), t.Null()]),
|
|
imageIds: t.Array(t.String()),
|
|
linkVideo: t.Optional(t.String()),
|
|
}),
|
|
})
|
|
.get("/find-first", beritaFindFirst)
|
|
.get("/find-recent", findRecentBerita)
|
|
.delete("/delete/:id", beritaDelete)
|
|
.put(
|
|
"/:id",
|
|
async (context) => {
|
|
const response = await beritaUpdate(context);
|
|
return response;
|
|
},
|
|
{
|
|
body: t.Object({
|
|
judul: t.String(),
|
|
deskripsi: t.String(),
|
|
imageId: t.String(),
|
|
content: t.String(),
|
|
kategoriBeritaId: t.Union([t.String(), t.Null()]),
|
|
imageIds: t.Array(t.String()),
|
|
linkVideo: t.Optional(t.String()),
|
|
}),
|
|
}
|
|
);
|
|
|
|
|
|
export default Berita;
|