xiongzhu преди 2 години
родител
ревизия
cd3433f403
променени са 12 файла, в които са добавени 894 реда и са изтрити 100 реда
  1. 49 0
      .env
  2. 4 4
      .gitignore
  3. 259 60
      graph.json
  4. 2 0
      package.json
  5. 20 2
      src/aliyun/aliyun.service.ts
  6. 3 1
      src/app.module.ts
  7. 18 0
      src/file/file.controller.spec.ts
  8. 19 0
      src/file/file.controller.ts
  9. 11 0
      src/file/file.module.ts
  10. 18 0
      src/file/file.service.spec.ts
  11. 14 0
      src/file/file.service.ts
  12. 477 33
      yarn.lock

+ 49 - 0
.env

@@ -0,0 +1,49 @@
+NODE_ENV="dev"
+NODE_API_PORT=
+
+ENDPOINT_CORS=
+
+SWAGGER_USER=admin
+SWAGGER_PASSWORD=123456
+
+EMAIL_HOST="smtp.mailtrap.io"
+EMAIL_PORT=2525
+EMAIL_AUTH_USER="1"
+EMAIL_AUTH_PASSWORD="1"
+EMAIL_DEBUG=true
+EMAIL_LOGGER=true
+EMAIL_LAYOUT_DIR='/templates/emails/'
+EMAIL_PARTIAL_DIR='/templates/emails/'
+EMAIL_VIEW_PATH='/templates/emails/'
+EMAIL_DEFAULT_LAYOUT='index'
+
+JWT_SECRET_KEY="x9YgTpDbHZC7jfyo!V"
+JWT_TOKEN_AUDIENCE="localhost:3000"
+JWT_TOKEN_ISSUER="localhost:3000"
+JWT_ACCESS_TOKEN_TTL=3600
+
+THROTTLE_TTL=60
+THROTTLE_LIMIT=20
+
+TYPEORM_CONNECTION="mysql"
+TYPEORM_HOST="192.168.6.10"
+TYPEORM_PORT=3306
+TYPEORM_USERNAME=root
+TYPEORM_PASSWORD=123456
+TYPEORM_DATABASE=testnest
+TYPEORM_AUTO_SCHEMA_SYNC=true
+TYPEORM_ENTITIES="dist/**/*.entity.js"
+TYPEORM_SUBSCRIBERS="dist/subscriber/**/*.js"
+TYPEORM_MIGRATIONS="dist/migrations/**/*.js"
+TYPEORM_ENTITIES_DIR="src/entity"
+TYPEORM_MIGRATIONS_DIR="src/migrations"
+TYPEORM_SUBSCRIBERS_DIR="src/subscriber"
+
+ALIYUN_ACCESS_KEY_ID=LTAI5tPoBCiEMSDaS1Q4HKr9
+ALIYUN_ACCESS_KEY_SECRET=F8ZNiqdH35T7gikBkn6Fq8tgbvdY88
+ALIYUN_OSS_ENDPOINT=oss-cn-shenzhen.aliyuncs.com
+ALIYUN_OSS_BUCKET=hc-ai
+ALIYUN_OSS_REGION=oss-cn-shenzhen
+ALIYUN_OSS_CDN=https://cdn.raex.vip
+ALIYUN_SMS_SIGN=华储AI
+ALIYUN_SMS_TEMPLATE_CODE=SMS_228870098

+ 4 - 4
.gitignore

@@ -3,10 +3,10 @@
 /node_modules
 /node_modules
 
 
 # Enviroment
 # Enviroment
-.env
-.env.dev
-.env.stage
-.env.prod
+# .env
+# .env.dev
+# .env.stage
+# .env.prod
 
 
 # Logs
 # Logs
 logs
 logs

+ 259 - 60
graph.json

@@ -1,21 +1,5 @@
 {
 {
   "nodes": {
   "nodes": {
-    "1896425": {
-      "id": "1896425",
-      "label": "CONFIGURABLE_MODULE_OPTIONS[e3b5c74eafc7706f6332f]",
-      "parent": "-1033621697",
-      "metadata": {
-        "type": "provider",
-        "internal": false,
-        "sourceModuleName": "DevtoolsModule",
-        "durable": false,
-        "static": true,
-        "scope": 0,
-        "transient": false,
-        "exported": false,
-        "token": "CONFIGURABLE_MODULE_OPTIONS[e3b5c74eafc7706f6332f]"
-      }
-    },
     "95355232": {
     "95355232": {
       "id": "95355232",
       "id": "95355232",
       "label": "JwtModule",
       "label": "JwtModule",
@@ -30,7 +14,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "JwtModule",
         "token": "JwtModule",
-        "initTime": 1.6359999999403954
+        "initTime": 1.3889579996466637
       }
       }
     },
     },
     "203550704": {
     "203550704": {
@@ -73,7 +57,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "InternalCoreModule",
         "token": "InternalCoreModule",
-        "initTime": 3.4108339995145798
+        "initTime": 2.810791999101639
       }
       }
     },
     },
     "233936880": {
     "233936880": {
@@ -135,7 +119,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "SandboxedCodeExecutor",
         "token": "SandboxedCodeExecutor",
-        "initTime": 3.8920830003917217
+        "initTime": 3.408957999199629
       }
       }
     },
     },
     "385041166": {
     "385041166": {
@@ -151,7 +135,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "JwtStrategy",
         "token": "JwtStrategy",
-        "initTime": 2.7962500005960464
+        "initTime": 2.633415997028351
       }
       }
     },
     },
     "400681591": {
     "400681591": {
@@ -167,7 +151,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "DiscoveryService",
         "token": "DiscoveryService",
-        "initTime": 3.4103749990463257
+        "initTime": 2.79695900157094
       }
       }
     },
     },
     "457665600": {
     "457665600": {
@@ -184,7 +168,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "AliyunModule",
         "token": "AliyunModule",
-        "initTime": 2.057250000536442
+        "initTime": 1.7141249999403954
       }
       }
     },
     },
     "545846241": {
     "545846241": {
@@ -271,7 +255,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "Reflector",
         "token": "Reflector",
-        "initTime": 3.328958000987768
+        "initTime": 2.732208002358675
       }
       }
     },
     },
     "687352615": {
     "687352615": {
@@ -397,7 +381,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "Symbol(CONFIG_SERVICE)",
         "token": "Symbol(CONFIG_SERVICE)",
-        "initTime": 3.3957500010728836
+        "initTime": 2.812959000468254
       }
       }
     },
     },
     "1014874916": {
     "1014874916": {
@@ -429,7 +413,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "CONFIGURATION_TOKEN",
         "token": "CONFIGURATION_TOKEN",
-        "initTime": 2.513374999165535
+        "initTime": 1.9665419980883598
       }
       }
     },
     },
     "1070370213": {
     "1070370213": {
@@ -523,7 +507,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "CONFIGURATION_LOADER",
         "token": "CONFIGURATION_LOADER",
-        "initTime": 3.1135830003768206
+        "initTime": 2.864833001047373
       }
       }
     },
     },
     "1333473084": {
     "1333473084": {
@@ -539,7 +523,40 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "CONFIGURATION_LOADER",
         "token": "CONFIGURATION_LOADER",
-        "initTime": 2.746875001117587
+        "initTime": 2.582125000655651
+      }
+    },
+    "1349506255": {
+      "id": "1349506255",
+      "label": "ModuleRef",
+      "parent": "-1327562795",
+      "metadata": {
+        "type": "provider",
+        "internal": true,
+        "sourceModuleName": "FileModule",
+        "durable": false,
+        "static": true,
+        "scope": 0,
+        "transient": false,
+        "exported": false,
+        "token": "ModuleRef"
+      }
+    },
+    "1376902224": {
+      "id": "1376902224",
+      "label": "FileModule",
+      "parent": "-1327562795",
+      "metadata": {
+        "type": "provider",
+        "internal": true,
+        "sourceModuleName": "FileModule",
+        "durable": false,
+        "static": true,
+        "scope": 0,
+        "transient": false,
+        "exported": false,
+        "token": "FileModule",
+        "initTime": 1.3686669990420341
       }
       }
     },
     },
     "1399306624": {
     "1399306624": {
@@ -556,7 +573,22 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "ThrottlerModule",
         "token": "ThrottlerModule",
-        "initTime": 2.509375000372529
+        "initTime": 1.9613750018179417
+      }
+    },
+    "1404752088": {
+      "id": "1404752088",
+      "label": "AuthController",
+      "parent": "-1134487807",
+      "metadata": {
+        "type": "controller",
+        "internal": false,
+        "sourceModuleName": "AuthModule",
+        "durable": false,
+        "static": true,
+        "transient": false,
+        "exported": false,
+        "token": "AuthController"
       }
       }
     },
     },
     "1434456218": {
     "1434456218": {
@@ -573,7 +605,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "Reflector",
         "token": "Reflector",
-        "initTime": 4.259875001385808
+        "initTime": 3.626333002001047
       }
       }
     },
     },
     "1475573941": {
     "1475573941": {
@@ -650,6 +682,21 @@
         "token": "ModuleRef"
         "token": "ModuleRef"
       }
       }
     },
     },
+    "1609867136": {
+      "id": "1609867136",
+      "label": "FileController",
+      "parent": "-1327562795",
+      "metadata": {
+        "type": "controller",
+        "internal": false,
+        "sourceModuleName": "FileModule",
+        "durable": false,
+        "static": true,
+        "transient": false,
+        "exported": false,
+        "token": "FileController"
+      }
+    },
     "1623724461": {
     "1623724461": {
       "id": "1623724461",
       "id": "1623724461",
       "label": "ModuleRef",
       "label": "ModuleRef",
@@ -710,7 +757,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "AliyunService",
         "token": "AliyunService",
-        "initTime": 3.175374999642372
+        "initTime": 2.923583000898361
       }
       }
     },
     },
     "1712628187": {
     "1712628187": {
@@ -753,7 +800,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "ConfigModule",
         "token": "ConfigModule",
-        "initTime": 2.5859999991953373
+        "initTime": 2.0757080018520355
       }
       }
     },
     },
     "1787828844": {
     "1787828844": {
@@ -770,7 +817,23 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "ConfigHostModule",
         "token": "ConfigHostModule",
-        "initTime": 2.4677920006215572
+        "initTime": 1.9723340012133121
+      }
+    },
+    "1811342262": {
+      "id": "1811342262",
+      "label": "CONFIGURABLE_MODULE_OPTIONS[7adf7a3c9416a5fd2f4c0]",
+      "parent": "-1033621697",
+      "metadata": {
+        "type": "provider",
+        "internal": false,
+        "sourceModuleName": "DevtoolsModule",
+        "durable": false,
+        "static": true,
+        "scope": 0,
+        "transient": false,
+        "exported": false,
+        "token": "CONFIGURABLE_MODULE_OPTIONS[7adf7a3c9416a5fd2f4c0]"
       }
       }
     },
     },
     "1817334964": {
     "1817334964": {
@@ -789,6 +852,21 @@
         "token": "ModuleRef"
         "token": "ModuleRef"
       }
       }
     },
     },
+    "1837744481": {
+      "id": "1837744481",
+      "label": "FileService",
+      "parent": "-1327562795",
+      "metadata": {
+        "type": "provider",
+        "internal": false,
+        "sourceModuleName": "FileModule",
+        "durable": false,
+        "static": true,
+        "transient": false,
+        "exported": false,
+        "token": "FileService"
+      }
+    },
     "1864578377": {
     "1864578377": {
       "id": "1864578377",
       "id": "1864578377",
       "label": "SmsService",
       "label": "SmsService",
@@ -818,7 +896,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "REQUEST",
         "token": "REQUEST",
-        "initTime": 2.7724580001085997
+        "initTime": 2.215082999318838
       }
       }
     },
     },
     "1989588516": {
     "1989588516": {
@@ -914,7 +992,7 @@
         "transient": true,
         "transient": true,
         "exported": true,
         "exported": true,
         "token": "INQUIRER",
         "token": "INQUIRER",
-        "initTime": 2.7693750001490116
+        "initTime": 2.2113750018179417
       }
       }
     },
     },
     "-26938366": {
     "-26938366": {
@@ -963,7 +1041,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "HttpAdapterHost",
         "token": "HttpAdapterHost",
-        "initTime": 3.492375001311302
+        "initTime": 2.9109590016305447
       }
       }
     },
     },
     "-702581189": {
     "-702581189": {
@@ -979,7 +1057,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "LazyModuleLoader",
         "token": "LazyModuleLoader",
-        "initTime": 2.9976249989122152
+        "initTime": 2.4618749991059303
       }
       }
     },
     },
     "-1904419534": {
     "-1904419534": {
@@ -1022,7 +1100,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "AppModule",
         "token": "AppModule",
-        "initTime": 2.988874999806285
+        "initTime": 2.4542919993400574
       }
       }
     },
     },
     "-71302842": {
     "-71302842": {
@@ -1070,7 +1148,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "AppService",
         "token": "AppService",
-        "initTime": 2.9747499991208315
+        "initTime": 2.362790998071432
       }
       }
     },
     },
     "-1033621697": {
     "-1033621697": {
@@ -1097,7 +1175,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "DevtoolsModule",
         "token": "DevtoolsModule",
-        "initTime": 2.8990000002086163
+        "initTime": 2.3459170013666153
       }
       }
     },
     },
     "-751962311": {
     "-751962311": {
@@ -1140,7 +1218,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "DiscoveryModule",
         "token": "DiscoveryModule",
-        "initTime": 2.6720000002533197
+        "initTime": 2.1185000017285347
       }
       }
     },
     },
     "-501891371": {
     "-501891371": {
@@ -1188,7 +1266,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "MetadataScanner",
         "token": "MetadataScanner",
-        "initTime": 2.6850419994443655
+        "initTime": 2.1332500018179417
       }
       }
     },
     },
     "-503631789": {
     "-503631789": {
@@ -1250,7 +1328,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "ConfigModule",
         "token": "ConfigModule",
-        "initTime": 2.2957079987972975
+        "initTime": 1.8596660010516644
       }
       }
     },
     },
     "-408540750": {
     "-408540750": {
@@ -1309,7 +1387,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "TypeOrmModule",
         "token": "TypeOrmModule",
-        "initTime": 2.2676250003278255
+        "initTime": 1.8517090007662773
       }
       }
     },
     },
     "-1068388246": {
     "-1068388246": {
@@ -1399,7 +1477,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "ConfigModule",
         "token": "ConfigModule",
-        "initTime": 2.023207999765873
+        "initTime": 1.6802500002086163
       }
       }
     },
     },
     "-408540749": {
     "-408540749": {
@@ -1446,7 +1524,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "CONFIGURATION(aliyun)",
         "token": "CONFIGURATION(aliyun)",
-        "initTime": 2.0314589999616146
+        "initTime": 1.6869169995188713
       }
       }
     },
     },
     "-759474504": {
     "-759474504": {
@@ -1473,7 +1551,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "SmsModule",
         "token": "SmsModule",
-        "initTime": 1.9737909995019436
+        "initTime": 1.642374999821186
       }
       }
     },
     },
     "-811664770": {
     "-811664770": {
@@ -1521,7 +1599,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "TypeOrmModule",
         "token": "TypeOrmModule",
-        "initTime": 1.7841250002384186
+        "initTime": 1.5041669979691505
       }
       }
     },
     },
     "-223917668": {
     "-223917668": {
@@ -1564,7 +1642,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "UsersModule",
         "token": "UsersModule",
-        "initTime": 1.7735830005258322
+        "initTime": 1.4964170008897781
       }
       }
     },
     },
     "-618964563": {
     "-618964563": {
@@ -1612,7 +1690,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "HashingService",
         "token": "HashingService",
-        "initTime": 1.7639589998871088
+        "initTime": 1.4916249997913837
       }
       }
     },
     },
     "-1102473136": {
     "-1102473136": {
@@ -1644,7 +1722,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "TypeOrmModule",
         "token": "TypeOrmModule",
-        "initTime": 1.7342910002917051
+        "initTime": 1.4689580015838146
       }
       }
     },
     },
     "-223917667": {
     "-223917667": {
@@ -1702,7 +1780,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "AuthModule",
         "token": "AuthModule",
-        "initTime": 1.7207090016454458
+        "initTime": 1.4592499993741512
       }
       }
     },
     },
     "-120792986": {
     "-120792986": {
@@ -1732,10 +1810,26 @@
         "durable": false,
         "durable": false,
         "static": true,
         "static": true,
         "transient": false,
         "transient": false,
-        "exported": false,
+        "exported": true,
         "token": "AuthService"
         "token": "AuthService"
       }
       }
     },
     },
+    "-239266870": {
+      "id": "-239266870",
+      "label": "JwtAuthGuard",
+      "parent": "-1134487807",
+      "metadata": {
+        "type": "provider",
+        "internal": false,
+        "sourceModuleName": "AuthModule",
+        "durable": false,
+        "static": true,
+        "transient": false,
+        "exported": false,
+        "token": "APP_GUARD (UUID: 1239237319)",
+        "subtype": "guard"
+      }
+    },
     "-491114352": {
     "-491114352": {
       "id": "-491114352",
       "id": "-491114352",
       "label": "ConfigModule",
       "label": "ConfigModule",
@@ -1750,7 +1844,7 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "ConfigModule",
         "token": "ConfigModule",
-        "initTime": 1.6761250011622906
+        "initTime": 1.418333001434803
       }
       }
     },
     },
     "-408540748": {
     "-408540748": {
@@ -1797,7 +1891,7 @@
         "transient": false,
         "transient": false,
         "exported": true,
         "exported": true,
         "token": "CONFIGURATION(jwt)",
         "token": "CONFIGURATION(jwt)",
-        "initTime": 1.68308399990201
+        "initTime": 1.4312499985098839
       }
       }
     },
     },
     "-536515674": {
     "-536515674": {
@@ -1839,11 +1933,47 @@
         "transient": false,
         "transient": false,
         "exported": false,
         "exported": false,
         "token": "JWT_MODULE_OPTIONS",
         "token": "JWT_MODULE_OPTIONS",
-        "initTime": 2.720958000048995
+        "initTime": 2.5627500005066395
+      }
+    },
+    "-1327562795": {
+      "id": "-1327562795",
+      "label": "FileModule",
+      "metadata": {
+        "type": "module",
+        "global": false,
+        "dynamic": false,
+        "internal": false
+      }
+    },
+    "-313867974": {
+      "id": "-313867974",
+      "label": "ApplicationConfig",
+      "parent": "-1327562795",
+      "metadata": {
+        "type": "provider",
+        "internal": true,
+        "sourceModuleName": "FileModule",
+        "durable": false,
+        "static": true,
+        "scope": 0,
+        "transient": false,
+        "exported": false,
+        "token": "ApplicationConfig"
       }
       }
     }
     }
   },
   },
   "edges": {
   "edges": {
+    "33362649": {
+      "source": "-1327562795",
+      "target": "-1026304274",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "FileModule",
+        "targetModuleName": "TypeOrmCoreModule"
+      },
+      "id": "33362649"
+    },
     "43962647": {
     "43962647": {
       "source": "-2003726489",
       "source": "-2003726489",
       "target": "-1026304274",
       "target": "-1026304274",
@@ -1931,6 +2061,16 @@
       },
       },
       "id": "254091268"
       "id": "254091268"
     },
     },
+    "289403048": {
+      "source": "-1134487807",
+      "target": "-2003726489",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "AuthModule",
+        "targetModuleName": "UsersModule"
+      },
+      "id": "289403048"
+    },
     "309543654": {
     "309543654": {
       "source": "-759474504",
       "source": "-759474504",
       "target": "1712628187",
       "target": "1712628187",
@@ -1951,6 +2091,16 @@
       },
       },
       "id": "353572985"
       "id": "353572985"
     },
     },
+    "363633297": {
+      "source": "-1327562795",
+      "target": "1712628187",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "FileModule",
+        "targetModuleName": "ConfigModule"
+      },
+      "id": "363633297"
+    },
     "420319069": {
     "420319069": {
       "source": "-2003726489",
       "source": "-2003726489",
       "target": "-759474504",
       "target": "-759474504",
@@ -2167,6 +2317,16 @@
       },
       },
       "id": "1134336077"
       "id": "1134336077"
     },
     },
+    "1138009401": {
+      "source": "-1327562795",
+      "target": "555176277",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "FileModule",
+        "targetModuleName": "InternalCoreModule"
+      },
+      "id": "1138009401"
+    },
     "1173495886": {
     "1173495886": {
       "source": "-759474504",
       "source": "-759474504",
       "target": "612499341",
       "target": "612499341",
@@ -2531,6 +2691,16 @@
       },
       },
       "id": "-158970266"
       "id": "-158970266"
     },
     },
+    "-789499568": {
+      "source": "-19112576",
+      "target": "-1327562795",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "AppModule",
+        "targetModuleName": "FileModule"
+      },
+      "id": "-789499568"
+    },
     "-815553404": {
     "-815553404": {
       "source": "-19112576",
       "source": "-19112576",
       "target": "211572259",
       "target": "211572259",
@@ -2941,6 +3111,36 @@
       },
       },
       "id": "-1881791934"
       "id": "-1881791934"
     },
     },
