Fix Eror Admin Persentase & Grafik
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.DoctorSignGetPayload<{
|
||||
select: {
|
||||
content: true;
|
||||
}
|
||||
}>
|
||||
|
||||
export default async function doctorSignCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
await prisma.doctorSign.create({
|
||||
data: {
|
||||
content: body.content,
|
||||
},
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create doctor sign",
|
||||
data: {
|
||||
...body,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function doctorSignFindMany() {
|
||||
const data = await prisma.doctorSign.findMany();
|
||||
return {
|
||||
success: true,
|
||||
message: "Success get doctor sign",
|
||||
data,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import Elysia, { t } from "elysia"
|
||||
import doctorSignCreate from "./create"
|
||||
import doctorSignFindMany from "./find-many"
|
||||
|
||||
const DoctorSign = new Elysia({
|
||||
prefix: "/doctor_sign",
|
||||
tags: ["Data Kesehatan/Artikel Kesehatan/Doctor Sign"],
|
||||
})
|
||||
.get("/find-many", doctorSignFindMany)
|
||||
.post("/create", doctorSignCreate, {
|
||||
body: t.Object({
|
||||
content: t.String(),
|
||||
}),
|
||||
})
|
||||
export default DoctorSign
|
||||
@@ -0,0 +1,27 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.FirstAidGetPayload<{
|
||||
select: {
|
||||
title: true;
|
||||
content: true;
|
||||
}
|
||||
}>
|
||||
export default async function firstAidCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
await prisma.firstAid.create({
|
||||
data: {
|
||||
title: body.title,
|
||||
content: body.content,
|
||||
},
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create first aid",
|
||||
data: {
|
||||
...body,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma"
|
||||
|
||||
export default async function firstAidFindMany() {
|
||||
const res = await prisma.firstAid.findMany()
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Elysia, { t } from "elysia"
|
||||
import firstAidCreate from "./create"
|
||||
import firstAidFindMany from "./find-many"
|
||||
|
||||
const FirstAid = new Elysia({
|
||||
prefix: "/firstaid",
|
||||
tags: ["Data Kesehatan/Artikel Kesehatan/First Aid"]
|
||||
})
|
||||
.get("/find-many", firstAidFindMany)
|
||||
.post("/create", firstAidCreate, {
|
||||
body: t.Object({
|
||||
title: t.String(),
|
||||
content: t.String(),
|
||||
}),
|
||||
})
|
||||
export default FirstAid
|
||||
@@ -0,0 +1,26 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.IntroductionGetPayload<{
|
||||
select: {
|
||||
content: true;
|
||||
};
|
||||
}>;
|
||||
|
||||
export default async function introductionCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
await prisma.introduction.create({
|
||||
data: {
|
||||
content: body.content,
|
||||
},
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create introduction",
|
||||
data: {
|
||||
...body,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function introductionFindMany() {
|
||||
const res = await prisma.introduction.findMany();
|
||||
return {
|
||||
data: res,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import introductionCreate from "./create";
|
||||
import introductionFindMany from "./find-many";
|
||||
|
||||
const Introduction = new Elysia({
|
||||
prefix: "/introduction",
|
||||
tags: ["Data Kesehatan/Artikel Kesehatan/Introduction"]
|
||||
})
|
||||
.get("/find-many", introductionFindMany)
|
||||
.post("/create", introductionCreate, {
|
||||
body: t.Object({
|
||||
content: t.String(),
|
||||
}),
|
||||
})
|
||||
|
||||
export default Introduction;
|
||||
@@ -0,0 +1,30 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
type FormCreate = Prisma.MythVsFactGetPayload<{
|
||||
select: {
|
||||
title: true;
|
||||
mitos: true;
|
||||
fakta: true;
|
||||
}
|
||||
}>
|
||||
|
||||
export default async function mythVsFactCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
await prisma.mythVsFact.create({
|
||||
data: {
|
||||
title: body.title,
|
||||
mitos: body.mitos,
|
||||
fakta: body.fakta,
|
||||
},
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create myth vs fact",
|
||||
data: {
|
||||
...body,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function mythVsFactFindMany() {
|
||||
const mythVsFacts = await prisma.mythVsFact.findMany();
|
||||
return {
|
||||
success: true,
|
||||
message: "Success get myth vs fact",
|
||||
data: mythVsFacts,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import mythVsFactCreate from "./create";
|
||||
import mythVsFactFindMany from "./find-many";
|
||||
|
||||
const MythVsFact = new Elysia({
|
||||
prefix: "/mythvsfact",
|
||||
tags: ["Data Kesehatan/Artikel Kesehatan/Myth vs Fact"]
|
||||
})
|
||||
.get("/find-many", mythVsFactFindMany)
|
||||
.post("/create", mythVsFactCreate, {
|
||||
body: t.Object({
|
||||
title: t.String(),
|
||||
mitos: t.String(),
|
||||
fakta: t.String(),
|
||||
}),
|
||||
})
|
||||
export default MythVsFact
|
||||
@@ -0,0 +1,28 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.PreventionGetPayload<{
|
||||
select: {
|
||||
title: true;
|
||||
content: true;
|
||||
}
|
||||
}>
|
||||
|
||||
export default async function preventionCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
await prisma.prevention.create({
|
||||
data: {
|
||||
title: body.title,
|
||||
content: body.content,
|
||||
},
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create prevention",
|
||||
data: {
|
||||
...body,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma"
|
||||
|
||||
export default async function preventionFindMany() {
|
||||
const res = await prisma.prevention.findMany()
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Elysia, { t } from "elysia"
|
||||
import preventionCreate from "./create"
|
||||
import preventionFindMany from "./find-many"
|
||||
|
||||
const Prevention = new Elysia({
|
||||
prefix: "/prevention",
|
||||
tags: ["Data Kesehatan/Artikel Kesehatan/Prevention"]
|
||||
})
|
||||
.get("/find-many", preventionFindMany)
|
||||
.post("/create", preventionCreate, {
|
||||
body: t.Object({
|
||||
title: t.String(),
|
||||
content: t.String(),
|
||||
}),
|
||||
})
|
||||
export default Prevention
|
||||
@@ -0,0 +1,27 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.SymptomGetPayload<{
|
||||
select: {
|
||||
title: true;
|
||||
content: true;
|
||||
}
|
||||
}>
|
||||
export default async function symptomCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
await prisma.symptom.create({
|
||||
data: {
|
||||
title: body.title,
|
||||
content: body.content,
|
||||
},
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create symptom",
|
||||
data: {
|
||||
...body,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import prisma from "@/lib/prisma"
|
||||
|
||||
export default async function symptomFindMany() {
|
||||
const res = await prisma.symptom.findMany()
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import symptomCreate from "./create";
|
||||
import symptomFindMany from "./find-many";
|
||||
|
||||
const Syptom = new Elysia({
|
||||
prefix: "/symptom",
|
||||
tags: ["Data Kesehatan/Artikel Kesehatan/Syptom"]
|
||||
})
|
||||
.get("/find-many", symptomFindMany)
|
||||
.post("/create", symptomCreate, {
|
||||
body: t.Object({
|
||||
title: t.String(),
|
||||
content: t.String(),
|
||||
}),
|
||||
})
|
||||
export default Syptom
|
||||
@@ -13,6 +13,12 @@ import DokumenDiperlukan from "./data_kesehatan_warga/jadwal_kegiatan/dokumen_ya
|
||||
import PendaftaranJadwal from "./data_kesehatan_warga/jadwal_kegiatan/pendaftaran";
|
||||
import PersentaseKelahiranKematian from "./data_kesehatan_warga/persentase_kelahiran_kematian";
|
||||
import GrafikKepuasan from "./data_kesehatan_warga/grafik_kepuasan";
|
||||
import Introduction from "./data_kesehatan_warga/artikel_kesehatan/introduction";
|
||||
import Syptom from "./data_kesehatan_warga/artikel_kesehatan/syptom";
|
||||
import Prevention from "./data_kesehatan_warga/artikel_kesehatan/prevention";
|
||||
import FirstAid from "./data_kesehatan_warga/artikel_kesehatan/first_aid";
|
||||
import MythVsFact from "./data_kesehatan_warga/artikel_kesehatan/myth_vs_fact";
|
||||
import DoctorSign from "./data_kesehatan_warga/artikel_kesehatan/doctor_sign";
|
||||
|
||||
|
||||
const Kesehatan = new Elysia({
|
||||
@@ -33,4 +39,10 @@ const Kesehatan = new Elysia({
|
||||
.use(PendaftaranJadwal)
|
||||
.use(PersentaseKelahiranKematian)
|
||||
.use(GrafikKepuasan)
|
||||
.use(Introduction)
|
||||
.use(Syptom)
|
||||
.use(Prevention)
|
||||
.use(FirstAid)
|
||||
.use(MythVsFact)
|
||||
.use(DoctorSign)
|
||||
export default Kesehatan;
|
||||
|
||||
@@ -45,11 +45,25 @@ async function layanan() {
|
||||
const data = await prisma.layanan.findMany();
|
||||
return { data };
|
||||
}
|
||||
|
||||
const Utils = new Elysia({
|
||||
prefix: "/api/utils",
|
||||
tags: ["Utils"],
|
||||
}).get("/version", async () => {
|
||||
const packageJson = await fs.readFile(
|
||||
path.join(ROOT, "package.json"),
|
||||
"utf-8"
|
||||
);
|
||||
const version = JSON.parse(packageJson).version;
|
||||
return { version };
|
||||
});
|
||||
|
||||
const ApiServer = new Elysia()
|
||||
.use(swagger({ path: "/api/docs" }))
|
||||
.use(cors(corsConfig))
|
||||
.use(Kesehatan)
|
||||
.use(Desa)
|
||||
.use(Utils)
|
||||
.onError(({ code }) => {
|
||||
if (code === "NOT_FOUND") {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user