@cinnabun/core 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/autowired.test.d.ts +1 -0
- package/dist/__tests__/autowired.test.js +109 -0
- package/dist/__tests__/autowired.test.js.map +1 -0
- package/dist/__tests__/cinnabun-application.test.d.ts +1 -0
- package/dist/__tests__/cinnabun-application.test.js +96 -0
- package/dist/__tests__/cinnabun-application.test.js.map +1 -0
- package/dist/__tests__/cinnabun-factory.test.d.ts +1 -0
- package/dist/__tests__/cinnabun-factory.test.js +269 -0
- package/dist/__tests__/cinnabun-factory.test.js.map +1 -0
- package/dist/__tests__/circular-dependency.test.d.ts +1 -0
- package/dist/__tests__/circular-dependency.test.js +318 -0
- package/dist/__tests__/circular-dependency.test.js.map +1 -0
- package/dist/__tests__/compression.test.d.ts +1 -0
- package/dist/__tests__/compression.test.js +459 -0
- package/dist/__tests__/compression.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +1 -0
- package/dist/__tests__/config.test.js +86 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/__tests__/cors.test.d.ts +1 -0
- package/dist/__tests__/cors.test.js +575 -0
- package/dist/__tests__/cors.test.js.map +1 -0
- package/dist/__tests__/env-config.test.d.ts +1 -0
- package/dist/__tests__/env-config.test.js +367 -0
- package/dist/__tests__/env-config.test.js.map +1 -0
- package/dist/__tests__/exception.test.d.ts +1 -0
- package/dist/__tests__/exception.test.js +207 -0
- package/dist/__tests__/exception.test.js.map +1 -0
- package/dist/__tests__/guards-interceptors.test.d.ts +1 -0
- package/dist/__tests__/guards-interceptors.test.js +660 -0
- package/dist/__tests__/guards-interceptors.test.js.map +1 -0
- package/dist/__tests__/health-check.test.d.ts +1 -0
- package/dist/__tests__/health-check.test.js +240 -0
- package/dist/__tests__/health-check.test.js.map +1 -0
- package/dist/__tests__/http.test.d.ts +1 -0
- package/dist/__tests__/http.test.js +629 -0
- package/dist/__tests__/http.test.js.map +1 -0
- package/dist/__tests__/integration/e2e.test.d.ts +1 -0
- package/dist/__tests__/integration/e2e.test.js +192 -0
- package/dist/__tests__/integration/e2e.test.js.map +1 -0
- package/dist/__tests__/integration/performance.bench.d.ts +1 -0
- package/dist/__tests__/integration/performance.bench.js +129 -0
- package/dist/__tests__/integration/performance.bench.js.map +1 -0
- package/dist/__tests__/integration/validation.test.d.ts +1 -0
- package/dist/__tests__/integration/validation.test.js +133 -0
- package/dist/__tests__/integration/validation.test.js.map +1 -0
- package/dist/__tests__/lifecycle-management.test.d.ts +1 -0
- package/dist/__tests__/lifecycle-management.test.js +688 -0
- package/dist/__tests__/lifecycle-management.test.js.map +1 -0
- package/dist/__tests__/lifecycle.test.d.ts +1 -0
- package/dist/__tests__/lifecycle.test.js +196 -0
- package/dist/__tests__/lifecycle.test.js.map +1 -0
- package/dist/__tests__/logger.test.d.ts +1 -0
- package/dist/__tests__/logger.test.js +109 -0
- package/dist/__tests__/logger.test.js.map +1 -0
- package/dist/__tests__/middleware.test.d.ts +1 -0
- package/dist/__tests__/middleware.test.js +329 -0
- package/dist/__tests__/middleware.test.js.map +1 -0
- package/dist/__tests__/module.test.d.ts +1 -0
- package/dist/__tests__/module.test.js +280 -0
- package/dist/__tests__/module.test.js.map +1 -0
- package/dist/__tests__/plugin.test.d.ts +1 -0
- package/dist/__tests__/plugin.test.js +283 -0
- package/dist/__tests__/plugin.test.js.map +1 -0
- package/dist/__tests__/request-logger.test.d.ts +1 -0
- package/dist/__tests__/request-logger.test.js +342 -0
- package/dist/__tests__/request-logger.test.js.map +1 -0
- package/dist/__tests__/request-mapping.test.d.ts +1 -0
- package/dist/__tests__/request-mapping.test.js +201 -0
- package/dist/__tests__/request-mapping.test.js.map +1 -0
- package/dist/__tests__/routes.test.d.ts +1 -0
- package/dist/__tests__/routes.test.js +119 -0
- package/dist/__tests__/routes.test.js.map +1 -0
- package/dist/__tests__/scan-fixtures/controllers/hello.controller.d.ts +4 -0
- package/dist/__tests__/scan-fixtures/controllers/hello.controller.js +28 -0
- package/dist/__tests__/scan-fixtures/controllers/hello.controller.js.map +1 -0
- package/dist/__tests__/scan-fixtures/modules/feature.module.d.ts +6 -0
- package/dist/__tests__/scan-fixtures/modules/feature.module.js +28 -0
- package/dist/__tests__/scan-fixtures/modules/feature.module.js.map +1 -0
- package/dist/__tests__/scan-fixtures/services/greeting.service.d.ts +4 -0
- package/dist/__tests__/scan-fixtures/services/greeting.service.js +18 -0
- package/dist/__tests__/scan-fixtures/services/greeting.service.js.map +1 -0
- package/dist/__tests__/scanner.test.d.ts +1 -0
- package/dist/__tests__/scanner.test.js +49 -0
- package/dist/__tests__/scanner.test.js.map +1 -0
- package/dist/__tests__/validation.test.d.ts +1 -0
- package/dist/__tests__/validation.test.js +561 -0
- package/dist/__tests__/validation.test.js.map +1 -0
- package/dist/__tests__/websocket-auth.test.d.ts +1 -0
- package/dist/__tests__/websocket-auth.test.js +431 -0
- package/dist/__tests__/websocket-auth.test.js.map +1 -0
- package/dist/__tests__/websocket-decorators.test.d.ts +1 -0
- package/dist/__tests__/websocket-decorators.test.js +173 -0
- package/dist/__tests__/websocket-decorators.test.js.map +1 -0
- package/dist/__tests__/websocket-validation.test.d.ts +1 -0
- package/dist/__tests__/websocket-validation.test.js +827 -0
- package/dist/__tests__/websocket-validation.test.js.map +1 -0
- package/dist/__tests__/websocket.test.d.ts +1 -0
- package/dist/__tests__/websocket.test.js +415 -0
- package/dist/__tests__/websocket.test.js.map +1 -0
- package/dist/config/config.module.d.ts +2 -0
- package/dist/config/config.module.js +18 -0
- package/dist/config/config.module.js.map +1 -0
- package/dist/config/config.service.d.ts +15 -0
- package/dist/config/config.service.js +58 -0
- package/dist/config/config.service.js.map +1 -0
- package/dist/config/schemas.d.ts +107 -0
- package/dist/config/schemas.js +87 -0
- package/dist/config/schemas.js.map +1 -0
- package/dist/core/app.d.ts +44 -0
- package/dist/core/app.js +178 -0
- package/dist/core/app.js.map +1 -0
- package/dist/core/cinnabun-factory.d.ts +5 -0
- package/dist/core/cinnabun-factory.js +130 -0
- package/dist/core/cinnabun-factory.js.map +1 -0
- package/dist/core/config-loader.d.ts +2 -0
- package/dist/core/config-loader.js +76 -0
- package/dist/core/config-loader.js.map +1 -0
- package/dist/core/config.d.ts +12 -0
- package/dist/core/config.js +27 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/container.d.ts +10 -0
- package/dist/core/container.js +82 -0
- package/dist/core/container.js.map +1 -0
- package/dist/core/dependency-validator.d.ts +12 -0
- package/dist/core/dependency-validator.js +76 -0
- package/dist/core/dependency-validator.js.map +1 -0
- package/dist/core/guard.d.ts +3 -0
- package/dist/core/guard.js +2 -0
- package/dist/core/guard.js.map +1 -0
- package/dist/core/interceptor.d.ts +4 -0
- package/dist/core/interceptor.js +2 -0
- package/dist/core/interceptor.js.map +1 -0
- package/dist/core/logger.d.ts +15 -0
- package/dist/core/logger.js +71 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/module-resolver.d.ts +6 -0
- package/dist/core/module-resolver.js +67 -0
- package/dist/core/module-resolver.js.map +1 -0
- package/dist/core/plugin.d.ts +12 -0
- package/dist/core/plugin.js +2 -0
- package/dist/core/plugin.js.map +1 -0
- package/dist/core/router.d.ts +38 -0
- package/dist/core/router.js +406 -0
- package/dist/core/router.js.map +1 -0
- package/dist/core/scanner.d.ts +7 -0
- package/dist/core/scanner.js +83 -0
- package/dist/core/scanner.js.map +1 -0
- package/dist/core/shutdown-manager.d.ts +15 -0
- package/dist/core/shutdown-manager.js +68 -0
- package/dist/core/shutdown-manager.js.map +1 -0
- package/dist/core/websocket-handler.d.ts +41 -0
- package/dist/core/websocket-handler.js +242 -0
- package/dist/core/websocket-handler.js.map +1 -0
- package/dist/decorators/autowired.d.ts +3 -0
- package/dist/decorators/autowired.js +11 -0
- package/dist/decorators/autowired.js.map +1 -0
- package/dist/decorators/cinnabun-application.d.ts +14 -0
- package/dist/decorators/cinnabun-application.js +17 -0
- package/dist/decorators/cinnabun-application.js.map +1 -0
- package/dist/decorators/lifecycle.d.ts +2 -0
- package/dist/decorators/lifecycle.js +12 -0
- package/dist/decorators/lifecycle.js.map +1 -0
- package/dist/decorators/middleware.d.ts +2 -0
- package/dist/decorators/middleware.js +12 -0
- package/dist/decorators/middleware.js.map +1 -0
- package/dist/decorators/module.d.ts +10 -0
- package/dist/decorators/module.js +13 -0
- package/dist/decorators/module.js.map +1 -0
- package/dist/decorators/on-shutdown.d.ts +1 -0
- package/dist/decorators/on-shutdown.js +10 -0
- package/dist/decorators/on-shutdown.js.map +1 -0
- package/dist/decorators/params.d.ts +6 -0
- package/dist/decorators/params.js +31 -0
- package/dist/decorators/params.js.map +1 -0
- package/dist/decorators/request-mapping.d.ts +7 -0
- package/dist/decorators/request-mapping.js +34 -0
- package/dist/decorators/request-mapping.js.map +1 -0
- package/dist/decorators/response.d.ts +2 -0
- package/dist/decorators/response.js +17 -0
- package/dist/decorators/response.js.map +1 -0
- package/dist/decorators/rest-controller.d.ts +1 -0
- package/dist/decorators/rest-controller.js +19 -0
- package/dist/decorators/rest-controller.js.map +1 -0
- package/dist/decorators/routes.d.ts +5 -0
- package/dist/decorators/routes.js +19 -0
- package/dist/decorators/routes.js.map +1 -0
- package/dist/decorators/service.d.ts +1 -0
- package/dist/decorators/service.js +7 -0
- package/dist/decorators/service.js.map +1 -0
- package/dist/decorators/use-guard.d.ts +2 -0
- package/dist/decorators/use-guard.js +12 -0
- package/dist/decorators/use-guard.js.map +1 -0
- package/dist/decorators/use-interceptor.d.ts +2 -0
- package/dist/decorators/use-interceptor.js +12 -0
- package/dist/decorators/use-interceptor.js.map +1 -0
- package/dist/decorators/validate.d.ts +12 -0
- package/dist/decorators/validate.js +7 -0
- package/dist/decorators/validate.js.map +1 -0
- package/dist/decorators/websocket.d.ts +9 -0
- package/dist/decorators/websocket.js +38 -0
- package/dist/decorators/websocket.js.map +1 -0
- package/dist/decorators/ws-event.d.ts +28 -0
- package/dist/decorators/ws-event.js +37 -0
- package/dist/decorators/ws-event.js.map +1 -0
- package/dist/decorators/ws-gateway.d.ts +18 -0
- package/dist/decorators/ws-gateway.js +24 -0
- package/dist/decorators/ws-gateway.js.map +1 -0
- package/dist/dev/index.d.ts +6 -0
- package/dist/dev/index.js +28 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/exceptions/circular-dependency-error.d.ts +5 -0
- package/dist/exceptions/circular-dependency-error.js +16 -0
- package/dist/exceptions/circular-dependency-error.js.map +1 -0
- package/dist/exceptions/http-exception.d.ts +41 -0
- package/dist/exceptions/http-exception.js +96 -0
- package/dist/exceptions/http-exception.js.map +1 -0
- package/dist/guards/jwt-websocket.guard.d.ts +11 -0
- package/dist/guards/jwt-websocket.guard.js +37 -0
- package/dist/guards/jwt-websocket.guard.js.map +1 -0
- package/dist/guards/websocket-auth.guard.d.ts +16 -0
- package/dist/guards/websocket-auth.guard.js +43 -0
- package/dist/guards/websocket-auth.guard.js.map +1 -0
- package/dist/health/health-check.service.d.ts +45 -0
- package/dist/health/health-check.service.js +95 -0
- package/dist/health/health-check.service.js.map +1 -0
- package/dist/health/health.controller.d.ts +15 -0
- package/dist/health/health.controller.js +63 -0
- package/dist/health/health.controller.js.map +1 -0
- package/dist/health/health.module.d.ts +2 -0
- package/dist/health/health.module.js +20 -0
- package/dist/health/health.module.js.map +1 -0
- package/dist/index.d.ts +74 -11
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata/storage.d.ts +171 -0
- package/dist/metadata/storage.js +257 -0
- package/dist/metadata/storage.js.map +1 -0
- package/dist/middleware/compression.middleware.d.ts +32 -0
- package/dist/middleware/compression.middleware.js +113 -0
- package/dist/middleware/compression.middleware.js.map +1 -0
- package/dist/middleware/cors.middleware.d.ts +18 -0
- package/dist/middleware/cors.middleware.js +79 -0
- package/dist/middleware/cors.middleware.js.map +1 -0
- package/dist/middleware/performance-tracker.middleware.d.ts +35 -0
- package/dist/middleware/performance-tracker.middleware.js +79 -0
- package/dist/middleware/performance-tracker.middleware.js.map +1 -0
- package/dist/middleware/request-logger.middleware.d.ts +32 -0
- package/dist/middleware/request-logger.middleware.js +125 -0
- package/dist/middleware/request-logger.middleware.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/validation/helpers.d.ts +36 -0
- package/dist/validation/helpers.js +27 -0
- package/dist/validation/helpers.js.map +1 -0
- package/dist/websocket/error.d.ts +27 -0
- package/dist/websocket/error.js +38 -0
- package/dist/websocket/error.js.map +1 -0
- package/package.json +38 -5
- package/LICENSE +0 -9
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import "reflect-metadata";
|
|
11
|
+
import { describe, it, expect, afterEach } from "bun:test";
|
|
12
|
+
import { CinnabunFactory } from "../core/cinnabun-factory.js";
|
|
13
|
+
import { CinnabunApplication as CinnabunAppDecorator } from "../decorators/cinnabun-application.js";
|
|
14
|
+
import { RestController } from "../decorators/rest-controller.js";
|
|
15
|
+
import { GetMapping } from "../decorators/routes.js";
|
|
16
|
+
import { Service } from "../decorators/service.js";
|
|
17
|
+
let app = null;
|
|
18
|
+
afterEach(async () => {
|
|
19
|
+
if (app) {
|
|
20
|
+
await app.close();
|
|
21
|
+
app = null;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
describe("Plugin system", () => {
|
|
25
|
+
it("calls onInit before the server starts", async () => {
|
|
26
|
+
let initCalled = false;
|
|
27
|
+
const testPlugin = {
|
|
28
|
+
name: "test-init",
|
|
29
|
+
onInit() {
|
|
30
|
+
initCalled = true;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
let PluginApp1 = class PluginApp1 {
|
|
34
|
+
index() {
|
|
35
|
+
return "ok";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
GetMapping("/"),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", []),
|
|
42
|
+
__metadata("design:returntype", void 0)
|
|
43
|
+
], PluginApp1.prototype, "index", null);
|
|
44
|
+
PluginApp1 = __decorate([
|
|
45
|
+
CinnabunAppDecorator({ port: 0, scanPaths: [], plugins: [testPlugin] }),
|
|
46
|
+
RestController()
|
|
47
|
+
], PluginApp1);
|
|
48
|
+
app = await CinnabunFactory.run(PluginApp1);
|
|
49
|
+
expect(initCalled).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
it("calls onReady after the server starts", async () => {
|
|
52
|
+
let readyCalled = false;
|
|
53
|
+
const testPlugin = {
|
|
54
|
+
name: "test-ready",
|
|
55
|
+
onReady() {
|
|
56
|
+
readyCalled = true;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
let PluginApp2 = class PluginApp2 {
|
|
60
|
+
index() {
|
|
61
|
+
return "ok";
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
__decorate([
|
|
65
|
+
GetMapping("/"),
|
|
66
|
+
__metadata("design:type", Function),
|
|
67
|
+
__metadata("design:paramtypes", []),
|
|
68
|
+
__metadata("design:returntype", void 0)
|
|
69
|
+
], PluginApp2.prototype, "index", null);
|
|
70
|
+
PluginApp2 = __decorate([
|
|
71
|
+
CinnabunAppDecorator({ port: 0, scanPaths: [], plugins: [testPlugin] }),
|
|
72
|
+
RestController()
|
|
73
|
+
], PluginApp2);
|
|
74
|
+
app = await CinnabunFactory.run(PluginApp2);
|
|
75
|
+
expect(readyCalled).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
it("calls onShutdown when app closes", async () => {
|
|
78
|
+
let shutdownCalled = false;
|
|
79
|
+
const testPlugin = {
|
|
80
|
+
name: "test-shutdown",
|
|
81
|
+
onShutdown() {
|
|
82
|
+
shutdownCalled = true;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
let PluginApp3 = class PluginApp3 {
|
|
86
|
+
index() {
|
|
87
|
+
return "ok";
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
__decorate([
|
|
91
|
+
GetMapping("/"),
|
|
92
|
+
__metadata("design:type", Function),
|
|
93
|
+
__metadata("design:paramtypes", []),
|
|
94
|
+
__metadata("design:returntype", void 0)
|
|
95
|
+
], PluginApp3.prototype, "index", null);
|
|
96
|
+
PluginApp3 = __decorate([
|
|
97
|
+
CinnabunAppDecorator({ port: 0, scanPaths: [], plugins: [testPlugin] }),
|
|
98
|
+
RestController()
|
|
99
|
+
], PluginApp3);
|
|
100
|
+
app = await CinnabunFactory.run(PluginApp3);
|
|
101
|
+
expect(shutdownCalled).toBe(false);
|
|
102
|
+
await app.close();
|
|
103
|
+
expect(shutdownCalled).toBe(true);
|
|
104
|
+
app = null;
|
|
105
|
+
});
|
|
106
|
+
it("provides container and config in plugin context", async () => {
|
|
107
|
+
let receivedContext = null;
|
|
108
|
+
const testPlugin = {
|
|
109
|
+
name: "test-context",
|
|
110
|
+
onInit(context) {
|
|
111
|
+
receivedContext = context;
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
let PluginApp4 = class PluginApp4 {
|
|
115
|
+
index() {
|
|
116
|
+
return "ok";
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
__decorate([
|
|
120
|
+
GetMapping("/"),
|
|
121
|
+
__metadata("design:type", Function),
|
|
122
|
+
__metadata("design:paramtypes", []),
|
|
123
|
+
__metadata("design:returntype", void 0)
|
|
124
|
+
], PluginApp4.prototype, "index", null);
|
|
125
|
+
PluginApp4 = __decorate([
|
|
126
|
+
CinnabunAppDecorator({ port: 0, scanPaths: [], plugins: [testPlugin] }),
|
|
127
|
+
RestController()
|
|
128
|
+
], PluginApp4);
|
|
129
|
+
app = await CinnabunFactory.run(PluginApp4);
|
|
130
|
+
expect(receivedContext).not.toBeNull();
|
|
131
|
+
expect(receivedContext.container).toBeDefined();
|
|
132
|
+
expect(receivedContext.config).toBeDefined();
|
|
133
|
+
});
|
|
134
|
+
it("plugins can register providers via container", async () => {
|
|
135
|
+
let PluginService = class PluginService {
|
|
136
|
+
getValue() {
|
|
137
|
+
return "from-plugin";
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
PluginService = __decorate([
|
|
141
|
+
Service()
|
|
142
|
+
], PluginService);
|
|
143
|
+
const testPlugin = {
|
|
144
|
+
name: "test-register",
|
|
145
|
+
onInit(context) {
|
|
146
|
+
context.container.resolve(PluginService);
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
let PluginApp5 = class PluginApp5 {
|
|
150
|
+
index() {
|
|
151
|
+
return "ok";
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
__decorate([
|
|
155
|
+
GetMapping("/"),
|
|
156
|
+
__metadata("design:type", Function),
|
|
157
|
+
__metadata("design:paramtypes", []),
|
|
158
|
+
__metadata("design:returntype", void 0)
|
|
159
|
+
], PluginApp5.prototype, "index", null);
|
|
160
|
+
PluginApp5 = __decorate([
|
|
161
|
+
CinnabunAppDecorator({ port: 0, scanPaths: [], plugins: [testPlugin] }),
|
|
162
|
+
RestController()
|
|
163
|
+
], PluginApp5);
|
|
164
|
+
app = await CinnabunFactory.run(PluginApp5);
|
|
165
|
+
const svc = app.getContainer().resolve(PluginService);
|
|
166
|
+
expect(svc.getValue()).toBe("from-plugin");
|
|
167
|
+
});
|
|
168
|
+
it("executes multiple plugins in registration order", async () => {
|
|
169
|
+
const order = [];
|
|
170
|
+
const plugin1 = {
|
|
171
|
+
name: "first",
|
|
172
|
+
onInit() {
|
|
173
|
+
order.push("first-init");
|
|
174
|
+
},
|
|
175
|
+
onReady() {
|
|
176
|
+
order.push("first-ready");
|
|
177
|
+
},
|
|
178
|
+
onShutdown() {
|
|
179
|
+
order.push("first-shutdown");
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
const plugin2 = {
|
|
183
|
+
name: "second",
|
|
184
|
+
onInit() {
|
|
185
|
+
order.push("second-init");
|
|
186
|
+
},
|
|
187
|
+
onReady() {
|
|
188
|
+
order.push("second-ready");
|
|
189
|
+
},
|
|
190
|
+
onShutdown() {
|
|
191
|
+
order.push("second-shutdown");
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
let PluginApp6 = class PluginApp6 {
|
|
195
|
+
index() {
|
|
196
|
+
return "ok";
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
__decorate([
|
|
200
|
+
GetMapping("/"),
|
|
201
|
+
__metadata("design:type", Function),
|
|
202
|
+
__metadata("design:paramtypes", []),
|
|
203
|
+
__metadata("design:returntype", void 0)
|
|
204
|
+
], PluginApp6.prototype, "index", null);
|
|
205
|
+
PluginApp6 = __decorate([
|
|
206
|
+
CinnabunAppDecorator({
|
|
207
|
+
port: 0,
|
|
208
|
+
scanPaths: [],
|
|
209
|
+
plugins: [plugin1, plugin2],
|
|
210
|
+
}),
|
|
211
|
+
RestController()
|
|
212
|
+
], PluginApp6);
|
|
213
|
+
app = await CinnabunFactory.run(PluginApp6);
|
|
214
|
+
expect(order).toEqual([
|
|
215
|
+
"first-init",
|
|
216
|
+
"second-init",
|
|
217
|
+
"first-ready",
|
|
218
|
+
"second-ready",
|
|
219
|
+
]);
|
|
220
|
+
await app.close();
|
|
221
|
+
expect(order).toEqual([
|
|
222
|
+
"first-init",
|
|
223
|
+
"second-init",
|
|
224
|
+
"first-ready",
|
|
225
|
+
"second-ready",
|
|
226
|
+
"first-shutdown",
|
|
227
|
+
"second-shutdown",
|
|
228
|
+
]);
|
|
229
|
+
app = null;
|
|
230
|
+
});
|
|
231
|
+
it("works with async plugin hooks", async () => {
|
|
232
|
+
let asyncResult = "";
|
|
233
|
+
const testPlugin = {
|
|
234
|
+
name: "test-async",
|
|
235
|
+
async onInit() {
|
|
236
|
+
await new Promise((r) => setTimeout(r, 10));
|
|
237
|
+
asyncResult += "init-";
|
|
238
|
+
},
|
|
239
|
+
async onReady() {
|
|
240
|
+
await new Promise((r) => setTimeout(r, 10));
|
|
241
|
+
asyncResult += "ready";
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
let PluginApp7 = class PluginApp7 {
|
|
245
|
+
index() {
|
|
246
|
+
return "ok";
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
__decorate([
|
|
250
|
+
GetMapping("/"),
|
|
251
|
+
__metadata("design:type", Function),
|
|
252
|
+
__metadata("design:paramtypes", []),
|
|
253
|
+
__metadata("design:returntype", void 0)
|
|
254
|
+
], PluginApp7.prototype, "index", null);
|
|
255
|
+
PluginApp7 = __decorate([
|
|
256
|
+
CinnabunAppDecorator({ port: 0, scanPaths: [], plugins: [testPlugin] }),
|
|
257
|
+
RestController()
|
|
258
|
+
], PluginApp7);
|
|
259
|
+
app = await CinnabunFactory.run(PluginApp7);
|
|
260
|
+
expect(asyncResult).toBe("init-ready");
|
|
261
|
+
});
|
|
262
|
+
it("app works normally without plugins", async () => {
|
|
263
|
+
let PluginApp8 = class PluginApp8 {
|
|
264
|
+
ping() {
|
|
265
|
+
return "pong";
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
__decorate([
|
|
269
|
+
GetMapping("/ping"),
|
|
270
|
+
__metadata("design:type", Function),
|
|
271
|
+
__metadata("design:paramtypes", []),
|
|
272
|
+
__metadata("design:returntype", void 0)
|
|
273
|
+
], PluginApp8.prototype, "ping", null);
|
|
274
|
+
PluginApp8 = __decorate([
|
|
275
|
+
CinnabunAppDecorator({ port: 0, scanPaths: [] }),
|
|
276
|
+
RestController()
|
|
277
|
+
], PluginApp8);
|
|
278
|
+
app = await CinnabunFactory.run(PluginApp8);
|
|
279
|
+
const res = await fetch(`http://localhost:${app.getPort()}/ping`);
|
|
280
|
+
expect(await res.text()).toBe("pong");
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
//# sourceMappingURL=plugin.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.test.js","sourceRoot":"","sources":["../../src/__tests__/plugin.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAInD,IAAI,GAAG,GAA+B,IAAI,CAAC;AAE3C,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;QAClB,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,MAAM,UAAU,GAAmB;YACjC,IAAI,EAAE,WAAW;YACjB,MAAM;gBACJ,UAAU,GAAG,I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YAChB,CAAC;SACF,CAAA;QAHC;YADC,UAAU,CAAC,OAAO,CAAC;;;;8CAGnB;QAJG,UAAU;YAFf,oBAAoB,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;YAChD,cAAc,EAAE;WACX,UAAU,CAKf;QAED,GAAG,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,oBAAoB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { describe, test, expect, beforeAll, afterAll } from "bun:test";
|
|
11
|
+
import { CinnabunFactory } from "../core/cinnabun-factory.js";
|
|
12
|
+
import { CinnabunApplication as CinnabunAppDecorator } from "../decorators/cinnabun-application.js";
|
|
13
|
+
import { RestController } from "../decorators/rest-controller.js";
|
|
14
|
+
import { GetMapping, PostMapping } from "../decorators/routes.js";
|
|
15
|
+
import { RequestLoggerMiddleware } from "../middleware/request-logger.middleware.js";
|
|
16
|
+
import { PerformanceTrackerMiddleware } from "../middleware/performance-tracker.middleware.js";
|
|
17
|
+
describe("RequestLoggerMiddleware", () => {
|
|
18
|
+
let app = null;
|
|
19
|
+
let port;
|
|
20
|
+
beforeAll(async () => {
|
|
21
|
+
let TestApp = class TestApp {
|
|
22
|
+
test() {
|
|
23
|
+
return { message: "test" };
|
|
24
|
+
}
|
|
25
|
+
create() {
|
|
26
|
+
return { id: 1 };
|
|
27
|
+
}
|
|
28
|
+
error() {
|
|
29
|
+
throw new Error("Test error");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
__decorate([
|
|
33
|
+
GetMapping("/test"),
|
|
34
|
+
__metadata("design:type", Function),
|
|
35
|
+
__metadata("design:paramtypes", []),
|
|
36
|
+
__metadata("design:returntype", void 0)
|
|
37
|
+
], TestApp.prototype, "test", null);
|
|
38
|
+
__decorate([
|
|
39
|
+
PostMapping("/create"),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", []),
|
|
42
|
+
__metadata("design:returntype", void 0)
|
|
43
|
+
], TestApp.prototype, "create", null);
|
|
44
|
+
__decorate([
|
|
45
|
+
GetMapping("/error"),
|
|
46
|
+
__metadata("design:type", Function),
|
|
47
|
+
__metadata("design:paramtypes", []),
|
|
48
|
+
__metadata("design:returntype", void 0)
|
|
49
|
+
], TestApp.prototype, "error", null);
|
|
50
|
+
TestApp = __decorate([
|
|
51
|
+
CinnabunAppDecorator({
|
|
52
|
+
port: 0,
|
|
53
|
+
scanPaths: [],
|
|
54
|
+
middleware: [RequestLoggerMiddleware],
|
|
55
|
+
}),
|
|
56
|
+
RestController("/")
|
|
57
|
+
], TestApp);
|
|
58
|
+
app = await CinnabunFactory.run(TestApp);
|
|
59
|
+
port = app.getPort();
|
|
60
|
+
});
|
|
61
|
+
afterAll(async () => {
|
|
62
|
+
if (app) {
|
|
63
|
+
await app.close();
|
|
64
|
+
app = null;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
test("generates request ID and adds to response headers", async () => {
|
|
68
|
+
const response = await fetch(`http://localhost:${port}/test`);
|
|
69
|
+
const requestId = response.headers.get("x-request-id");
|
|
70
|
+
expect(requestId).toBeDefined();
|
|
71
|
+
expect(requestId).toMatch(/^req_\d+_[a-z0-9]+$/);
|
|
72
|
+
});
|
|
73
|
+
test("propagates request ID from request header", async () => {
|
|
74
|
+
const customId = "custom-request-id-123";
|
|
75
|
+
const response = await fetch(`http://localhost:${port}/test`, {
|
|
76
|
+
headers: {
|
|
77
|
+
"x-request-id": customId,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
expect(response.headers.get("x-request-id")).toBe(customId);
|
|
81
|
+
});
|
|
82
|
+
test("handles POST requests", async () => {
|
|
83
|
+
const response = await fetch(`http://localhost:${port}/create`, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: {
|
|
86
|
+
"content-type": "application/json",
|
|
87
|
+
},
|
|
88
|
+
body: JSON.stringify({ name: "test" }),
|
|
89
|
+
});
|
|
90
|
+
expect(response.status).toBe(200);
|
|
91
|
+
expect(response.headers.get("x-request-id")).toBeDefined();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe("RequestLoggerMiddleware - custom options", () => {
|
|
95
|
+
let app = null;
|
|
96
|
+
let port;
|
|
97
|
+
beforeAll(async () => {
|
|
98
|
+
let TestApp = class TestApp {
|
|
99
|
+
test() {
|
|
100
|
+
return { message: "test" };
|
|
101
|
+
}
|
|
102
|
+
health() {
|
|
103
|
+
return { status: "ok" };
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
__decorate([
|
|
107
|
+
GetMapping("/test"),
|
|
108
|
+
__metadata("design:type", Function),
|
|
109
|
+
__metadata("design:paramtypes", []),
|
|
110
|
+
__metadata("design:returntype", void 0)
|
|
111
|
+
], TestApp.prototype, "test", null);
|
|
112
|
+
__decorate([
|
|
113
|
+
GetMapping("/health"),
|
|
114
|
+
__metadata("design:type", Function),
|
|
115
|
+
__metadata("design:paramtypes", []),
|
|
116
|
+
__metadata("design:returntype", void 0)
|
|
117
|
+
], TestApp.prototype, "health", null);
|
|
118
|
+
TestApp = __decorate([
|
|
119
|
+
CinnabunAppDecorator({
|
|
120
|
+
port: 0,
|
|
121
|
+
scanPaths: [],
|
|
122
|
+
middleware: [
|
|
123
|
+
new RequestLoggerMiddleware({
|
|
124
|
+
skip: (req) => {
|
|
125
|
+
const url = new URL(req.url);
|
|
126
|
+
return url.pathname === "/health";
|
|
127
|
+
},
|
|
128
|
+
requestIdHeader: "x-correlation-id",
|
|
129
|
+
}),
|
|
130
|
+
],
|
|
131
|
+
}),
|
|
132
|
+
RestController("/")
|
|
133
|
+
], TestApp);
|
|
134
|
+
app = await CinnabunFactory.run(TestApp);
|
|
135
|
+
port = app.getPort();
|
|
136
|
+
});
|
|
137
|
+
afterAll(async () => {
|
|
138
|
+
if (app) {
|
|
139
|
+
await app.close();
|
|
140
|
+
app = null;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
test("uses custom request ID header", async () => {
|
|
144
|
+
const customId = "correlation-abc-123";
|
|
145
|
+
const response = await fetch(`http://localhost:${port}/test`, {
|
|
146
|
+
headers: {
|
|
147
|
+
"x-correlation-id": customId,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
expect(response.headers.get("x-correlation-id")).toBe(customId);
|
|
151
|
+
});
|
|
152
|
+
test("skips logging for specified paths", async () => {
|
|
153
|
+
// Health endpoint should not have request ID header added (since logging is skipped)
|
|
154
|
+
const response = await fetch(`http://localhost:${port}/health`);
|
|
155
|
+
// Request should still succeed
|
|
156
|
+
expect(response.status).toBe(200);
|
|
157
|
+
const data = await response.json();
|
|
158
|
+
expect(data.status).toBe("ok");
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
describe("PerformanceTrackerMiddleware", () => {
|
|
162
|
+
let app = null;
|
|
163
|
+
let port;
|
|
164
|
+
let tracker;
|
|
165
|
+
beforeAll(async () => {
|
|
166
|
+
tracker = new PerformanceTrackerMiddleware(100); // 100ms threshold
|
|
167
|
+
let TestApp = class TestApp {
|
|
168
|
+
fast() {
|
|
169
|
+
return { message: "fast" };
|
|
170
|
+
}
|
|
171
|
+
async slow() {
|
|
172
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
173
|
+
return { message: "slow" };
|
|
174
|
+
}
|
|
175
|
+
async medium() {
|
|
176
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
177
|
+
return { message: "medium" };
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
__decorate([
|
|
181
|
+
GetMapping("/fast"),
|
|
182
|
+
__metadata("design:type", Function),
|
|
183
|
+
__metadata("design:paramtypes", []),
|
|
184
|
+
__metadata("design:returntype", void 0)
|
|
185
|
+
], TestApp.prototype, "fast", null);
|
|
186
|
+
__decorate([
|
|
187
|
+
GetMapping("/slow"),
|
|
188
|
+
__metadata("design:type", Function),
|
|
189
|
+
__metadata("design:paramtypes", []),
|
|
190
|
+
__metadata("design:returntype", Promise)
|
|
191
|
+
], TestApp.prototype, "slow", null);
|
|
192
|
+
__decorate([
|
|
193
|
+
GetMapping("/medium"),
|
|
194
|
+
__metadata("design:type", Function),
|
|
195
|
+
__metadata("design:paramtypes", []),
|
|
196
|
+
__metadata("design:returntype", Promise)
|
|
197
|
+
], TestApp.prototype, "medium", null);
|
|
198
|
+
TestApp = __decorate([
|
|
199
|
+
CinnabunAppDecorator({
|
|
200
|
+
port: 0,
|
|
201
|
+
scanPaths: [],
|
|
202
|
+
middleware: [tracker],
|
|
203
|
+
}),
|
|
204
|
+
RestController("/")
|
|
205
|
+
], TestApp);
|
|
206
|
+
app = await CinnabunFactory.run(TestApp);
|
|
207
|
+
port = app.getPort();
|
|
208
|
+
});
|
|
209
|
+
afterAll(async () => {
|
|
210
|
+
if (app) {
|
|
211
|
+
await app.close();
|
|
212
|
+
app = null;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
test("tracks request metrics", async () => {
|
|
216
|
+
tracker.clear();
|
|
217
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
218
|
+
const metrics = tracker.getMetrics("/fast");
|
|
219
|
+
expect(metrics.length).toBe(1);
|
|
220
|
+
expect(metrics[0].path).toBe("/fast");
|
|
221
|
+
expect(metrics[0].method).toBe("GET");
|
|
222
|
+
expect(metrics[0].status).toBe(200);
|
|
223
|
+
expect(metrics[0].duration).toBeGreaterThanOrEqual(0);
|
|
224
|
+
});
|
|
225
|
+
test("detects slow requests", async () => {
|
|
226
|
+
tracker.clear();
|
|
227
|
+
await fetch(`http://localhost:${port}/slow`);
|
|
228
|
+
const metrics = tracker.getMetrics("/slow");
|
|
229
|
+
expect(metrics.length).toBe(1);
|
|
230
|
+
expect(metrics[0].duration).toBeGreaterThanOrEqual(100);
|
|
231
|
+
});
|
|
232
|
+
test("calculates average response time", async () => {
|
|
233
|
+
tracker.clear();
|
|
234
|
+
// Make multiple requests
|
|
235
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
236
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
237
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
238
|
+
const avgTime = tracker.getAverageResponseTime("/fast");
|
|
239
|
+
expect(avgTime).toBeGreaterThanOrEqual(0);
|
|
240
|
+
expect(avgTime).toBeLessThan(100);
|
|
241
|
+
});
|
|
242
|
+
test("calculates percentiles", async () => {
|
|
243
|
+
tracker.clear();
|
|
244
|
+
// Make requests with different speeds
|
|
245
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
246
|
+
await fetch(`http://localhost:${port}/medium`);
|
|
247
|
+
await fetch(`http://localhost:${port}/slow`);
|
|
248
|
+
const p50 = tracker.getPercentile(50);
|
|
249
|
+
const p95 = tracker.getPercentile(95);
|
|
250
|
+
expect(p50).toBeGreaterThanOrEqual(0);
|
|
251
|
+
expect(p95).toBeGreaterThanOrEqual(p50);
|
|
252
|
+
});
|
|
253
|
+
test("gets all metrics when no path specified", async () => {
|
|
254
|
+
tracker.clear();
|
|
255
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
256
|
+
await fetch(`http://localhost:${port}/slow`);
|
|
257
|
+
const allMetrics = tracker.getMetrics();
|
|
258
|
+
expect(allMetrics.length).toBe(2);
|
|
259
|
+
});
|
|
260
|
+
test("filters metrics by path", async () => {
|
|
261
|
+
tracker.clear();
|
|
262
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
263
|
+
await fetch(`http://localhost:${port}/slow`);
|
|
264
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
265
|
+
const fastMetrics = tracker.getMetrics("/fast");
|
|
266
|
+
const slowMetrics = tracker.getMetrics("/slow");
|
|
267
|
+
expect(fastMetrics.length).toBe(2);
|
|
268
|
+
expect(slowMetrics.length).toBe(1);
|
|
269
|
+
});
|
|
270
|
+
test("maintains max metrics limit", async () => {
|
|
271
|
+
tracker.clear();
|
|
272
|
+
// The maxMetrics is 1000, but we'll just verify the mechanism works
|
|
273
|
+
// by checking that metrics are stored
|
|
274
|
+
for (let i = 0; i < 10; i++) {
|
|
275
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
276
|
+
}
|
|
277
|
+
const metrics = tracker.getMetrics();
|
|
278
|
+
expect(metrics.length).toBe(10);
|
|
279
|
+
});
|
|
280
|
+
test("clear() removes all metrics", async () => {
|
|
281
|
+
tracker.clear();
|
|
282
|
+
await fetch(`http://localhost:${port}/fast`);
|
|
283
|
+
expect(tracker.getMetrics().length).toBe(1);
|
|
284
|
+
tracker.clear();
|
|
285
|
+
expect(tracker.getMetrics().length).toBe(0);
|
|
286
|
+
});
|
|
287
|
+
test("returns 0 for average when no metrics", async () => {
|
|
288
|
+
tracker.clear();
|
|
289
|
+
const avg = tracker.getAverageResponseTime();
|
|
290
|
+
expect(avg).toBe(0);
|
|
291
|
+
});
|
|
292
|
+
test("returns 0 for percentile when no metrics", async () => {
|
|
293
|
+
tracker.clear();
|
|
294
|
+
const p95 = tracker.getPercentile(95);
|
|
295
|
+
expect(p95).toBe(0);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
describe("Combined middleware", () => {
|
|
299
|
+
let app = null;
|
|
300
|
+
let port;
|
|
301
|
+
let tracker;
|
|
302
|
+
beforeAll(async () => {
|
|
303
|
+
tracker = new PerformanceTrackerMiddleware(100);
|
|
304
|
+
let TestApp = class TestApp {
|
|
305
|
+
test() {
|
|
306
|
+
return { message: "test" };
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
__decorate([
|
|
310
|
+
GetMapping("/test"),
|
|
311
|
+
__metadata("design:type", Function),
|
|
312
|
+
__metadata("design:paramtypes", []),
|
|
313
|
+
__metadata("design:returntype", void 0)
|
|
314
|
+
], TestApp.prototype, "test", null);
|
|
315
|
+
TestApp = __decorate([
|
|
316
|
+
CinnabunAppDecorator({
|
|
317
|
+
port: 0,
|
|
318
|
+
scanPaths: [],
|
|
319
|
+
middleware: [RequestLoggerMiddleware, tracker],
|
|
320
|
+
}),
|
|
321
|
+
RestController("/")
|
|
322
|
+
], TestApp);
|
|
323
|
+
app = await CinnabunFactory.run(TestApp);
|
|
324
|
+
port = app.getPort();
|
|
325
|
+
});
|
|
326
|
+
afterAll(async () => {
|
|
327
|
+
if (app) {
|
|
328
|
+
await app.close();
|
|
329
|
+
app = null;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
test("both middlewares work together", async () => {
|
|
333
|
+
tracker.clear();
|
|
334
|
+
const response = await fetch(`http://localhost:${port}/test`);
|
|
335
|
+
// Request logger adds request ID
|
|
336
|
+
expect(response.headers.get("x-request-id")).toBeDefined();
|
|
337
|
+
// Performance tracker records metrics
|
|
338
|
+
const metrics = tracker.getMetrics("/test");
|
|
339
|
+
expect(metrics.length).toBe(1);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
//# sourceMappingURL=request-logger.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-logger.test.js","sourceRoot":"","sources":["../../src/__tests__/request-logger.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAG/F,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,GAAG,GAA+B,IAAI,CAAC;IAC3C,IAAI,IAAY,CAAC;IAEjB,SAAS,CAAC,KAAK,IAAI,EAAE;QAOnB,IAAM,OAAO,GAAb,MAAM,OAAO;YAEX,IAAI;gBACF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC7B,CAAC;YAGD,MAAM;gBACJ,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;YACnB,CAAC;YAGD,KAAK;gBACH,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;YAChC,CAAC;SACF,CAAA;QAbC;YADC,UAAU,CAAC,OAAO,CAAC;;;;2CAGnB;QAGD;YADC,WAAW,CAAC,SAAS,CAAC;;;;6CAGtB;QAGD;YADC,UAAU,CAAC,QAAQ,CAAC;;;;4CAGpB;QAdG,OAAO;YANZ,oBAAoB,CAAC;gBACpB,IAAI,EAAE,CAAC;gBACP,SAAS,EAAE,EAAE;gBACb,U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