unnbound-events 1.0.13 → 1.0.15
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/README.md +2 -0
- package/dist/lib/client.js +14 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ client.get('/health', async () => ({ status: 200, body: { status: 'ok' } }));
|
|
|
27
27
|
await client.start();
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
The client provides a built-in `GET /healthcheck` handler that responds with `204`, so you can skip registering it unless you need custom logic. Add your own handler with the same path to override the default.
|
|
31
|
+
|
|
30
32
|
### Custom Configuration
|
|
31
33
|
|
|
32
34
|
Configure specific transports as needed:
|
package/dist/lib/client.js
CHANGED
|
@@ -49,6 +49,12 @@ exports.defaultIgnoreTraceRoutes = ['/health', '/healthcheck'];
|
|
|
49
49
|
function createEventsClient(ignoreTraceRoutes = exports.defaultIgnoreTraceRoutes) {
|
|
50
50
|
const routes = [];
|
|
51
51
|
const middlewares = [];
|
|
52
|
+
routes.push({
|
|
53
|
+
method: 'GET',
|
|
54
|
+
matcher: '/healthcheck',
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
56
|
+
handler: async () => ({ status: 204 }),
|
|
57
|
+
});
|
|
52
58
|
const traceContextMiddleware = async (request, next) => {
|
|
53
59
|
if ((0, exports.shouldIgnorePath)(request.path, ignoreTraceRoutes)) {
|
|
54
60
|
return next(request);
|
|
@@ -141,9 +147,15 @@ function createEventsClient(ignoreTraceRoutes = exports.defaultIgnoreTraceRoutes
|
|
|
141
147
|
middlewares.push({ matcher, fn });
|
|
142
148
|
},
|
|
143
149
|
async handle(request) {
|
|
144
|
-
|
|
150
|
+
let route;
|
|
151
|
+
for (let i = routes.length - 1; i >= 0; i -= 1) {
|
|
152
|
+
const candidate = routes[i];
|
|
153
|
+
if (candidate.method === request.method && matchPath(candidate.matcher, request.path)) {
|
|
154
|
+
route = candidate;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
145
158
|
if (!route) {
|
|
146
|
-
unnbound_logger_sdk_1.logger.warn({ path: request.path, method: request.method }, 'No route match');
|
|
147
159
|
return { status: 404, body: { message: 'Not Found' } };
|
|
148
160
|
}
|
|
149
161
|
// Build middleware chain for this request (middleware added later will run earlier)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unnbound-events",
|
|
3
3
|
"description": "Unified events SDK to handle HTTP routes and SQS messages with a single routing API.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.15",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"express": "^4.0.0 || ^5.0.0",
|
|
35
35
|
"@aws-sdk/client-sqs": "^3.0.0",
|
|
36
|
-
"unnbound-logger-sdk": "
|
|
36
|
+
"unnbound-logger-sdk": "^3.0.22"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"express": "^4.0.0 || ^5.0.0"
|