Browse Source

1.0.5: httpLogger is optional

CrazyDoctor 7 months ago
parent
commit
fe2902d57a

+ 1 - 0
dist/middlewares/InternalServerErrorHandler.js

@@ -8,6 +8,7 @@ class InternalServerErrorHandler extends http_1.Middleware {
         this.order = 10000;
         this.order = 10000;
         this.route = null;
         this.route = null;
         this.action = (err, req, res, next) => {
         this.action = (err, req, res, next) => {
+            this.context.logError(`${err.message}: ${err.stack}`);
             res.status(http_1.StatusCodes.INTERNAL_SERVER_ERROR).send((0, i18n_1.$$)('org.crazydoctor.expressts.httpError.500'));
             res.status(http_1.StatusCodes.INTERNAL_SERVER_ERROR).send((0, i18n_1.$$)('org.crazydoctor.expressts.httpError.500'));
         };
         };
     }
     }

+ 1 - 1
dist/middlewares/InternalServerErrorHandler.js.map

@@ -1 +1 @@
-{"version":3,"file":"InternalServerErrorHandler.js","sourceRoot":"","sources":["../../lib/middlewares/InternalServerErrorHandler.ts"],"names":[],"mappings":";;AAAA,uCAAuD;AAEvD,uCAAkC;AAElC,MAAM,0BAA2B,SAAQ,iBAAU;IAAnD;;QACW,UAAK,GAAG,KAAK,CAAC;QACd,UAAK,GAAG,IAAI,CAAC;QACb,WAAM,GAAG,CAAC,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAO,EAAE;YACvF,GAAG,CAAC,MAAM,CAAC,kBAAW,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,IAAA,SAAE,EAAC,yCAAyC,CAAC,CAAC,CAAC;QACnG,CAAC,CAAC;IACH,CAAC;CAAA;AAED,kBAAe,0BAA0B,CAAC"}
+{"version":3,"file":"InternalServerErrorHandler.js","sourceRoot":"","sources":["../../lib/middlewares/InternalServerErrorHandler.ts"],"names":[],"mappings":";;AAAA,uCAAuD;AAEvD,uCAAkC;AAElC,MAAM,0BAA2B,SAAQ,iBAAU;IAAnD;;QACW,UAAK,GAAG,KAAK,CAAC;QACd,UAAK,GAAG,IAAI,CAAC;QACb,WAAM,GAAG,CAAC,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAO,EAAE;YACvF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;YACtD,GAAG,CAAC,MAAM,CAAC,kBAAW,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,IAAA,SAAE,EAAC,yCAAyC,CAAC,CAAC,CAAC;QACnG,CAAC,CAAC;IACH,CAAC;CAAA;AAED,kBAAe,0BAA0B,CAAC"}

+ 2 - 1
dist/middlewares/LoggerMiddleware.d.ts

@@ -1,7 +1,8 @@
 import { Middleware } from '../base/http';
 import { Middleware } from '../base/http';
+import { NextFunction, Request, Response } from 'express';
 declare class LoggerMiddleware extends Middleware {
 declare class LoggerMiddleware extends Middleware {
     protected order: number;
     protected order: number;
     protected route: null;
     protected route: null;
-    protected action: import("pino-http").HttpLogger;
+    protected action: (res: Response, req: Request, next: NextFunction) => any;
 }
 }
 export default LoggerMiddleware;
 export default LoggerMiddleware;

+ 5 - 1
dist/middlewares/LoggerMiddleware.js

@@ -1,12 +1,16 @@
 "use strict";
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 Object.defineProperty(exports, "__esModule", { value: true });
 const http_1 = require("../base/http");
 const http_1 = require("../base/http");
+// import { Logger } from '../base/logger';
 class LoggerMiddleware extends http_1.Middleware {
 class LoggerMiddleware extends http_1.Middleware {
     constructor() {
     constructor() {
         super(...arguments);
         super(...arguments);
         this.order = -97;
         this.order = -97;
         this.route = null;
         this.route = null;
-        this.action = this.context.getLogger().getHttpLogger();
+        // protected action = (<Logger>this.context.getLogger()).getHttpLogger();	
+        this.action = (res, req, next) => {
+            next();
+        };
     }
     }
 }
 }
 exports.default = LoggerMiddleware;
 exports.default = LoggerMiddleware;

