Files
jenna-mcp/src/server/routes/credential_route.ts
bipproduction 9850fab34d tambahan
2025-10-12 21:49:54 +08:00

60 lines
1.3 KiB
TypeScript

import Elysia, { t } from "elysia";
import { prisma } from "../lib/prisma";
const CredentialRoute = new Elysia({
prefix: "/credential",
tags: ["credential"],
})
.post("/create", async (ctx) => {
const { name, value } = ctx.body
const create = await prisma.credential.create({
data: {
name,
value
}
})
return {
message: "success",
create
}
}, {
body: t.Object({
name: t.String(),
value: t.String(),
}),
detail: {
summary: 'create',
description: 'create credential',
}
})
.get("/list", async () => {
const list = await prisma.credential.findMany()
return {
message: "success",
list
}
}, {
detail: {
summary: 'list',
description: 'get credential list',
}
})
.delete("/rm", async (ctx) => {
const { id } = ctx.body
await prisma.credential.delete({
where: {
id: id
}
})
}, {
body: t.Object({
id: t.String()
}),
detail: {
summary: 'rm',
description: 'delete credential by id',
}
})
export default CredentialRoute