update 00000
This commit is contained in:
parent
40d600ab5b
commit
6bbf2137b5
1 changed files with 73 additions and 3 deletions
76
src/app.ts
76
src/app.ts
|
|
@ -1,4 +1,4 @@
|
|||
import { Elysia } from "elysia";
|
||||
import { Elysia, t } from "elysia";
|
||||
import swagger from "@elysiajs/swagger";
|
||||
import cors from "@elysiajs/cors";
|
||||
import { ENV } from "./config/env";
|
||||
|
|
@ -43,10 +43,71 @@ const app = new Elysia()
|
|||
{ name: "Auth", description: "Authentication related endpoints" },
|
||||
{ name: "Download", description: "Download count related endpoints" },
|
||||
],
|
||||
// Add server information to help Swagger understand your API
|
||||
servers: [
|
||||
{
|
||||
url: ENV.SERVER_URL + ":" + ENV.SERVER_PORT,
|
||||
description: "Canvas API Server",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
)
|
||||
.get("/", () => "PlanPostAI Canvas Server is running")
|
||||
.get("/", () => "PlanPostAI Canvas Server is running", {
|
||||
detail: {
|
||||
tags: ["Default"],
|
||||
summary: "Server root",
|
||||
description: "Returns a message indicating server is running",
|
||||
},
|
||||
response: {
|
||||
200: t.String(),
|
||||
},
|
||||
})
|
||||
.get("/test-swagger", () => "Test route with complete swagger docs", {
|
||||
detail: {
|
||||
tags: ["Default"],
|
||||
summary: "Test Swagger",
|
||||
description: "Test route with complete Swagger documentation",
|
||||
},
|
||||
response: {
|
||||
200: t.String(),
|
||||
},
|
||||
})
|
||||
.get(
|
||||
"/debug/routes",
|
||||
() => {
|
||||
return {
|
||||
routes: app.routes.map((route) => ({
|
||||
method: route.method,
|
||||
path: route.path,
|
||||
detail: route.detail
|
||||
? {
|
||||
tags: route.detail.tags,
|
||||
summary: route.detail.summary,
|
||||
}
|
||||
: "No detail",
|
||||
})),
|
||||
};
|
||||
},
|
||||
{
|
||||
detail: {
|
||||
tags: ["Default"],
|
||||
summary: "Debug Routes",
|
||||
description: "Shows all registered routes",
|
||||
},
|
||||
response: {
|
||||
200: t.Object({
|
||||
routes: t.Array(
|
||||
t.Object({
|
||||
method: t.String(),
|
||||
path: t.String(),
|
||||
detail: t.Any(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
},
|
||||
}
|
||||
)
|
||||
.use(api)
|
||||
.onError(({ code, error }) => {
|
||||
console.error(`App Error: ${code}`, error);
|
||||
|
|
@ -54,6 +115,12 @@ const app = new Elysia()
|
|||
return "An error occurred";
|
||||
});
|
||||
|
||||
// Log environment configuration
|
||||
console.log("Environment configuration:", {
|
||||
SERVER_URL: ENV.SERVER_URL,
|
||||
SERVER_PORT: ENV.SERVER_PORT,
|
||||
});
|
||||
|
||||
app.listen(ENV.SERVER_PORT, () => {
|
||||
console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`);
|
||||
console.log(
|
||||
|
|
@ -62,6 +129,9 @@ app.listen(ENV.SERVER_PORT, () => {
|
|||
|
||||
console.log("All registered routes:");
|
||||
app.routes.forEach((route) => {
|
||||
console.log(`${route.method} ${route.path}`);
|
||||
// Also log the detail object to see if routes have Swagger metadata
|
||||
console.log(
|
||||
`${route.method} ${route.path} - Detail: ${route.detail ? "Yes" : "No"}`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue