lrf hai 11 meses
pai
achega
3337bd898d

+ 4 - 0
README.md

@@ -1,6 +1,10 @@
 # 未完成:
   * [x] 1.代理请求
   * [ ] 2.对数据进行解密
+    - [ ] 2.1 前端生成 加密字符串 并加密 post 请求下的数据, 将加密串带在token中: ${str}:${token}
+    - [ ] 2.2 代理服务将 加密串和token分离: 1.将token归为(删除非token部分) 2.使用加密串 对数据进行解密 给对应的服务
+    - [ ] 2.3 服务返回结果后: 代理服务将返回的结果 使用加密串进行加密 返回前端
+    - [ ] 2.4 前端使用加密串 对返回结果进行解密
 	* [ ]	3.接口鉴权
   * [ ] 4.i18n处理
 

+ 22 - 0
package-lock.json

@@ -18,6 +18,8 @@
         "@midwayjs/koa": "^3.12.0",
         "@midwayjs/logger": "^3.1.0",
         "@midwayjs/validate": "^3.12.0",
+        "@types/crypto-js": "^4.2.2",
+        "crypto-js": "^4.2.0",
         "lodash": "^4.17.21"
       },
       "devDependencies": {
@@ -1478,6 +1480,11 @@
         "@types/node": "*"
       }
     },
+    "node_modules/@types/crypto-js": {
+      "version": "4.2.2",
+      "resolved": "https://registry.npmmirror.com/@types/crypto-js/-/crypto-js-4.2.2.tgz",
+      "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ=="
+    },
     "node_modules/@types/express": {
       "version": "4.17.21",
       "resolved": "https://registry.npmmirror.com/@types/express/-/express-4.17.21.tgz",
@@ -2749,6 +2756,11 @@
         "node": ">= 8"
       }
     },
+    "node_modules/crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    },
     "node_modules/crypto-random-string": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@@ -8704,6 +8716,11 @@
         "@types/node": "*"
       }
     },
+    "@types/crypto-js": {
+      "version": "4.2.2",
+      "resolved": "https://registry.npmmirror.com/@types/crypto-js/-/crypto-js-4.2.2.tgz",
+      "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ=="
+    },
     "@types/express": {
       "version": "4.17.21",
       "resolved": "https://registry.npmmirror.com/@types/express/-/express-4.17.21.tgz",
@@ -9734,6 +9751,11 @@
         "which": "^2.0.1"
       }
     },
+    "crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    },
     "crypto-random-string": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz",

+ 2 - 0
package.json

@@ -13,6 +13,8 @@
     "@midwayjs/koa": "^3.12.0",
     "@midwayjs/logger": "^3.1.0",
     "@midwayjs/validate": "^3.12.0",
+    "@types/crypto-js": "^4.2.2",
+    "crypto-js": "^4.2.0",
     "lodash": "^4.17.21"
   },
   "devDependencies": {

+ 1 - 1
src/config/config.local.ts

@@ -9,7 +9,7 @@ export default {
   axios: {
     clients: {
       // key则为路由前缀
-      '/api': {
+      '/cxyy/api': {
         baseURL: 'http://127.0.0.1:9700',
       },
       '/test/api': {

+ 6 - 2
src/controller/home.controller.ts

@@ -1,4 +1,4 @@
-import { All, Controller, Get, Inject } from '@midwayjs/core';
+import { All, Controller, Get, Inject, Put } from '@midwayjs/core';
 import { Context } from '@midwayjs/koa';
 import { ProxyService } from '../service/proxy.service';
 @Controller('/')
@@ -14,10 +14,14 @@ export class HomeController {
     return 'proxy starting....';
   }
 
+  @Put('/init')
+  async makePairCrypto() {}
+
   @All('/**')
   async proxy() {
-    const rb = this.service.getRequstBase();
+    // const rb = this.service.getRequstBase();
     return await this.service.toProxy();
+    // return false;
     // return 'in proxy';
   }
 }

+ 1 - 0
src/service/proxy.service.ts

@@ -56,6 +56,7 @@ export class ProxyService {
       break;
     }
     if (!url) return;
+    console.log(url);
     const reqConfig: any = {
       url,
       method: rb.method,