-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
43 lines (38 loc) · 1 KB
/
Copy pathserver.ts
File metadata and controls
43 lines (38 loc) · 1 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
import { classValidator } from "../../src/adapters/class-validator.js";
import { createApp } from "../../src/index.js";
import {
HealthController,
OrderController,
ProductController,
} from "./controllers.js";
const port = 3_000;
const app = createApp({
schema: classValidator(),
controllers: [ProductController, OrderController, HealthController],
docs: { swagger: true },
openapi: {
service: {
name: "multi-controller",
version: "1.0.0",
description: "Multiple controllers, @OperationId, @Deprecated, @Hidden, and @Produces for CSV responses. Builds on crud.",
},
},
});
Bun.serve({
port: port,
routes: {
...app.routes,
},
fetch: app.fetch,
});
console.table(
Object.entries(app.routes).map(([path, handlers]) => ({
path: path,
methods: Object.keys(handlers).join(", "),
})),
);
console.table([
{ name: "Server", url: `http://localhost:${port}` },
{ name: "Docs Index", url: `http://localhost:${port}/docs/` },
{ name: "Swagger UI", url: `http://localhost:${port}/docs/swagger/` },
]);