+    "-693890971": {
+      "source": "-1327562795",
+      "target": "612499341",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "FileModule",
+        "targetModuleName": "AliyunModule"
+      },
+      "id": "-693890971"
+    },
+    "-497922230": {
+      "source": "-1327562795",
+      "target": "211572259",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "FileModule",
+        "targetModuleName": "ConfigHostModule"
+      },
+      "id": "-497922230"
+    },
+    "-1517205111": {
+      "source": "-1327562795",
+      "target": "1482218087",
+      "metadata": {
+        "type": "module-to-module",
+        "sourceModuleName": "FileModule",
+        "targetModuleName": "ThrottlerModule"
+      },
+      "id": "-1517205111"
+    },
     "-951393523": {
     "-951393523": {
       "source": "930519593",
       "source": "930519593",
       "target": "1063746662",
       "target": "1063746662",
@@ -3116,13 +3316,12 @@
       "context": {
       "context": {
         "index": 0,
         "index": 0,
         "dependencies": [
         "dependencies": [
-          "UsersService",
-          "JwtService"
+          "Object"
         ],
         ],
-        "name": "UsersService"
+        "name": "Object"
       },
       },
-      "moduleId": "-1134487807",
-      "nodeId": "-793915935"
+      "moduleId": "-1327562795",
+      "nodeId": "1837744481"
     }
     }
   }
   }
 }
 }

+ 2 - 0
package.json

@@ -33,6 +33,8 @@
     "@nestjs/swagger": "^6.2.1",
     "@nestjs/swagger": "^6.2.1",
     "@nestjs/throttler": "^4.0.0",
     "@nestjs/throttler": "^4.0.0",
     "@nestjs/typeorm": "^9.0.1",
     "@nestjs/typeorm": "^9.0.1",
+    "@types/multer": "^1.4.7",
+    "ali-oss": "^6.17.1",
     "bcrypt": "^5.1.0",
     "bcrypt": "^5.1.0",
     "class-transformer": "^0.5.1",
     "class-transformer": "^0.5.1",
     "class-validator": "^0.13.0",
     "class-validator": "^0.13.0",

+ 20 - 2
src/aliyun/aliyun.service.ts

@@ -1,14 +1,14 @@
 import { Inject, Injectable, InternalServerErrorException, Logger } from '@nestjs/common'
 import { Inject, Injectable, InternalServerErrorException, Logger } from '@nestjs/common'
 import aliyunConfig from './config/aliyun.config'
 import aliyunConfig from './config/aliyun.config'
 import { ConfigType } from '@nestjs/config'
 import { ConfigType } from '@nestjs/config'
-// This file is auto-generated, don't edit it
 import Dysmsapi20170525, * as $Dysmsapi20170525 from '@alicloud/dysmsapi20170525'
 import Dysmsapi20170525, * as $Dysmsapi20170525 from '@alicloud/dysmsapi20170525'
-// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
 import OpenApi, * as $OpenApi from '@alicloud/openapi-client'
 import OpenApi, * as $OpenApi from '@alicloud/openapi-client'
 import Util, * as $Util from '@alicloud/tea-util'
 import Util, * as $Util from '@alicloud/tea-util'
 import * as $tea from '@alicloud/tea-typescript'
 import * as $tea from '@alicloud/tea-typescript'
 import { SendSmsResponse } from '@alicloud/dysmsapi20170525'
 import { SendSmsResponse } from '@alicloud/dysmsapi20170525'
 import * as randomstring from 'randomstring'
 import * as randomstring from 'randomstring'
+import * as OSS from 'ali-oss'
+import { buffer } from 'stream/consumers'
 
 
 @Injectable()
 @Injectable()
 export class AliyunService {
 export class AliyunService {
@@ -47,4 +47,22 @@ export class AliyunService {
             throw new InternalServerErrorException(error.message)
             throw new InternalServerErrorException(error.message)
         }
         }
     }
     }
+
+    public async uploadFile(fileName: string, fileBuffer: Buffer) {
+        let client = new OSS({
+            endpoint: this.aliyunConfiguration.ossEndPoint,
+            accessKeyId: this.aliyunConfiguration.accessKeyId,
+            accessKeySecret: this.aliyunConfiguration.accessKeySecret,
+            bucket: this.aliyunConfiguration.ossBucket
+        })
+        try {
+            const result = await client.put(buffer, 'files/111.png')
+            // 自定义headers
+            //,{headers}
+           
+            console.log(result);
+          } catch (e) {
+            console.log(e);
+          }
+    }
 }
 }

