Browse Source

clean code and move @types package to devDep

Signed-off-by: Gitea <zizhao.chen@zilliz.com>
Gitea 3 years ago
parent
commit
024551fcc0
2 changed files with 2 additions and 46 deletions
  1. 2 2
      express/package.json
  2. 0 44
      express/src/middlewares/index.ts

+ 2 - 2
express/package.json

@@ -4,8 +4,6 @@
   "main": "dist/app.js",
   "license": "MIT",
   "dependencies": {
-    "@types/chalk": "^2.2.0",
-    "@types/morgan": "^1.9.3",
     "@zilliz/milvus2-sdk-node": "^1.0.19",
     "chalk": "^4.1.2",
     "cors": "^2.8.5",
@@ -19,6 +17,8 @@
     "socket.io": "^4.3.1"
   },
   "devDependencies": {
+    "@types/chalk": "^2.2.0",
+    "@types/morgan": "^1.9.3",
     "@types/cors": "^2.8.12",
     "@types/express": "^4.17.13",
     "@types/glob": "^7.2.0",

+ 0 - 44
express/src/middlewares/index.ts

@@ -22,50 +22,6 @@ export const TransformResMiddlerware = (
   next();
 };
 
-const getDurationInMilliseconds = (start: any) => {
-  const NS_PER_SEC = 1e9;
-  const NS_TO_MS = 1e6;
-  const diff = process.hrtime(start);
-
-  return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS;
-};
-
-/**
- * Add spent time looger when accessing milvus.
- */
-// export const LoggingMiddleware = (
-//   req: Request,
-//   res: Response,
-//   next: NextFunction
-// ) => {
-//   console.log(`${req.method} ${req.originalUrl} [STARTED]`);
-//   const start = process.hrtime();
-//   const { ip = "", method = "", originalUrl = "", headers = {} } = req;
-//   const ua = headers["user-agent"] || "";
-
-//   res.on("finish", () => {
-//     const durationInMilliseconds = getDurationInMilliseconds(start);
-//     console.log(
-//       `${req.method} ${
-//         req.originalUrl
-//       } [FINISHED] ${durationInMilliseconds.toLocaleString()} ms`
-//     );
-//   });
-
-//   res.on("close", () => {
-//     const durationInMilliseconds = getDurationInMilliseconds(start);
-//     const { statusCode = "" } = res;
-//     // TODO: Need some special log instead of console.log
-//     console.log(
-//       `${req.method} ${
-//         req.originalUrl
-//       } [CLOSED] ${durationInMilliseconds.toLocaleString()} ms ip:${ip} ua:${ua} status:${statusCode}`
-//     );
-//   });
-
-//   next();
-// };
-
 /**
  * Handle error in here.
  * Normally depend on status which from milvus service.