Compare commits
25 Commits
amalia/06-
...
2aaa44cf14
| Author | SHA1 | Date | |
|---|---|---|---|
| 2aaa44cf14 | |||
| fbf00a55da | |||
|
|
03955743ca | ||
|
|
cdd7c6fa2b | ||
|
|
c51dcfdad4 | ||
|
|
e68fe87e9e | ||
|
|
fca77c6bd8 | ||
| aa89a10aa8 | |||
| 21af3e3310 | |||
| 08faa9f6b0 | |||
| b101c63f8d | |||
| 41820ff2b3 | |||
| 9c045f32ea | |||
| 6dd8dcd06e | |||
| f79629e97e | |||
| b52bb57fbc | |||
| 401f8f13a2 | |||
| 7b0d4e5d30 | |||
| 5c71d000f6 | |||
| 621cfc931a | |||
| 928ecb4c76 | |||
| 0ac649345d | |||
| e0456b2dba | |||
| 14ec81d98d | |||
| 0e5fab6a84 |
@@ -1,28 +1,30 @@
|
||||
// ⚡ Auto-generated by generateRoutes.ts — DO NOT EDIT MANUALLY
|
||||
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
||||
import DarmasabaHome from "./pages/darmasaba/darmasaba_home";
|
||||
import DarmasabaLayout from "./pages/darmasaba/darmasaba_layout";
|
||||
import FormKartuKeluarga from "./pages/darmasaba/form_kartu_keluarga";
|
||||
import FormKartuTandaPenduduk from "./pages/darmasaba/form_kartu_tanda_penduduk";
|
||||
import FormKeteranganKelahiran from "./pages/darmasaba/form_keterangan_kelahiran";
|
||||
import FormLaporanSampah from "./pages/darmasaba/form_laporan_sampah";
|
||||
import FormSuratKeteranganBelumKawin from "./pages/darmasaba/form_surat_keterangan_belum_kawin";
|
||||
import FormSuratKeteranganDomisiliOrganisasi from "./pages/darmasaba/form_surat_keterangan_domisili_organisasi";
|
||||
import FormSuratKeteranganKelakuanBaik from "./pages/darmasaba/form_surat_keterangan_kelakuan_baik";
|
||||
import FormSuratKeteranganPenghasilan from "./pages/darmasaba/form_surat_keterangan_penghasilan";
|
||||
import FormSuratKeteranganTempatUsaha from "./pages/darmasaba/form_surat_keterangan_tempat_usaha";
|
||||
import FormSuratKeteranganTidakMampu from "./pages/darmasaba/form_surat_keterangan_tidak_mampu";
|
||||
import FormSuratKeteranganUsaha from "./pages/darmasaba/form_surat_keterangan_usaha";
|
||||
import DirPage from "./pages/dir/dir_page";
|
||||
import Home from "./pages/Home";
|
||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
||||
import Login from "./pages/Login";
|
||||
import NotFound from "./pages/NotFound";
|
||||
import ApikeyPage from "./pages/scr/dashboard/apikey/apikey_page";
|
||||
import DarmasabaLayout from "./pages/darmasaba/darmasaba_layout";
|
||||
import FormSuratKeteranganUsaha from "./pages/darmasaba/form_surat_keterangan_usaha";
|
||||
import FormSuratKeteranganTidakMampu from "./pages/darmasaba/form_surat_keterangan_tidak_mampu";
|
||||
import DarmasabaHome from "./pages/darmasaba/darmasaba_home";
|
||||
import FormKartuTandaPenduduk from "./pages/darmasaba/form_kartu_tanda_penduduk";
|
||||
import FormKartuKeluarga from "./pages/darmasaba/form_kartu_keluarga";
|
||||
import FormLaporanSampah from "./pages/darmasaba/form_laporan_sampah";
|
||||
import FormSuratKeteranganPenghasilan from "./pages/darmasaba/form_surat_keterangan_penghasilan";
|
||||
import FormSuratKeteranganDomisiliOrganisasi from "./pages/darmasaba/form_surat_keterangan_domisili_organisasi";
|
||||
import FormSuratKeteranganBelumKawin from "./pages/darmasaba/form_surat_keterangan_belum_kawin";
|
||||
import FormKeteranganKelahiran from "./pages/darmasaba/form_keterangan_kelahiran";
|
||||
import FormSuratKeteranganTempatUsaha from "./pages/darmasaba/form_surat_keterangan_tempat_usaha";
|
||||
import FormSuratKeteranganKelakuanBaik from "./pages/darmasaba/form_surat_keterangan_kelakuan_baik";
|
||||
import Home from "./pages/Home";
|
||||
import CredentialPage from "./pages/scr/dashboard/credential/credential_page";
|
||||
import DashboardHome from "./pages/scr/dashboard/dashboard_home";
|
||||
import DashboardLayout from "./pages/scr/dashboard/dashboard_layout";
|
||||
import ListPelayananPage from "./pages/scr/dashboard/pelayanan-surat/list_pelayanan_page";
|
||||
import ListPage from "./pages/scr/dashboard/pengaduan/list_page";
|
||||
import DetailPage from "./pages/scr/dashboard/pengaduan/detail_page";
|
||||
import ApikeyPage from "./pages/scr/dashboard/apikey/apikey_page";
|
||||
import DashboardLayout from "./pages/scr/dashboard/dashboard_layout";
|
||||
import ScrLayout from "./pages/scr/scr_layout";
|
||||
import DirPage from "./pages/dir/dir_page";
|
||||
import NotFound from "./pages/NotFound";
|
||||
|
||||
export default function AppRoutes() {
|
||||
return (
|
||||
@@ -93,10 +95,18 @@ export default function AppRoutes() {
|
||||
path="/scr/dashboard/dashboard-home"
|
||||
element={<DashboardHome />}
|
||||
/>
|
||||
<Route
|
||||
path="/scr/dashboard/pelayanan-surat/list-pelayanan"
|
||||
element={<ListPelayananPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/scr/dashboard/pengaduan/list"
|
||||
element={<ListPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/scr/dashboard/pengaduan/detail"
|
||||
element={<DetailPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/scr/dashboard/apikey/apikey"
|
||||
element={<ApikeyPage />}
|
||||
|
||||
@@ -19,7 +19,9 @@ const clientRoutes = {
|
||||
"/scr/dashboard": "/scr/dashboard",
|
||||
"/scr/dashboard/credential/credential": "/scr/dashboard/credential/credential",
|
||||
"/scr/dashboard/dashboard-home": "/scr/dashboard/dashboard-home",
|
||||
"/scr/dashboard/pelayanan-surat/list-pelayanan": "/scr/dashboard/pelayanan-surat/list-pelayanan",
|
||||
"/scr/dashboard/pengaduan/list": "/scr/dashboard/pengaduan/list",
|
||||
"/scr/dashboard/pengaduan/detail": "/scr/dashboard/pengaduan/detail",
|
||||
"/scr/dashboard/apikey/apikey": "/scr/dashboard/apikey/apikey",
|
||||
"/dir/dir": "/dir/dir",
|
||||
"/*": "/*"
|
||||
|
||||
@@ -12,7 +12,9 @@ import LayananRoute from "./server/routes/layanan_route";
|
||||
import { MCPRoute } from "./server/routes/mcp_route";
|
||||
import PelayananRoute from "./server/routes/pelayanan_surat_route";
|
||||
import PengaduanRoute from "./server/routes/pengaduan_route";
|
||||
import TestRoute from "./server/routes/test";
|
||||
import UserRoute from "./server/routes/user_route";
|
||||
import cors from "@elysiajs/cors";
|
||||
|
||||
const Docs = new Elysia({
|
||||
tags: ["docs"],
|
||||
@@ -28,6 +30,7 @@ const Api = new Elysia({
|
||||
})
|
||||
.use(PengaduanRoute)
|
||||
.use(PelayananRoute)
|
||||
.use(TestRoute)
|
||||
.use(apiAuth)
|
||||
.use(ApiKeyRoute)
|
||||
.use(DarmasabaRoute)
|
||||
@@ -40,6 +43,13 @@ const app = new Elysia()
|
||||
.use(Api)
|
||||
.use(Docs)
|
||||
.use(Auth)
|
||||
.use(
|
||||
cors({
|
||||
origin: "*",
|
||||
methods: ["GET", "POST", "OPTIONS"],
|
||||
allowedHeaders: ["Content-Type"],
|
||||
}),
|
||||
)
|
||||
.get(
|
||||
"/.well-known/mcp.json",
|
||||
async () => {
|
||||
|
||||
@@ -230,7 +230,7 @@ function NavigationDashboard() {
|
||||
description: "Manage pengaduan warga",
|
||||
},
|
||||
{
|
||||
path: "/scr/dashboard/pelayanan",
|
||||
path: "/scr/dashboard/pelayanan-surat/list-pelayanan",
|
||||
icon: <IconFileCertificate size={20} />,
|
||||
label: "Pelayanan Surat",
|
||||
description: "Manage pelayanan surat",
|
||||
|
||||
271
src/pages/scr/dashboard/pelayanan-surat/list_pelayanan_page.tsx
Normal file
271
src/pages/scr/dashboard/pelayanan-surat/list_pelayanan_page.tsx
Normal file
@@ -0,0 +1,271 @@
|
||||
import apiFetch from "@/lib/apiFetch";
|
||||
import {
|
||||
Badge,
|
||||
Card,
|
||||
CloseButton,
|
||||
Container,
|
||||
Divider,
|
||||
Flex,
|
||||
Group,
|
||||
Input,
|
||||
Stack,
|
||||
Tabs,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconAlignJustified,
|
||||
IconClockHour3,
|
||||
IconFileSad,
|
||||
IconMapPin,
|
||||
IconSearch,
|
||||
} from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import useSwr from "swr";
|
||||
import { proxy } from "valtio";
|
||||
|
||||
const state = proxy({ reload: "" });
|
||||
function reloadState() {
|
||||
state.reload = Math.random().toString();
|
||||
}
|
||||
|
||||
export default function PelayananSuratListPage() {
|
||||
const { search } = useLocation();
|
||||
const query = new URLSearchParams(search);
|
||||
const status = query.get("status") as StatusKey;
|
||||
|
||||
return (
|
||||
<Container size="xl" py="xl" w={"100%"}>
|
||||
<Stack gap="xl">
|
||||
<TabListPelayananSurat status={status || "semua"} />
|
||||
<ListPelayananSurat status={status || "semua"} />
|
||||
</Stack>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
function TabListPelayananSurat({ status }: { status: string }) {
|
||||
const navigate = useNavigate();
|
||||
const dataCount = useSwr("/pelayanan-surat/count", () =>
|
||||
apiFetch.api.pengaduan.count.get().then((res) => res.data),
|
||||
);
|
||||
|
||||
return (
|
||||
<Tabs defaultValue={status || "semua"} color="teal">
|
||||
<Tabs.List grow>
|
||||
<Tabs.Tab
|
||||
value="all"
|
||||
onClick={() => {
|
||||
navigate("?status=semua");
|
||||
}}
|
||||
>
|
||||
Semua ({dataCount?.data?.semua || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="antrian"
|
||||
onClick={() => {
|
||||
navigate("?status=antrian");
|
||||
}}
|
||||
>
|
||||
Antrian ({dataCount?.data?.antrian || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="diterima"
|
||||
onClick={() => {
|
||||
navigate("?status=diterima");
|
||||
}}
|
||||
>
|
||||
Diterima ({dataCount?.data?.diterima || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="dikerjakan"
|
||||
onClick={() => {
|
||||
navigate("?status=dikerjakan");
|
||||
}}
|
||||
>
|
||||
Dikerjakan ({dataCount?.data?.dikerjakan || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="selesai"
|
||||
onClick={() => {
|
||||
navigate("?status=selesai");
|
||||
}}
|
||||
>
|
||||
Selesai ({dataCount?.data?.selesai || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="ditolak"
|
||||
onClick={() => {
|
||||
navigate("?status=ditolak");
|
||||
}}
|
||||
>
|
||||
Ditolak ({dataCount?.data?.ditolak || 0})
|
||||
</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
|
||||
type StatusKey =
|
||||
| "antrian"
|
||||
| "diterima"
|
||||
| "dikerjakan"
|
||||
| "ditolak"
|
||||
| "selesai"
|
||||
| "semua";
|
||||
function ListPelayananSurat({ status }: { status: StatusKey }) {
|
||||
const [page, setPage] = useState(1);
|
||||
const [value, setValue] = useState("");
|
||||
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||
apiFetch.api.pengaduan.list.get({
|
||||
query: {
|
||||
status,
|
||||
search: value,
|
||||
take: "",
|
||||
page: "",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
useShallowEffect(() => {
|
||||
mutate();
|
||||
}, [status, value]);
|
||||
|
||||
if (isLoading)
|
||||
return (
|
||||
<Card
|
||||
radius="lg"
|
||||
p="xl"
|
||||
withBorder
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||
}}
|
||||
>
|
||||
<Text size="sm" c="dimmed">
|
||||
Loading pengaduan...
|
||||
</Text>
|
||||
</Card>
|
||||
);
|
||||
|
||||
const list = data?.data || [];
|
||||
|
||||
return (
|
||||
<Stack gap="xl">
|
||||
<Group grow>
|
||||
<Input
|
||||
value={value}
|
||||
placeholder="Cari pengaduan..."
|
||||
onChange={(event) => setValue(event.currentTarget.value)}
|
||||
leftSection={<IconSearch size={16} />}
|
||||
rightSectionPointerEvents="all"
|
||||
rightSection={
|
||||
<CloseButton
|
||||
aria-label="Clear input"
|
||||
onClick={() => setValue("")}
|
||||
style={{ display: value ? undefined : "none" }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* <Group justify="flex-end">
|
||||
<Text size="sm">Menampilkan {Number(data?.data?.length) * (page - 1) + 1} – {Math.min(10, Number(data?.data?.length) * page)} dari {Number(data?.data?.length)}</Text>
|
||||
<Pagination total={Number(data?.data?.length)} value={page} onChange={setPage} withPages={false} />
|
||||
</Group> */}
|
||||
</Group>
|
||||
{list.length === 0 ? (
|
||||
<Flex justify="center" align="center" py={"xl"}>
|
||||
<Stack gap={4} align="center">
|
||||
<IconFileSad size={32} color="gray" />
|
||||
<Text c="dimmed" size="sm">
|
||||
No pengaduan have been added yet.
|
||||
</Text>
|
||||
</Stack>
|
||||
</Flex>
|
||||
) : (
|
||||
list.map((v: any) => (
|
||||
<Card
|
||||
key={v.id}
|
||||
radius="lg"
|
||||
p="xl"
|
||||
withBorder
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||
borderColor: "rgba(100,100,100,0.2)",
|
||||
boxShadow: "0 0 20px rgba(0,255,200,0.08)",
|
||||
}}
|
||||
>
|
||||
<Stack gap="md">
|
||||
<Flex align="center" justify="space-between">
|
||||
<Flex direction={"column"}>
|
||||
<Title order={3} c="gray.2">
|
||||
{v.title}
|
||||
</Title>
|
||||
<Group>
|
||||
<Title order={6} c="gray.5">
|
||||
#{v.noPengaduan}
|
||||
</Title>
|
||||
<Text size="sm" c="dimmed">
|
||||
{v.updatedAt}
|
||||
</Text>
|
||||
</Group>
|
||||
</Flex>
|
||||
<Badge
|
||||
size="xl"
|
||||
variant="light"
|
||||
radius="sm"
|
||||
color={
|
||||
v.status === "diterima"
|
||||
? "green"
|
||||
: v.status === "ditolak"
|
||||
? "red"
|
||||
: v.status === "selesai"
|
||||
? "blue"
|
||||
: v.status === "dikerjakan"
|
||||
? "purple"
|
||||
: "yellow"
|
||||
}
|
||||
style={{ textTransform: "none" }}
|
||||
>
|
||||
{v.status}
|
||||
</Badge>
|
||||
</Flex>
|
||||
<Divider my={0} />
|
||||
<Stack gap="sm">
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconClockHour3 size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Tanggal Aduan
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">{v.createdAt}</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconMapPin size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Lokasi
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">{v.location}</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconAlignJustified size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Detail
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">{v.detail}</Text>
|
||||
</Flex>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Card>
|
||||
))
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
301
src/pages/scr/dashboard/pengaduan/detail_page.tsx
Normal file
301
src/pages/scr/dashboard/pengaduan/detail_page.tsx
Normal file
@@ -0,0 +1,301 @@
|
||||
import apiFetch from "@/lib/apiFetch";
|
||||
import {
|
||||
Anchor,
|
||||
Badge,
|
||||
Card,
|
||||
Container,
|
||||
Divider,
|
||||
Flex,
|
||||
Grid,
|
||||
Group,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Title
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconAlignJustified,
|
||||
IconCategory,
|
||||
IconFileCertificate,
|
||||
IconInfoTriangle,
|
||||
IconMapPin,
|
||||
IconMessageReport,
|
||||
IconPhotoScan,
|
||||
IconUser
|
||||
} from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import useSwr from "swr";
|
||||
|
||||
export default function DetailPengaduanPage() {
|
||||
const { search } = useLocation();
|
||||
const query = new URLSearchParams(search);
|
||||
const id = query.get("id");
|
||||
|
||||
return (
|
||||
<Container size="xl" py="xl" w={"100%"}>
|
||||
<Grid>
|
||||
<Grid.Col span={8}>
|
||||
<Stack gap={"xl"}>
|
||||
<DetailDataPengaduan />
|
||||
<DetailDataHistori />
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={4}>
|
||||
<DetailUserPengaduan />
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
function DetailDataPengaduan() {
|
||||
return (
|
||||
<Card
|
||||
radius="md"
|
||||
p="lg"
|
||||
withBorder
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||
borderColor: "rgba(100,100,100,0.2)",
|
||||
boxShadow: "0 0 20px rgba(0,255,200,0.08)",
|
||||
}}
|
||||
>
|
||||
<Stack gap={"md"}>
|
||||
<Flex align="center" justify="space-between">
|
||||
<Group gap="xs">
|
||||
<Title order={4} c="gray.2">
|
||||
Pengaduan
|
||||
</Title>
|
||||
<Title order={4} c="dimmed">
|
||||
#PGf-2345-33
|
||||
</Title>
|
||||
</Group>
|
||||
<Badge
|
||||
size="xl"
|
||||
variant="light"
|
||||
radius="sm"
|
||||
color={"yellow"}
|
||||
style={{ textTransform: "none" }}
|
||||
>
|
||||
antrian
|
||||
</Badge>
|
||||
</Flex>
|
||||
<Divider my={0} />
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Stack gap="md">
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconAlignJustified size={20} />
|
||||
<Text size="md">
|
||||
Judul
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c={"white"}>Judul Pengaduan</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconMapPin size={20} />
|
||||
<Text size="md">
|
||||
Lokasi
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c="white">fwef</Text>
|
||||
</Flex>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Stack gap="md">
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconCategory size={20} />
|
||||
<Text size="md">
|
||||
Kategori
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c="white">fwef</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconPhotoScan size={20} />
|
||||
<Text size="md">
|
||||
Gambar
|
||||
</Text>
|
||||
</Group>
|
||||
<Anchor href="https://mantine.dev/" target="_blank">
|
||||
Lihat Gambar
|
||||
</Anchor>
|
||||
</Flex>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={12}>
|
||||
<Stack gap="md">
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconAlignJustified size={20} />
|
||||
<Text size="md">
|
||||
Detail
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c="white">
|
||||
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Illum, corporis iusto. Suscipit veritatis quas, non nobis fuga, laudantium accusantium tempora sint aliquid architecto totam esse eum excepturi nostrum fugiat ut.
|
||||
</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconInfoTriangle size={20} />
|
||||
<Text size="md">
|
||||
Keterangan
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c={"white"}>
|
||||
Lorem ipsum dolor, sit amet consectetur adipisicing elit. At fugiat eligendi nesciunt dolore? Maiores a cumque vitae suscipit incidunt quos beatae modi, vel, id ullam quae voluptas, deserunt quas placeat.
|
||||
</Text>
|
||||
</Flex>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function DetailDataHistori() {
|
||||
const elements = [
|
||||
{ position: 6, mass: 12.011, symbol: 'C', name: 'Carbon' },
|
||||
{ position: 7, mass: 14.007, symbol: 'N', name: 'Nitrogen' },
|
||||
{ position: 39, mass: 88.906, symbol: 'Y', name: 'Yttrium' },
|
||||
{ position: 56, mass: 137.33, symbol: 'Ba', name: 'Barium' },
|
||||
{ position: 58, mass: 140.12, symbol: 'Ce', name: 'Cerium' },
|
||||
];
|
||||
|
||||
const rows = elements.map((element) => (
|
||||
<Table.Tr key={element.name}>
|
||||
<Table.Td>{element.position}</Table.Td>
|
||||
<Table.Td>{element.name}</Table.Td>
|
||||
<Table.Td>{element.symbol}</Table.Td>
|
||||
<Table.Td>{element.mass}</Table.Td>
|
||||
</Table.Tr>
|
||||
));
|
||||
return (
|
||||
<Card
|
||||
radius="md"
|
||||
p="lg"
|
||||
withBorder
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||
borderColor: "rgba(100,100,100,0.2)",
|
||||
boxShadow: "0 0 20px rgba(0,255,200,0.08)",
|
||||
}}
|
||||
>
|
||||
<Stack gap="md">
|
||||
<Flex align="center" justify="space-between">
|
||||
<Title order={4} c="gray.2">
|
||||
Histori Pengaduan
|
||||
</Title>
|
||||
</Flex>
|
||||
<Divider my={0} />
|
||||
<Table>
|
||||
<Table.Thead>
|
||||
<Table.Tr>
|
||||
<Table.Th>Tanggal</Table.Th>
|
||||
<Table.Th>Deskripsi</Table.Th>
|
||||
<Table.Th>Status</Table.Th>
|
||||
<Table.Th>User</Table.Th>
|
||||
</Table.Tr>
|
||||
</Table.Thead>
|
||||
<Table.Tbody>{rows}</Table.Tbody>
|
||||
</Table>
|
||||
</Stack>
|
||||
</Card>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
function DetailUserPengaduan() {
|
||||
const [page, setPage] = useState(1);
|
||||
const [value, setValue] = useState("");
|
||||
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||
apiFetch.api.pengaduan.list.get({
|
||||
query: {
|
||||
status,
|
||||
search: value,
|
||||
take: "",
|
||||
page: "",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
useShallowEffect(() => {
|
||||
mutate();
|
||||
}, [status, value]);
|
||||
|
||||
const list = data?.data || [];
|
||||
|
||||
return (
|
||||
<Card
|
||||
radius="md"
|
||||
p="lg"
|
||||
withBorder
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||
borderColor: "rgba(100,100,100,0.2)",
|
||||
boxShadow: "0 0 20px rgba(0,255,200,0.08)",
|
||||
}}
|
||||
>
|
||||
<Stack gap="md">
|
||||
<Flex align="center" justify="space-between">
|
||||
<Flex direction={"column"}>
|
||||
<Title order={4} c="gray.2">
|
||||
Warga
|
||||
</Title>
|
||||
</Flex>
|
||||
</Flex>
|
||||
<Divider my={0} />
|
||||
<Stack gap="md">
|
||||
<Group justify="space-between" >
|
||||
<Group gap="xs">
|
||||
<IconUser size={20} />
|
||||
<Text size="md">
|
||||
Nama
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c={"white"}>Amalia Dwi Yustiani</Text>
|
||||
</Group>
|
||||
<Group justify="space-between" >
|
||||
<Group gap="xs">
|
||||
<IconMapPin size={20} />
|
||||
<Text size="md">
|
||||
Telepon
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c="white">08123456789</Text>
|
||||
</Group>
|
||||
<Group justify="space-between" >
|
||||
<Group gap="xs">
|
||||
<IconMessageReport size={20} />
|
||||
<Text size="md">
|
||||
Jumlah Pengaduan
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c="white">10</Text>
|
||||
</Group>
|
||||
<Group justify="space-between" >
|
||||
<Group gap="xs">
|
||||
<IconFileCertificate size={20} />
|
||||
<Text size="md">
|
||||
Jumlah Pelayanan Surat
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md" c="white">10</Text>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -2,21 +2,29 @@ import apiFetch from "@/lib/apiFetch";
|
||||
import {
|
||||
Badge,
|
||||
Card,
|
||||
CloseButton,
|
||||
Container,
|
||||
Divider,
|
||||
Flex,
|
||||
Group,
|
||||
Input,
|
||||
Stack,
|
||||
Tabs,
|
||||
Text,
|
||||
Title
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { showNotification } from "@mantine/notifications";
|
||||
import { IconAlignJustified, IconClockHour3, IconMapPin } from "@tabler/icons-react";
|
||||
import {
|
||||
IconAlignJustified,
|
||||
IconClockHour3,
|
||||
IconFileSad,
|
||||
IconMapPin,
|
||||
IconSearch,
|
||||
} from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import useSwr from "swr";
|
||||
import { proxy, subscribe } from "valtio";
|
||||
import { proxy } from "valtio";
|
||||
|
||||
const state = proxy({ reload: "" });
|
||||
function reloadState() {
|
||||
@@ -26,19 +34,13 @@ function reloadState() {
|
||||
export default function PengaduanListPage() {
|
||||
const { search } = useLocation();
|
||||
const query = new URLSearchParams(search);
|
||||
|
||||
const status = query.get("status");
|
||||
console.log(status, "status");
|
||||
const status = query.get("status") as StatusKey;
|
||||
|
||||
return (
|
||||
<Container
|
||||
size="xl"
|
||||
py="xl"
|
||||
w={"100%"}
|
||||
>
|
||||
<Container size="xl" py="xl" w={"100%"}>
|
||||
<Stack gap="xl">
|
||||
<TabListPengaduan status={status || "all"} />
|
||||
<ListPengaduan />
|
||||
<TabListPengaduan status={status || "semua"} />
|
||||
<ListPengaduan status={status || "semua"} />
|
||||
</Stack>
|
||||
</Container>
|
||||
);
|
||||
@@ -46,47 +48,92 @@ export default function PengaduanListPage() {
|
||||
|
||||
function TabListPengaduan({ status }: { status: string }) {
|
||||
const navigate = useNavigate();
|
||||
const dataCount = useSwr("/pengaduan/count", () =>
|
||||
apiFetch.api.pengaduan.count.get().then((res) => res.data),
|
||||
);
|
||||
|
||||
return (
|
||||
<Tabs defaultValue={status || "all"} color="teal">
|
||||
<Tabs defaultValue={status || "semua"} color="teal">
|
||||
<Tabs.List grow>
|
||||
<Tabs.Tab value="all" onClick={() => { navigate("?status=all") }}>Semua</Tabs.Tab>
|
||||
<Tabs.Tab value="antrian" onClick={() => { navigate("?status=antrian") }}>Antrian</Tabs.Tab>
|
||||
<Tabs.Tab value="diterima" onClick={() => { navigate("?status=diterima") }}>Diterima</Tabs.Tab>
|
||||
<Tabs.Tab value="dikerjakan" onClick={() => { navigate("?status=dikerjakan") }}>Dikerjakan</Tabs.Tab>
|
||||
<Tabs.Tab value="ditolak" onClick={() => { navigate("?status=ditolak") }}>Ditolak</Tabs.Tab>
|
||||
<Tabs.Tab value="selesai" onClick={() => { navigate("?status=selesai") }}>Selesai</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="all"
|
||||
onClick={() => {
|
||||
navigate("?status=semua");
|
||||
}}
|
||||
>
|
||||
Semua ({dataCount?.data?.semua || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="antrian"
|
||||
onClick={() => {
|
||||
navigate("?status=antrian");
|
||||
}}
|
||||
>
|
||||
Antrian ({dataCount?.data?.antrian || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="diterima"
|
||||
onClick={() => {
|
||||
navigate("?status=diterima");
|
||||
}}
|
||||
>
|
||||
Diterima ({dataCount?.data?.diterima || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="dikerjakan"
|
||||
onClick={() => {
|
||||
navigate("?status=dikerjakan");
|
||||
}}
|
||||
>
|
||||
Dikerjakan ({dataCount?.data?.dikerjakan || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="selesai"
|
||||
onClick={() => {
|
||||
navigate("?status=selesai");
|
||||
}}
|
||||
>
|
||||
Selesai ({dataCount?.data?.selesai || 0})
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="ditolak"
|
||||
onClick={() => {
|
||||
navigate("?status=ditolak");
|
||||
}}
|
||||
>
|
||||
Ditolak ({dataCount?.data?.ditolak || 0})
|
||||
</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
|
||||
function ListPengaduan() {
|
||||
type StatusKey =
|
||||
| "antrian"
|
||||
| "diterima"
|
||||
| "dikerjakan"
|
||||
| "ditolak"
|
||||
| "selesai"
|
||||
| "semua";
|
||||
|
||||
function ListPengaduan({ status }: { status: StatusKey }) {
|
||||
const navigate = useNavigate();
|
||||
const [page, setPage] = useState(1);
|
||||
const [value, setValue] = useState("");
|
||||
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||
apiFetch.api.credential.list.get(),
|
||||
apiFetch.api.pengaduan.list.get({
|
||||
query: {
|
||||
status,
|
||||
search: value,
|
||||
take: "",
|
||||
page: "",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
useShallowEffect(() => {
|
||||
const unsubscribe = subscribe(state, () => mutate());
|
||||
return () => unsubscribe();
|
||||
}, []);
|
||||
|
||||
async function handleRemove(id: string) {
|
||||
try {
|
||||
await apiFetch.api.credential.rm.delete({ id });
|
||||
showNotification({
|
||||
color: "teal",
|
||||
title: "Credential Deleted",
|
||||
message: "The credential was successfully removed.",
|
||||
});
|
||||
reloadState();
|
||||
} catch {
|
||||
showNotification({
|
||||
color: "red",
|
||||
title: "Error",
|
||||
message: "Failed to delete credential. Please try again.",
|
||||
});
|
||||
}
|
||||
}
|
||||
mutate();
|
||||
}, [status, value]);
|
||||
|
||||
if (isLoading)
|
||||
return (
|
||||
@@ -100,87 +147,128 @@ function ListPengaduan() {
|
||||
}}
|
||||
>
|
||||
<Text size="sm" c="dimmed">
|
||||
Loading credentials...
|
||||
Loading pengaduan...
|
||||
</Text>
|
||||
</Card>
|
||||
);
|
||||
|
||||
const list = data?.data?.list || [];
|
||||
const list = data?.data || [];
|
||||
|
||||
return (
|
||||
<Card
|
||||
radius="lg"
|
||||
p="xl"
|
||||
withBorder
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||
borderColor: "rgba(100,100,100,0.2)",
|
||||
boxShadow: "0 0 20px rgba(0,255,200,0.08)",
|
||||
}}
|
||||
>
|
||||
<Stack gap="md">
|
||||
<Flex align="center" justify="space-between">
|
||||
<Flex direction={"column"}>
|
||||
<Title order={3} c="gray.2">
|
||||
Dompet Hilang
|
||||
</Title>
|
||||
<Group>
|
||||
<Title order={6} c="gray.5">
|
||||
#PGD-061125-001
|
||||
</Title>
|
||||
<Text size="sm" c="dimmed">
|
||||
updated 2 minutes ago
|
||||
</Text>
|
||||
</Group>
|
||||
</Flex>
|
||||
<Badge
|
||||
size="xl"
|
||||
variant="light"
|
||||
radius="sm"
|
||||
color="gray"
|
||||
style={{ textTransform: "none" }}
|
||||
>
|
||||
Antrian
|
||||
</Badge>
|
||||
<Stack gap="xl">
|
||||
<Group grow>
|
||||
<Input
|
||||
value={value}
|
||||
placeholder="Cari pengaduan..."
|
||||
onChange={(event) => setValue(event.currentTarget.value)}
|
||||
leftSection={<IconSearch size={16} />}
|
||||
rightSectionPointerEvents="all"
|
||||
rightSection={
|
||||
<CloseButton
|
||||
aria-label="Clear input"
|
||||
onClick={() => setValue("")}
|
||||
style={{ display: value ? undefined : "none" }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* <Group justify="flex-end">
|
||||
<Text size="sm">Menampilkan {Number(data?.data?.length) * (page - 1) + 1} – {Math.min(10, Number(data?.data?.length) * page)} dari {Number(data?.data?.length)}</Text>
|
||||
<Pagination total={Number(data?.data?.length)} value={page} onChange={setPage} withPages={false} />
|
||||
</Group> */}
|
||||
</Group>
|
||||
{list.length === 0 ? (
|
||||
<Flex justify="center" align="center" py={"xl"}>
|
||||
<Stack gap={4} align="center">
|
||||
<IconFileSad size={32} color="gray" />
|
||||
<Text c="dimmed" size="sm">
|
||||
No pengaduan have been added yet.
|
||||
</Text>
|
||||
</Stack>
|
||||
</Flex>
|
||||
<Divider my={0} />
|
||||
<Stack gap="sm">
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconClockHour3 size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Tanggal Aduan
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">
|
||||
05 November 2025
|
||||
</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconMapPin size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Lokasi
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">
|
||||
Jalan Darmasaba Raya no 77
|
||||
</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconAlignJustified size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Detail
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">
|
||||
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quis, obcaecati. Sint natus culpa temporibus neque quasi expedita ratione, facere optio incidunt quibusdam suscipit nam nemo delectus beatae similique velit obcaecati?
|
||||
</Text>
|
||||
</Flex>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Card>
|
||||
) : (
|
||||
list.map((v: any) => (
|
||||
<Card
|
||||
key={v.id}
|
||||
radius="lg"
|
||||
p="xl"
|
||||
withBorder
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||
borderColor: "rgba(100,100,100,0.2)",
|
||||
boxShadow: "0 0 20px rgba(0,255,200,0.08)",
|
||||
}}
|
||||
onClick={() => navigate(`/scr/dashboard/pengaduan/detail?id=${v.id}`)}
|
||||
>
|
||||
<Stack gap="md">
|
||||
<Flex align="center" justify="space-between">
|
||||
<Flex direction={"column"}>
|
||||
<Title order={3} c="gray.2">
|
||||
{v.title}
|
||||
</Title>
|
||||
<Group>
|
||||
<Title order={6} c="gray.5">
|
||||
#{v.noPengaduan}
|
||||
</Title>
|
||||
<Text size="sm" c="dimmed">
|
||||
{v.updatedAt}
|
||||
</Text>
|
||||
</Group>
|
||||
</Flex>
|
||||
<Badge
|
||||
size="xl"
|
||||
variant="light"
|
||||
radius="sm"
|
||||
color={
|
||||
v.status === "diterima"
|
||||
? "green"
|
||||
: v.status === "ditolak"
|
||||
? "red"
|
||||
: v.status === "selesai"
|
||||
? "blue"
|
||||
: v.status === "dikerjakan"
|
||||
? "purple"
|
||||
: "yellow"
|
||||
}
|
||||
style={{ textTransform: "none" }}
|
||||
>
|
||||
{v.status}
|
||||
</Badge>
|
||||
</Flex>
|
||||
<Divider my={0} />
|
||||
<Stack gap="sm">
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconClockHour3 size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Tanggal Aduan
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">{v.createdAt}</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconMapPin size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Lokasi
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">{v.location}</Text>
|
||||
</Flex>
|
||||
<Flex direction={"column"} justify="flex-start">
|
||||
<Group gap="xs">
|
||||
<IconAlignJustified size={20} color="white" />
|
||||
<Text size="md" c="white">
|
||||
Detail
|
||||
</Text>
|
||||
</Group>
|
||||
<Text size="md">{v.detail}</Text>
|
||||
</Flex>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Card>
|
||||
))
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
21
src/server/lib/get-last-updated.ts
Normal file
21
src/server/lib/get-last-updated.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export function getLastUpdated(date: string | Date): string {
|
||||
const now = new Date();
|
||||
const updated = new Date(date);
|
||||
const diffMs = now.getTime() - updated.getTime();
|
||||
|
||||
const diffMinutes = Math.floor(diffMs / (1000 * 60));
|
||||
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffMinutes < 1) return "baru saja";
|
||||
if (diffMinutes < 60) return `${diffMinutes} menit lalu`;
|
||||
if (diffHours < 24) return `${diffHours} jam lalu`;
|
||||
if (diffDays < 7) return `${diffDays} hari lalu`;
|
||||
|
||||
// kalau sudah lebih dari seminggu, tampilkan tanggal
|
||||
return updated.toLocaleDateString("id-ID", {
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
});
|
||||
}
|
||||
42
src/server/lib/mimetypeToExtension.ts
Normal file
42
src/server/lib/mimetypeToExtension.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
export function mimeToExtension(mimeType: string): string {
|
||||
const map: Record<string, string> = {
|
||||
"image/jpeg": "jpg",
|
||||
"image/png": "png",
|
||||
"image/gif": "gif",
|
||||
"image/webp": "webp",
|
||||
"image/svg+xml": "svg",
|
||||
"image/bmp": "bmp",
|
||||
"image/tiff": "tiff",
|
||||
|
||||
"video/mp4": "mp4",
|
||||
"video/webm": "webm",
|
||||
"video/ogg": "ogv",
|
||||
"video/quicktime": "mov",
|
||||
|
||||
"audio/mpeg": "mp3",
|
||||
"audio/wav": "wav",
|
||||
"audio/ogg": "ogg",
|
||||
"audio/webm": "weba",
|
||||
|
||||
"application/pdf": "pdf",
|
||||
"application/zip": "zip",
|
||||
"application/x-zip-compressed": "zip",
|
||||
"application/json": "json",
|
||||
"application/javascript": "js",
|
||||
"application/x-httpd-php": "php",
|
||||
"application/msword": "doc",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
||||
"application/vnd.ms-excel": "xls",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
||||
"application/vnd.ms-powerpoint": "ppt",
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
||||
|
||||
"text/plain": "txt",
|
||||
"text/html": "html",
|
||||
"text/css": "css",
|
||||
"text/csv": "csv",
|
||||
"text/xml": "xml",
|
||||
};
|
||||
|
||||
return map[mimeType.toLowerCase()] || "bin"; // default jika tidak dikenal
|
||||
}
|
||||
@@ -136,32 +136,65 @@ export async function catFile(config: Config, fileName: string): Promise<string>
|
||||
}
|
||||
|
||||
export async function uploadFile(config: Config, file: File): Promise<string> {
|
||||
const remoteName = path.basename(file.name);
|
||||
const remoteName = path.basename(file.name);
|
||||
|
||||
// 1. Dapatkan upload link (pakai Authorization)
|
||||
const uploadUrlResponse = await fetchWithAuth(
|
||||
config,
|
||||
`${config.URL}/${config.REPO}/upload-link/`
|
||||
);
|
||||
const uploadUrl = (await uploadUrlResponse.text()).replace(/"/g, "");
|
||||
// 1. Dapatkan upload link (pakai Authorization)
|
||||
const uploadUrlResponse = await fetchWithAuth(
|
||||
config,
|
||||
`${config.URL}/${config.REPO}/upload-link/`
|
||||
);
|
||||
const uploadUrl = (await uploadUrlResponse.text()).replace(/"/g, "");
|
||||
|
||||
// 2. Siapkan form-data
|
||||
const formData = new FormData();
|
||||
formData.append("parent_dir", "/");
|
||||
formData.append("relative_path", "syarat-dokumen"); // tanpa slash di akhir
|
||||
formData.append("file", file, remoteName); // file langsung, jangan pakai Blob
|
||||
// 2. Siapkan form-data
|
||||
const formData = new FormData();
|
||||
formData.append("parent_dir", "/");
|
||||
formData.append("relative_path", "syarat-dokumen"); // tanpa slash di akhir
|
||||
formData.append("file", file, remoteName); // file langsung, jangan pakai Blob
|
||||
|
||||
// 3. Upload file TANPA Authorization header, token di query param
|
||||
const res = await fetch(`${uploadUrl}?token=${config.TOKEN}`, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
// 3. Upload file TANPA Authorization header, token di query param
|
||||
const res = await fetch(`${uploadUrl}?token=${config.TOKEN}`, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const text = await res.text();
|
||||
const text = await res.text();
|
||||
|
||||
if (!res.ok) throw new Error(`Upload failed: ${text}`);
|
||||
return `✅ Uploaded ${file.name} successfully`;
|
||||
if (!res.ok) throw new Error(`Upload failed: ${text}`);
|
||||
return `✅ Uploaded ${file.name} successfully`;
|
||||
}
|
||||
export async function uploadFileBase64(config: Config, base64File: { name: string; data: string; }): Promise<string> {
|
||||
const remoteName = path.basename(base64File.name);
|
||||
|
||||
// 1. Dapatkan upload link (pakai Authorization)
|
||||
const uploadUrlResponse = await fetchWithAuth(
|
||||
config,
|
||||
`${config.URL}/${config.REPO}/upload-link/`
|
||||
);
|
||||
const uploadUrl = (await uploadUrlResponse.text()).replace(/"/g, "");
|
||||
|
||||
// 2. Konversi base64 ke Blob
|
||||
const binary = Buffer.from(base64File.data, "base64");
|
||||
const blob = new Blob([binary]);
|
||||
|
||||
// 3. Siapkan form-data
|
||||
const formData = new FormData();
|
||||
formData.append("parent_dir", "/");
|
||||
formData.append("relative_path", "syarat-dokumen"); // tanpa slash di akhir
|
||||
formData.append("file", blob, remoteName);
|
||||
|
||||
// 4. Upload file TANPA Authorization header, token di query param
|
||||
const res = await fetch(`${uploadUrl}?token=${config.TOKEN}`, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const text = await res.text();
|
||||
|
||||
if (!res.ok) throw new Error(`Upload failed: ${text}`);
|
||||
return `✅ Uploaded ${base64File.name} successfully`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export async function removeFile(config: Config, fileName: string): Promise<string> {
|
||||
|
||||
@@ -38,10 +38,7 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
kategori pelayanan surat sudah dibuat`
|
||||
return { success: true, message: 'kategori pelayanan surat sudah dibuat' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
name: t.String({ minLength: 1, error: "name harus diisi" }),
|
||||
@@ -67,10 +64,7 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
kategori pelayanan surat sudah diperbarui`
|
||||
return { success: true, message: 'kategori pelayanan surat sudah diperbarui' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
@@ -95,10 +89,7 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
kategori pelayanan surat sudah dihapus`
|
||||
return { success: true, message: 'kategori pelayanan surat sudah dihapus' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
@@ -252,10 +243,7 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
pengaduan sudah dibuat`
|
||||
return { success: true, message: 'pengajuan surat sudah dibuat' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
idCategory: t.String({ minLength: 1, error: "idCategory harus diisi" }),
|
||||
@@ -300,10 +288,7 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
pengajuan surat sudah diperbarui`
|
||||
return { success: true, message: 'pengajuan surat sudah diperbarui' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import Elysia, { t } from "elysia"
|
||||
import type { StatusPengaduan } from "generated/prisma"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
import { getLastUpdated } from "../lib/get-last-updated"
|
||||
import { mimeToExtension } from "../lib/mimetypeToExtension"
|
||||
import { generateNoPengaduan } from "../lib/no-pengaduan"
|
||||
import { normalizePhoneNumber } from "../lib/normalizePhone"
|
||||
import { prisma } from "../lib/prisma"
|
||||
import { defaultConfigSF, uploadFile } from "../lib/seafile"
|
||||
import { defaultConfigSF, uploadFile, uploadFileBase64 } from "../lib/seafile"
|
||||
|
||||
const PengaduanRoute = new Elysia({
|
||||
prefix: "pengaduan",
|
||||
@@ -37,10 +40,7 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
kategori pengaduan sudah dibuat`
|
||||
return { success: true, message: 'kategori pengaduan sudah dibuat' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
name: t.String({ minLength: 1, error: "name harus diisi" }),
|
||||
@@ -62,10 +62,7 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
kategori pengaduan sudah diperbarui`
|
||||
return { success: true, message: 'kategori pengaduan sudah diperbarui' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
@@ -88,10 +85,7 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
kategori pengaduan sudah dihapus`
|
||||
return { success: true, message: 'kategori pengaduan sudah dihapus' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
@@ -188,10 +182,7 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
pengaduan sudah dibuat`
|
||||
return { success: true, message: 'pengaduan sudah dibuat' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
title: t.String({ minLength: 1, error: "title harus diisi" }),
|
||||
@@ -245,10 +236,7 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
return `
|
||||
${JSON.stringify(body)}
|
||||
|
||||
status pengaduan sudah diupdate`
|
||||
return { success: true, message: 'status pengaduan sudah diupdate' }
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
@@ -431,38 +419,206 @@ const PengaduanRoute = new Elysia({
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.post("/upload",
|
||||
async ({ body }) => {
|
||||
const { file } = body;
|
||||
.post("/upload", async ({ body }) => {
|
||||
const { file } = body;
|
||||
|
||||
// Validasi file
|
||||
if (!file) {
|
||||
return { success: false, message: "File tidak ditemukan" };
|
||||
}
|
||||
|
||||
// Upload ke Seafile (pastikan uploadFile menerima Blob atau ArrayBuffer)
|
||||
// const buffer = await file.arrayBuffer();
|
||||
const result = await uploadFile(defaultConfigSF, file);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Upload berhasil",
|
||||
filename: file.name,
|
||||
size: file.size,
|
||||
seafileResult: result
|
||||
};
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
file: t.File({ format: "binary" })
|
||||
}),
|
||||
detail: {
|
||||
summary: "Upload File",
|
||||
description: "Tool untuk upload file ke Seafile",
|
||||
tags: ["mcp"],
|
||||
consumes: ["multipart/form-data"]
|
||||
},
|
||||
// Validasi file
|
||||
if (!file) {
|
||||
return { success: false, message: "File tidak ditemukan" };
|
||||
}
|
||||
);
|
||||
|
||||
// Upload ke Seafile (pastikan uploadFile menerima Blob atau ArrayBuffer)
|
||||
// const buffer = await file.arrayBuffer();
|
||||
const result = await uploadFile(defaultConfigSF, file);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Upload berhasil",
|
||||
filename: file.name,
|
||||
size: file.size,
|
||||
seafileResult: result
|
||||
};
|
||||
}, {
|
||||
body: t.Object({
|
||||
file: t.File({ format: "binary" })
|
||||
}),
|
||||
detail: {
|
||||
summary: "Upload File",
|
||||
description: "Tool untuk upload file ke Seafile",
|
||||
tags: ["mcp"],
|
||||
consumes: ["multipart/form-data"]
|
||||
},
|
||||
})
|
||||
.post("/upload-base64", async ({ body }) => {
|
||||
const { data, mimetype } = body;
|
||||
const ext = mimeToExtension(mimetype)
|
||||
const name = `${uuidv4()}.${ext}`
|
||||
|
||||
// Validasi file
|
||||
if (!data) {
|
||||
return { success: false, message: "File tidak ditemukan" };
|
||||
}
|
||||
|
||||
// Konversi file ke base64
|
||||
// const buffer = await file.arrayBuffer();
|
||||
// const base64String = Buffer.from(buffer).toString("base64");
|
||||
|
||||
// (Opsional) jika perlu dikirim ke Seafile sebagai base64
|
||||
const result = await uploadFileBase64(defaultConfigSF, { name: name, data: data });
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Upload berhasil",
|
||||
data: {
|
||||
name,
|
||||
mimetype,
|
||||
ext,
|
||||
}
|
||||
};
|
||||
}, {
|
||||
body: t.Object({
|
||||
data: t.String(),
|
||||
mimetype: t.String()
|
||||
}),
|
||||
detail: {
|
||||
summary: "Upload File (Base64)",
|
||||
description: "Tool untuk upload file ke Seafile dalam format Base64",
|
||||
tags: ["mcp"],
|
||||
consumes: ["multipart/form-data"]
|
||||
},
|
||||
})
|
||||
|
||||
.get("/list", async ({ query }) => {
|
||||
const { take, page, search, status } = query
|
||||
const skip = !page ? 0 : (Number(page) - 1) * (!take ? 10 : Number(take))
|
||||
|
||||
let where: any = {
|
||||
isActive: true,
|
||||
OR: [
|
||||
{
|
||||
title: {
|
||||
contains: search ?? "",
|
||||
mode: "insensitive"
|
||||
},
|
||||
},
|
||||
{
|
||||
noPengaduan: {
|
||||
contains: search ?? "",
|
||||
mode: "insensitive"
|
||||
},
|
||||
},
|
||||
{
|
||||
detail: {
|
||||
contains: search ?? "",
|
||||
mode: "insensitive"
|
||||
},
|
||||
},
|
||||
{
|
||||
Warga: {
|
||||
phone: {
|
||||
contains: search ?? "",
|
||||
mode: "insensitive"
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
if (status && status !== "semua") {
|
||||
where = {
|
||||
...where,
|
||||
status: status
|
||||
}
|
||||
}
|
||||
|
||||
const data = await prisma.pengaduan.findMany({
|
||||
skip,
|
||||
take: !take ? 10 : Number(take),
|
||||
orderBy: {
|
||||
createdAt: "desc"
|
||||
},
|
||||
where,
|
||||
select: {
|
||||
id: true,
|
||||
noPengaduan: true,
|
||||
title: true,
|
||||
detail: true,
|
||||
location: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
CategoryPengaduan: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
},
|
||||
Warga: {
|
||||
select: {
|
||||
name: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const dataFix = data.map((item) => {
|
||||
return {
|
||||
noPengaduan: item.noPengaduan,
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
detail: item.detail,
|
||||
status: item.status,
|
||||
location: item.location,
|
||||
createdAt: item.createdAt.toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric" }),
|
||||
updatedAt: 'terakhir diperbarui ' + getLastUpdated(item.updatedAt),
|
||||
}
|
||||
})
|
||||
|
||||
return dataFix
|
||||
}, {
|
||||
query: t.Object({
|
||||
take: t.String({ optional: true }),
|
||||
page: t.String({ optional: true }),
|
||||
search: t.String({ optional: true }),
|
||||
status: t.String({ optional: true }),
|
||||
}),
|
||||
detail: {
|
||||
summary: "List Pengaduan Warga",
|
||||
description: `tool untuk mendapatkan list pengaduan warga`,
|
||||
}
|
||||
})
|
||||
.get("/count", async ({ query }) => {
|
||||
const counts = await prisma.pengaduan.groupBy({
|
||||
by: ['status'],
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
_count: {
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
|
||||
const grouped = Object.fromEntries(
|
||||
counts.map(c => [c.status, c._count.status])
|
||||
);
|
||||
|
||||
const total = await prisma.pengaduan.count({
|
||||
where: { isActive: true },
|
||||
});
|
||||
|
||||
return {
|
||||
antrian: grouped?.antrian || 0,
|
||||
diterima: grouped?.diterima || 0,
|
||||
dikerjakan: grouped?.dikerjakan || 0,
|
||||
ditolak: grouped?.ditolak || 0,
|
||||
selesai: grouped?.selesai || 0,
|
||||
semua: total,
|
||||
};
|
||||
}, {
|
||||
detail: {
|
||||
summary: "Jumlah Pengaduan Warga",
|
||||
description: `tool untuk mendapatkan jumlah pengaduan warga`,
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
export default PengaduanRoute
|
||||
|
||||
53
src/server/routes/test.ts
Normal file
53
src/server/routes/test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
|
||||
const TestRoute = new Elysia({
|
||||
prefix: "test",
|
||||
tags: ["mcp", "test"],
|
||||
})
|
||||
.get("/info-rapat-list", () => {
|
||||
return {
|
||||
success: true,
|
||||
message: "data info rapat berhasil diambil",
|
||||
data: [
|
||||
{
|
||||
judul: "Info Rapat",
|
||||
tanggal: "2025-11-10",
|
||||
deskripsi: "Info rapat",
|
||||
gambar: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII="
|
||||
}
|
||||
]
|
||||
}
|
||||
}, {
|
||||
detail: {
|
||||
summary: "mendapatkan list rapat",
|
||||
description: "mendapatkan list rapat dari database",
|
||||
}
|
||||
})
|
||||
|
||||
.post("/simpan-rapat", ({ body }) => {
|
||||
if (!body.gambar) {
|
||||
return {
|
||||
success: false,
|
||||
message: "gambar harus diisi",
|
||||
}
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
message: "data info rapat berhasil diambil",
|
||||
chunk: body.gambar.substring(22)
|
||||
}
|
||||
}, {
|
||||
body: t.Object({
|
||||
judul: t.String(),
|
||||
tanggal: t.String(),
|
||||
deskripsi: t.String(),
|
||||
gambar: t.Required(t.String()),
|
||||
}),
|
||||
detail: {
|
||||
summary: "simpan data rapat",
|
||||
description: "simpan data rapat memerlukan base64 gambar",
|
||||
}
|
||||
})
|
||||
|
||||
export default TestRoute
|
||||
|
||||
5
upload_base64.sh
Normal file
5
upload_base64.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
IMAGE_BASE64=$(base64 image.png | tr -d '\n')
|
||||
|
||||
curl -X POST http://localhost:3000/api/pengaduan/upload-base64 \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"file\": \"$IMAGE_BASE64\"}"
|
||||
154
x.ts
154
x.ts
@@ -1,133 +1,39 @@
|
||||
/**
|
||||
* src/utils/swagger-to-mcp.ts
|
||||
*
|
||||
* Auto-converter: Swagger (OpenAPI) → MCP manifest (real-time)
|
||||
*
|
||||
* - Fetch swagger JSON dynamically from process.env.BUN_PUBLIC_BASE_URL + "/docs/json"
|
||||
* - Generate MCP manifest for AI discovery (/.well-known/mcp.json)
|
||||
* - Can be used as Bun CLI or integrated in Elysia route
|
||||
*/
|
||||
import fs from "fs";
|
||||
|
||||
import { writeFileSync } from "fs"
|
||||
// 1️⃣ File yang mau diupload
|
||||
const filePath = "image.png";
|
||||
const apiUrl = "http://localhost:3000/api/pengaduan/upload-base64";
|
||||
|
||||
interface OpenAPI {
|
||||
info: { title?: string; description?: string; version?: string }
|
||||
paths: Record<string, any>
|
||||
}
|
||||
// 2️⃣ Baca file dan ubah ke base64
|
||||
const fileBuffer = fs.readFileSync(filePath);
|
||||
const base64Data = fileBuffer.toString("base64");
|
||||
|
||||
interface McpManifest {
|
||||
schema_version: string
|
||||
name: string
|
||||
description: string
|
||||
version?: string
|
||||
endpoints: Record<string, string>
|
||||
capabilities: Record<string, any>
|
||||
contact?: { email?: string }
|
||||
}
|
||||
// 3️⃣ Buat payload JSON
|
||||
const payload = {
|
||||
data: base64Data,
|
||||
mimetype: "image/png"
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert OpenAPI JSON to MCP manifest format
|
||||
*/
|
||||
async function convertOpenApiToMcp(baseUrl: string): Promise<McpManifest> {
|
||||
const res = await fetch(`${baseUrl}/docs/json`)
|
||||
if (!res.ok) throw new Error(`Failed to fetch Swagger JSON from ${baseUrl}/docs/json`)
|
||||
// 4️⃣ Kirim ke server pakai fetch
|
||||
async function uploadBase64() {
|
||||
try {
|
||||
const res = await fetch(apiUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
const openapi: OpenAPI = await res.json()
|
||||
|
||||
const manifest: McpManifest = {
|
||||
schema_version: "1.0",
|
||||
name: openapi.info?.title ?? "MCP Server",
|
||||
description: openapi.info?.description ?? "Auto-generated MCP manifest from Swagger",
|
||||
version: openapi.info?.version ?? "0.0.0",
|
||||
endpoints: {
|
||||
openapi: `${baseUrl}/docs/json`,
|
||||
mcp: `${baseUrl}/.well-known/mcp.json`
|
||||
},
|
||||
capabilities: {}
|
||||
if (!res.ok) {
|
||||
throw new Error(`Request failed: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
|
||||
for (const [path, methods] of Object.entries(openapi.paths || {})) {
|
||||
for (const [method, def] of Object.entries<any>(methods)) {
|
||||
const tags = def.tags || ["default"]
|
||||
const tag = tags[0]
|
||||
const operationId = def.operationId || `${method}_${path.replace(/[\/{}]/g, "_")}`
|
||||
|
||||
manifest.capabilities[tag] ??= {}
|
||||
|
||||
// Extract parameters and body schema
|
||||
const params: Record<string, string> = {}
|
||||
const required: string[] = []
|
||||
|
||||
if (Array.isArray(def.parameters)) {
|
||||
for (const p of def.parameters) {
|
||||
const type = p.schema?.type || "string"
|
||||
params[p.name] = type
|
||||
if (p.required) required.push(p.name)
|
||||
}
|
||||
}
|
||||
|
||||
const bodySchema = def.requestBody?.content?.["application/json"]?.schema
|
||||
if (bodySchema?.properties) {
|
||||
for (const [key, prop] of Object.entries<any>(bodySchema.properties)) {
|
||||
params[key] = prop.type || "string"
|
||||
}
|
||||
if (Array.isArray(bodySchema.required))
|
||||
required.push(...bodySchema.required)
|
||||
}
|
||||
|
||||
// Generate example cURL
|
||||
const sampleCurl = [
|
||||
`curl -X ${method.toUpperCase()} ${baseUrl}${path}`,
|
||||
Object.keys(params).length > 0
|
||||
? ` -H 'Content-Type: application/json' -d '${JSON.stringify(
|
||||
Object.fromEntries(Object.keys(params).map(k => [k, params[k] === "string" ? k : "value"]))
|
||||
)}'`
|
||||
: ""
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" \\\n")
|
||||
|
||||
manifest.capabilities[tag][operationId] = {
|
||||
method: method.toUpperCase(),
|
||||
path,
|
||||
summary: def.summary || def.description || "",
|
||||
parameters: Object.keys(params).length > 0 ? params : undefined,
|
||||
required: required.length > 0 ? required : undefined,
|
||||
command: sampleCurl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return manifest
|
||||
const result = await res.json();
|
||||
console.log("✅ Upload sukses:", result);
|
||||
} catch (err) {
|
||||
console.error("❌ Upload gagal:", err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CLI entry
|
||||
* bun run src/utils/swagger-to-mcp.ts
|
||||
*/
|
||||
if (import.meta.main) {
|
||||
const baseUrl = process.env.BUN_PUBLIC_BASE_URL
|
||||
if (!baseUrl) {
|
||||
console.error("❌ Missing BUN_PUBLIC_BASE_URL environment variable.")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
convertOpenApiToMcp(baseUrl)
|
||||
.then(manifest => {
|
||||
writeFileSync(".well-known/mcp.json", JSON.stringify(manifest, null, 2))
|
||||
console.log("✅ Generated .well-known/mcp.json")
|
||||
})
|
||||
.catch(err => console.error("❌ Failed to convert Swagger → MCP:", err))
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional: Elysia integration
|
||||
* Automatically serve /.well-known/mcp.json
|
||||
*/
|
||||
// import Elysia from "elysia"
|
||||
// new Elysia()
|
||||
// .get("/.well-known/mcp.json", async () => {
|
||||
// const baseUrl = process.env.BUN_PUBLIC_BASE_URL!
|
||||
// return await convertOpenApiToMcp(baseUrl)
|
||||
// })
|
||||
// .listen(3000)
|
||||
uploadBase64();
|
||||
|
||||
Reference in New Issue
Block a user