Deskripsi: - list data konfigurasi api - edit data konfigurasi api - integrasi api No Issues
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import Elysia, { t } from "elysia";
|
|
import { prisma } from "../lib/prisma";
|
|
|
|
const ConfigurationDesaRoute = new Elysia({
|
|
prefix: "configuration-desa",
|
|
tags: ["configuration-desa"],
|
|
})
|
|
|
|
.get("/list", async () => {
|
|
const data = await prisma.configuration.findMany({
|
|
orderBy: {
|
|
name: "asc"
|
|
}
|
|
})
|
|
|
|
return data
|
|
}, {
|
|
detail: {
|
|
summary: "List Konfigurasi",
|
|
description: `tool untuk mendapatkan list konfigurasi`,
|
|
}
|
|
})
|
|
.post("/edit", async ({ body }) => {
|
|
const { id, value } = body
|
|
|
|
await prisma.configuration.update({
|
|
where: {
|
|
id,
|
|
},
|
|
data: {
|
|
value,
|
|
}
|
|
})
|
|
|
|
return { success: true, message: 'konfigurasi sudah diperbarui' }
|
|
}, {
|
|
body: t.Object({
|
|
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
|
value: t.String({ minLength: 1, error: "value harus diisi" }),
|
|
}),
|
|
detail: {
|
|
summary: "edit konfigurasi desa",
|
|
description: `tool untuk edit konfigurasi desa`
|
|
}
|
|
})
|
|
;
|
|
|
|
export default ConfigurationDesaRoute
|