@valentine-efagene/qshelter-common 2.0.133 → 2.0.135

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.
@@ -2,5 +2,7 @@ import { Request, Response, NextFunction } from 'express';
2
2
  /**
3
3
  * Request logging middleware that logs method, path, status code, and duration.
4
4
  * Logs in JSON format for easy parsing by log aggregation tools.
5
+ *
6
+ * In debug mode, also logs the authorizer context from API Gateway.
5
7
  */
6
8
  export declare function requestLogger(req: Request, res: Response, next: NextFunction): void;
@@ -1,9 +1,27 @@
1
1
  /**
2
2
  * Request logging middleware that logs method, path, status code, and duration.
3
3
  * Logs in JSON format for easy parsing by log aggregation tools.
4
+ *
5
+ * In debug mode, also logs the authorizer context from API Gateway.
4
6
  */
5
7
  export function requestLogger(req, res, next) {
6
8
  const start = Date.now();
9
+ // Debug: Log authorizer context structure
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ const lambdaReq = req;
12
+ const authorizer = lambdaReq.apiGateway?.event?.requestContext?.authorizer;
13
+ if (process.env.DEBUG_AUTH === 'true' || process.env.NODE_ENV !== 'production') {
14
+ console.log(JSON.stringify({
15
+ type: 'auth_debug',
16
+ path: req.path,
17
+ hasApiGateway: !!lambdaReq.apiGateway,
18
+ hasEvent: !!lambdaReq.apiGateway?.event,
19
+ hasRequestContext: !!lambdaReq.apiGateway?.event?.requestContext,
20
+ hasAuthorizer: !!authorizer,
21
+ authorizerKeys: authorizer ? Object.keys(authorizer) : [],
22
+ authorizer: authorizer,
23
+ }));
24
+ }
7
25
  res.on('finish', () => {
8
26
  const duration = Date.now() - start;
9
27
  console.log(JSON.stringify({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.133",
3
+ "version": "2.0.135",
4
4
  "description": "Shared database schemas and utilities for QShelter services",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",