Update app.ts
Browse files
app.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
| 1 |
-
import { Elysia
|
|
|
|
| 2 |
|
| 3 |
-
const loggerMiddleware = async ({ method, path, headers }, next) => {
|
| 4 |
-
console.log(`[${new Date().toISOString()}] ${method} ${path}`);
|
| 5 |
-
console.log(`Headers: ${JSON.stringify(headers)}`);
|
| 6 |
-
const start = Date.now();
|
| 7 |
-
const response = await next();
|
| 8 |
-
const duration = Date.now() - start;
|
| 9 |
-
console.log(`Response Time: ${duration}ms`);
|
| 10 |
-
return response;
|
| 11 |
-
};
|
| 12 |
|
| 13 |
const app = new Elysia()
|
| 14 |
-
.use(
|
| 15 |
.get("/", () => "Hello, Elysia!")
|
| 16 |
.get("/items/:id", ({ params }) => `Item ID: ${params.id}`)
|
| 17 |
.listen(process.env.PORT);
|
|
|
|
| 1 |
+
import { Elysia } from "elysia";
|
| 2 |
+
import { swagger } from "@elysiajs/swagger"
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
const app = new Elysia()
|
| 6 |
+
.use(swagger({ path: "/docs" }))
|
| 7 |
.get("/", () => "Hello, Elysia!")
|
| 8 |
.get("/items/:id", ({ params }) => `Item ID: ${params.id}`)
|
| 9 |
.listen(process.env.PORT);
|