+ 3 - 1
src/app.module.ts

@@ -10,6 +10,7 @@ import * as Yup from 'yup'
 import { SmsModule } from './sms/sms.module'
 import { SmsModule } from './sms/sms.module'
 import { DevtoolsModule } from '@nestjs/devtools-integration'
 import { DevtoolsModule } from '@nestjs/devtools-integration'
 import { AuthModule } from './auth/auth.module';
 import { AuthModule } from './auth/auth.module';
+import { FileModule } from './file/file.module';
 
 
 @Module({
 @Module({
     imports: [
     imports: [
@@ -59,7 +60,8 @@ import { AuthModule } from './auth/auth.module';
         AliyunModule,
         AliyunModule,
         SmsModule,
         SmsModule,
         UsersModule,
         UsersModule,
-        AuthModule
+        AuthModule,
+        FileModule
     ],
     ],
     controllers: [AppController],
     controllers: [AppController],
     providers: [AppService]
     providers: [AppService]

+ 18 - 0
src/file/file.controller.spec.ts

@@ -0,0 +1,18 @@
+import { Test, TestingModule } from '@nestjs/testing';
+import { FileController } from './file.controller';
+
+describe('FileController', () => {
+  let controller: FileController;
+
+  beforeEach(async () => {
+    const module: TestingModule = await Test.createTestingModule({
+      controllers: [FileController],
+    }).compile();
+
+    controller = module.get<FileController>(FileController);
+  });
+
+  it('should be defined', () => {
+    expect(controller).toBeDefined();
+  });
+});

+ 19 - 0
src/file/file.controller.ts

@@ -0,0 +1,19 @@
+import { FileService } from './file.service'
+import { Controller, UploadedFile, UseInterceptors } from '@nestjs/common'
+import { ApiTags } from '@nestjs/swagger'
+import { Public } from 'src/auth/public.decorator'
+import { Post } from '@nestjs/common'
+import { FileInterceptor } from '@nestjs/platform-express'
+
+@ApiTags('file')
+@Controller('file')
+export class FileController {
+    constructor(private readonly fileService: FileService) {}
+
+    @Public()
+    @Post('upload')
+    @UseInterceptors(FileInterceptor('file'))
+    public async uploadFile(@UploadedFile() file: Express.Multer.File) {
+        return await this.fileService.upload(file)
+    }
+}

+ 11 - 0
src/file/file.module.ts

@@ -0,0 +1,11 @@
+import { Module } from '@nestjs/common'
+import { FileService } from './file.service'
+import { FileController } from './file.controller'
+import { AliyunModule } from 'src/aliyun/aliyun.module'
+
+@Module({
+    imports: [AliyunModule],
+    providers: [FileService],
+    controllers: [FileController]
+})
+export class FileModule {}

+ 18 - 0
src/file/file.service.spec.ts

@@ -0,0 +1,18 @@
+import { Test, TestingModule } from '@nestjs/testing';
+import { FileService } from './file.service';
+
+describe('FileService', () => {
+  let service: FileService;
+
+  beforeEach(async () => {
+    const module: TestingModule = await Test.createTestingModule({
+      providers: [FileService],
+    }).compile();
+
+    service = module.get<FileService>(FileService);
+  });
+
+  it('should be defined', () => {
+    expect(service).toBeDefined();
+  });
+});

+ 14 - 0
src/file/file.service.ts

@@ -0,0 +1,14 @@
+import { Injectable, Logger } from '@nestjs/common'
+import { AliyunService } from 'src/aliyun/aliyun.service'
+
+@Injectable()
+export class FileService {
+    constructor(private readonly aliyunService: AliyunService) {}
+
+    public async upload(file: Express.Multer.File) {
+        const { originalname, buffer, mimetype } = file
+        Logger.log(`upload file name=${originalname} type=${mimetype}`)
+        const result = await this.aliyunService.uploadFile(originalname, buffer)
+        return result
+    }
+}

Файловите разлики са ограничени, защото са твърде много
+ 477 - 33
yarn.lock


Някои файлове не бяха показани, защото твърде много файлове са промени