+ 1 - 1
dist/middlewares/LoggerMiddleware.js.map

@@ -1 +1 @@
-{"version":3,"file":"LoggerMiddleware.js","sourceRoot":"","sources":["../../lib/middlewares/LoggerMiddleware.ts"],"names":[],"mappings":";;AAAA,uCAA0C;AAG1C,MAAM,gBAAiB,SAAQ,iBAAU;IAAzC;;QACW,UAAK,GAAG,CAAC,EAAE,CAAC;QACZ,UAAK,GAAG,IAAI,CAAC;QACb,WAAM,GAAY,IAAI,CAAC,OAAO,CAAC,SAAS,EAAG,CAAC,aAAa,EAAE,CAAC;IACvE,CAAC;CAAA;AAED,kBAAe,gBAAgB,CAAC"}
+{"version":3,"file":"LoggerMiddleware.js","sourceRoot":"","sources":["../../lib/middlewares/LoggerMiddleware.ts"],"names":[],"mappings":";;AAAA,uCAA0C;AAE1C,2CAA2C;AAE3C,MAAM,gBAAiB,SAAQ,iBAAU;IAAzC;;QACW,UAAK,GAAG,CAAC,EAAE,CAAC;QACZ,UAAK,GAAG,IAAI,CAAC;QACvB,0EAA0E;QAChE,WAAM,GAAG,CAAC,GAAa,EAAE,GAAY,EAAE,IAAkB,EAAO,EAAE;YAC3E,IAAI,EAAE,CAAC;QACR,CAAC,CAAC;IACH,CAAC;CAAA;AAED,kBAAe,gBAAgB,CAAC"}

+ 1 - 0
lib/middlewares/InternalServerErrorHandler.ts

@@ -6,6 +6,7 @@ class InternalServerErrorHandler extends Middleware {
 	protected order = 10000;
 	protected order = 10000;
 	protected route = null;
 	protected route = null;
 	protected action = (err: Error, req: Request, res: Response, next: NextFunction): any => {
 	protected action = (err: Error, req: Request, res: Response, next: NextFunction): any => {
+		this.context.logError(`${err.message}: ${err.stack}`);
 		res.status(StatusCodes.INTERNAL_SERVER_ERROR).send($$('org.crazydoctor.expressts.httpError.500'));
 		res.status(StatusCodes.INTERNAL_SERVER_ERROR).send($$('org.crazydoctor.expressts.httpError.500'));
 	};
 	};
 }
 }

+ 6 - 2
lib/middlewares/LoggerMiddleware.ts

@@ -1,10 +1,14 @@
 import { Middleware } from '../base/http';
 import { Middleware } from '../base/http';
-import { Logger } from '../base/logger';
+import { NextFunction, Request, Response } from 'express';
+// import { Logger } from '../base/logger';
 
 
 class LoggerMiddleware extends Middleware {
 class LoggerMiddleware extends Middleware {
 	protected order = -97;
 	protected order = -97;
 	protected route = null;
 	protected route = null;
-	protected action = (<Logger>this.context.getLogger()).getHttpLogger();
+	// protected action = (<Logger>this.context.getLogger()).getHttpLogger();	
+	protected action = (res: Response, req: Request, next: NextFunction): any => {
+		next();
+	};
 }
 }
 
 
 export default LoggerMiddleware;
 export default LoggerMiddleware;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "org.crazydoctor.expressts",
   "name": "org.crazydoctor.expressts",
-  "version": "1.0.4",
+  "version": "1.0.5",
   "devDependencies": {
   "devDependencies": {
     "@types/express-session": "^1.17.7",
     "@types/express-session": "^1.17.7",
     "@types/node": "^20.4.9",
     "@types/node": "^20.4.9",