Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
Latest commit
51 lines (45 loc) · 1.44 KB
/
Copy pathapp.ts
File metadata and controls
51 lines (45 loc) · 1.44 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
import{OpenAPIHono}from"@hono/zod-openapi";
import{cors}from"hono/cors";
import{jsonError}from"@/lib/http-error";
import{agentsRoute}from"@/routes/agents";
import{configRoute}from"@/routes/config";
import{deploymentsRoute}from"@/routes/deployments";
import{environmentsRoute}from"@/routes/environments";
import{filesRoute}from"@/routes/files";
import{modelsRoute}from"@/routes/models";
import{sessionsRoute}from"@/routes/sessions";
import{skillsRoute}from"@/routes/skills";
import{vaultsRoute}from"@/routes/vaults";
exportconstapp=newOpenAPIHono();
// CORS
app.use(
"/*",
cors({
origin: process.env.CORS_ORIGIN?.split(",")??["http://localhost:3000"],
allowMethods: ["GET","POST","PUT","OPTIONS"],
allowHeaders: ["Content-Type"],
maxAge: 86400,
}),
);
// Routes
app.route("/api",configRoute);
app.route("/api",deploymentsRoute);
app.route("/api",agentsRoute);
app.route("/api",environmentsRoute);
app.route("/api",vaultsRoute);
app.route("/api",sessionsRoute);
app.route("/api",filesRoute);
app.route("/api",skillsRoute);
app.route("/api",modelsRoute);
// OpenAPI document
app.doc("/openapi.json",{
openapi: "3.0.0",
info: {
title: "OpenAgentPack API",
version: "1.0.0",
},
});
// Health check
app.get("/health",(c)=>c.json({status: "ok"}));
// Centralized error formatting: routes throw, this maps to { error: { message }}.
app.onError((error)=>jsonError(error));