feat: add credential routes and mcp manifest
This commit is contained in:
46
src/server/routes/credential_route.ts
Normal file
46
src/server/routes/credential_route.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import { prisma } from "../lib/prisma";
|
||||
|
||||
const CredentialRoute = new Elysia({
|
||||
prefix: "/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(),
|
||||
})
|
||||
})
|
||||
.get("/list", async (ctx) => {
|
||||
const list = await prisma.credential.findMany()
|
||||
return {
|
||||
message: "success",
|
||||
list
|
||||
}
|
||||
})
|
||||
.delete("/rm", async (ctx) => {
|
||||
const { id } = ctx.body
|
||||
const rm = await prisma.credential.delete({
|
||||
where: {
|
||||
id: id
|
||||
}
|
||||
})
|
||||
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String()
|
||||
})
|
||||
})
|
||||
|
||||
export default CredentialRoute
|
||||
Reference in New Issue
Block a user