forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagents.routes.ts
More file actions
38 lines (34 loc) · 961 Bytes
/
Copy pathagents.routes.ts
File metadata and controls
38 lines (34 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Router } from "express";
import { apiKeyAuth } from "../../common/http/api-key-auth.middleware";
import { idempotencyKeyMiddleware } from "../../common/http/idempotency.middleware";
import { validateBody, validateQuery } from "../../common/http/validate.middleware";
import {
createAgent,
deleteAgent,
getAgentById,
listAgents,
updateAgentStatus,
} from "./agents.controller";
import {
agentStatusSchema,
createAgentSchema,
listAgentsQuerySchema,
} from "./agents.schema";
export const agentsRouter = Router();
agentsRouter.use(apiKeyAuth);
agentsRouter.get("/", validateQuery(listAgentsQuerySchema), listAgents);
agentsRouter.get("/:id", getAgentById);
agentsRouter.post(
"/",
apiKeyAuth,
idempotencyKeyMiddleware,
validateBody(createAgentSchema),
createAgent,
);
agentsRouter.patch(
"/:id",
apiKeyAuth,
validateBody(agentStatusSchema),
updateAgentStatus,
);
agentsRouter.delete("/:id", apiKeyAuth, deleteAgent);