From e933dbadf3d7c285560cd288fdaed5556ebb0a6a Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Mon, 30 Nov 2020 22:52:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E9=99=86=E3=80=81=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=8C=E6=88=90=EF=BC=8C=E6=90=BA=E5=B8=A6?= =?UTF-8?q?token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package-lock.json | 225 ++++++++++++++++---------------- backend/package.json | 1 - backend/src/config/index.ts | 2 +- backend/src/router/api/mysql.ts | 115 +++++++++------- backend/src/server.ts | 9 +- 5 files changed, 185 insertions(+), 167 deletions(-) diff --git a/backend/package-lock.json b/backend/package-lock.json index 9597d80c1..32cf1bac1 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -124,7 +124,7 @@ }, "ansi-align": { "version": "2.0.0", - "resolved": "http://192.168.250.101:4873/ansi-align/-/ansi-align-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", "dev": true, "requires": { @@ -168,7 +168,7 @@ }, "arr-diff": { "version": "4.0.0", - "resolved": "http://192.168.250.101:4873/arr-diff/-/arr-diff-4.0.0.tgz", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", "dev": true }, @@ -180,7 +180,7 @@ }, "arr-union": { "version": "3.1.0", - "resolved": "http://192.168.250.101:4873/arr-union/-/arr-union-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, @@ -191,13 +191,13 @@ }, "array-unique": { "version": "0.3.2", - "resolved": "http://192.168.250.101:4873/array-unique/-/array-unique-0.3.2.tgz", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, "assign-symbols": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/assign-symbols/-/assign-symbols-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, @@ -240,7 +240,7 @@ "dependencies": { "define-property": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { @@ -365,7 +365,7 @@ "dependencies": { "extend-shallow": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/extend-shallow/-/extend-shallow-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { @@ -414,7 +414,7 @@ }, "camelcase": { "version": "4.1.0", - "resolved": "http://192.168.250.101:4873/camelcase/-/camelcase-4.1.0.tgz", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", "dev": true }, @@ -495,7 +495,7 @@ "dependencies": { "define-property": { "version": "0.2.5", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-0.2.5.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { @@ -506,13 +506,13 @@ }, "cli-boxes": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/cli-boxes/-/cli-boxes-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", "dev": true }, "collection-visit": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/collection-visit/-/collection-visit-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, "requires": { @@ -620,7 +620,7 @@ }, "copy-descriptor": { "version": "0.1.1", - "resolved": "http://192.168.250.101:4873/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, @@ -636,7 +636,7 @@ }, "create-error-class": { "version": "3.0.2", - "resolved": "http://192.168.250.101:4873/create-error-class/-/create-error-class-3.0.2.tgz", + "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", "dev": true, "requires": { @@ -645,7 +645,7 @@ }, "cross-spawn": { "version": "5.1.0", - "resolved": "http://192.168.250.101:4873/cross-spawn/-/cross-spawn-5.1.0.tgz", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { @@ -656,7 +656,7 @@ }, "crypto-random-string": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/crypto-random-string/-/crypto-random-string-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", "dev": true }, @@ -677,7 +677,7 @@ }, "decode-uri-component": { "version": "0.2.0", - "resolved": "http://192.168.250.101:4873/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, @@ -781,7 +781,7 @@ }, "duplexer3": { "version": "0.1.4", - "resolved": "http://192.168.250.101:4873/duplexer3/-/duplexer3-0.1.4.tgz", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", "dev": true }, @@ -836,7 +836,7 @@ }, "execa": { "version": "0.7.0", - "resolved": "http://192.168.250.101:4873/execa/-/execa-0.7.0.tgz", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "dev": true, "requires": { @@ -851,7 +851,7 @@ }, "expand-brackets": { "version": "2.1.4", - "resolved": "http://192.168.250.101:4873/expand-brackets/-/expand-brackets-2.1.4.tgz", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { @@ -875,7 +875,7 @@ }, "define-property": { "version": "0.2.5", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-0.2.5.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { @@ -884,7 +884,7 @@ }, "extend-shallow": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/extend-shallow/-/extend-shallow-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { @@ -963,7 +963,7 @@ }, "extend-shallow": { "version": "3.0.2", - "resolved": "http://192.168.250.101:4873/extend-shallow/-/extend-shallow-3.0.2.tgz", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, "requires": { @@ -1000,7 +1000,7 @@ "dependencies": { "define-property": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { @@ -1009,7 +1009,7 @@ }, "extend-shallow": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/extend-shallow/-/extend-shallow-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { @@ -1066,7 +1066,7 @@ }, "fill-range": { "version": "4.0.0", - "resolved": "http://192.168.250.101:4873/fill-range/-/fill-range-4.0.0.tgz", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { @@ -1078,7 +1078,7 @@ "dependencies": { "extend-shallow": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/extend-shallow/-/extend-shallow-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { @@ -1118,7 +1118,7 @@ }, "for-in": { "version": "1.0.2", - "resolved": "http://192.168.250.101:4873/for-in/-/for-in-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, @@ -1134,7 +1134,7 @@ }, "fragment-cache": { "version": "0.2.1", - "resolved": "http://192.168.250.101:4873/fragment-cache/-/fragment-cache-0.2.1.tgz", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, "requires": { @@ -1718,13 +1718,13 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://192.168.250.101:4873/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, "get-value": { "version": "2.0.6", - "resolved": "http://192.168.250.101:4873/get-value/-/get-value-2.0.6.tgz", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", "dev": true }, @@ -1743,7 +1743,7 @@ }, "glob-parent": { "version": "3.1.0", - "resolved": "http://192.168.250.101:4873/glob-parent/-/glob-parent-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, "requires": { @@ -1753,7 +1753,7 @@ "dependencies": { "is-glob": { "version": "3.1.0", - "resolved": "http://192.168.250.101:4873/is-glob/-/is-glob-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, "requires": { @@ -1764,7 +1764,7 @@ }, "global-dirs": { "version": "0.1.1", - "resolved": "http://192.168.250.101:4873/global-dirs/-/global-dirs-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", "dev": true, "requires": { @@ -1773,7 +1773,7 @@ }, "got": { "version": "6.7.1", - "resolved": "http://192.168.250.101:4873/got/-/got-6.7.1.tgz", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "dev": true, "requires": { @@ -1813,7 +1813,7 @@ }, "has-value": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/has-value/-/has-value-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, "requires": { @@ -1824,7 +1824,7 @@ }, "has-values": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/has-values/-/has-values-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, "requires": { @@ -1834,7 +1834,7 @@ "dependencies": { "kind-of": { "version": "4.0.0", - "resolved": "http://192.168.250.101:4873/kind-of/-/kind-of-4.0.0.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { @@ -1865,19 +1865,19 @@ }, "ignore-by-default": { "version": "1.0.1", - "resolved": "http://192.168.250.101:4873/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", "dev": true }, "import-lazy": { "version": "2.1.0", - "resolved": "http://192.168.250.101:4873/import-lazy/-/import-lazy-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", "dev": true }, "imurmurhash": { "version": "0.1.4", - "resolved": "http://192.168.250.101:4873/imurmurhash/-/imurmurhash-0.1.4.tgz", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, @@ -1908,7 +1908,7 @@ }, "is-accessor-descriptor": { "version": "0.1.6", - "resolved": "http://192.168.250.101:4873/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { @@ -1917,7 +1917,7 @@ "dependencies": { "kind-of": { "version": "3.2.2", - "resolved": "http://192.168.250.101:4873/kind-of/-/kind-of-3.2.2.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { @@ -1933,7 +1933,7 @@ }, "is-binary-path": { "version": "1.0.1", - "resolved": "http://192.168.250.101:4873/is-binary-path/-/is-binary-path-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, "requires": { @@ -1966,7 +1966,7 @@ }, "is-data-descriptor": { "version": "0.1.4", - "resolved": "http://192.168.250.101:4873/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { @@ -1975,7 +1975,7 @@ "dependencies": { "kind-of": { "version": "3.2.2", - "resolved": "http://192.168.250.101:4873/kind-of/-/kind-of-3.2.2.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { @@ -2011,19 +2011,19 @@ }, "is-extendable": { "version": "0.1.1", - "resolved": "http://192.168.250.101:4873/is-extendable/-/is-extendable-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", "dev": true }, "is-extglob": { "version": "2.1.1", - "resolved": "http://192.168.250.101:4873/is-extglob/-/is-extglob-2.1.1.tgz", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, "is-fullwidth-code-point": { "version": "2.0.0", - "resolved": "http://192.168.250.101:4873/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, @@ -2038,7 +2038,7 @@ }, "is-installed-globally": { "version": "0.1.0", - "resolved": "http://192.168.250.101:4873/is-installed-globally/-/is-installed-globally-0.1.0.tgz", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", "dev": true, "requires": { @@ -2048,13 +2048,13 @@ }, "is-npm": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/is-npm/-/is-npm-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", "dev": true }, "is-number": { "version": "3.0.0", - "resolved": "http://192.168.250.101:4873/is-number/-/is-number-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { @@ -2063,7 +2063,7 @@ "dependencies": { "kind-of": { "version": "3.2.2", - "resolved": "http://192.168.250.101:4873/kind-of/-/kind-of-3.2.2.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { @@ -2074,13 +2074,13 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://192.168.250.101:4873/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, "is-path-inside": { "version": "1.0.1", - "resolved": "http://192.168.250.101:4873/is-path-inside/-/is-path-inside-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { @@ -2103,7 +2103,7 @@ }, "is-redirect": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/is-redirect/-/is-redirect-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", "dev": true }, @@ -2115,7 +2115,7 @@ }, "is-stream": { "version": "1.1.0", - "resolved": "http://192.168.250.101:4873/is-stream/-/is-stream-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, @@ -2141,13 +2141,13 @@ }, "isexe": { "version": "2.0.0", - "resolved": "http://192.168.250.101:4873/isexe/-/isexe-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, "isobject": { "version": "3.0.1", - "resolved": "http://192.168.250.101:4873/isobject/-/isobject-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "dev": true }, @@ -2243,7 +2243,7 @@ }, "latest-version": { "version": "3.1.0", - "resolved": "http://192.168.250.101:4873/latest-version/-/latest-version-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", "dev": true, "requires": { @@ -2345,24 +2345,19 @@ }, "map-cache": { "version": "0.2.2", - "resolved": "http://192.168.250.101:4873/map-cache/-/map-cache-0.2.2.tgz", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true }, "map-visit": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/map-visit/-/map-visit-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, "requires": { "object-visit": "^1.0.0" } }, - "md5-node": { - "version": "1.0.1", - "resolved": "http://192.168.250.101:4873/md5-node/-/md5-node-1.0.1.tgz", - "integrity": "sha1-DiLQCdRr3JWx08XoyP7dwaXDqog=" - }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -2571,7 +2566,7 @@ }, "nopt": { "version": "1.0.10", - "resolved": "http://192.168.250.101:4873/nopt/-/nopt-1.0.10.tgz", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", "dev": true, "requires": { @@ -2586,7 +2581,7 @@ }, "npm-run-path": { "version": "2.0.2", - "resolved": "http://192.168.250.101:4873/npm-run-path/-/npm-run-path-2.0.2.tgz", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "dev": true, "requires": { @@ -2595,7 +2590,7 @@ }, "object-copy": { "version": "0.1.0", - "resolved": "http://192.168.250.101:4873/object-copy/-/object-copy-0.1.0.tgz", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, "requires": { @@ -2606,7 +2601,7 @@ "dependencies": { "define-property": { "version": "0.2.5", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-0.2.5.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { @@ -2615,7 +2610,7 @@ }, "kind-of": { "version": "3.2.2", - "resolved": "http://192.168.250.101:4873/kind-of/-/kind-of-3.2.2.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { @@ -2626,7 +2621,7 @@ }, "object-visit": { "version": "1.0.1", - "resolved": "http://192.168.250.101:4873/object-visit/-/object-visit-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, "requires": { @@ -2635,7 +2630,7 @@ }, "object.pick": { "version": "1.3.0", - "resolved": "http://192.168.250.101:4873/object.pick/-/object.pick-1.3.0.tgz", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { @@ -2704,13 +2699,13 @@ }, "p-finally": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/p-finally/-/p-finally-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", "dev": true }, "package-json": { "version": "4.0.1", - "resolved": "http://192.168.250.101:4873/package-json/-/package-json-4.0.1.tgz", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", "dev": true, "requires": { @@ -2727,13 +2722,13 @@ }, "pascalcase": { "version": "0.1.1", - "resolved": "http://192.168.250.101:4873/pascalcase/-/pascalcase-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", "dev": true }, "path-dirname": { "version": "1.0.2", - "resolved": "http://192.168.250.101:4873/path-dirname/-/path-dirname-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", "dev": true }, @@ -2744,13 +2739,13 @@ }, "path-is-inside": { "version": "1.0.2", - "resolved": "http://192.168.250.101:4873/path-is-inside/-/path-is-inside-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", "dev": true }, "path-key": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/path-key/-/path-key-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, @@ -2767,19 +2762,19 @@ }, "pify": { "version": "3.0.0", - "resolved": "http://192.168.250.101:4873/pify/-/pify-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true }, "posix-character-classes": { "version": "0.1.1", - "resolved": "http://192.168.250.101:4873/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true }, "prepend-http": { "version": "1.0.4", - "resolved": "http://192.168.250.101:4873/prepend-http/-/prepend-http-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", "dev": true }, @@ -2893,7 +2888,7 @@ }, "registry-url": { "version": "3.1.0", - "resolved": "http://192.168.250.101:4873/registry-url/-/registry-url-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", "dev": true, "requires": { @@ -2902,7 +2897,7 @@ }, "remove-trailing-separator": { "version": "1.1.0", - "resolved": "http://192.168.250.101:4873/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", "dev": true }, @@ -2914,7 +2909,7 @@ }, "repeat-string": { "version": "1.6.1", - "resolved": "http://192.168.250.101:4873/repeat-string/-/repeat-string-1.6.1.tgz", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, @@ -2930,7 +2925,7 @@ }, "resolve-url": { "version": "0.2.1", - "resolved": "http://192.168.250.101:4873/resolve-url/-/resolve-url-0.2.1.tgz", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "dev": true }, @@ -2947,7 +2942,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "http://192.168.250.101:4873/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { @@ -2966,7 +2961,7 @@ }, "semver-diff": { "version": "2.1.0", - "resolved": "http://192.168.250.101:4873/semver-diff/-/semver-diff-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", "dev": true, "requires": { @@ -3045,7 +3040,7 @@ "dependencies": { "extend-shallow": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/extend-shallow/-/extend-shallow-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { @@ -3061,7 +3056,7 @@ }, "shebang-command": { "version": "1.2.0", - "resolved": "http://192.168.250.101:4873/shebang-command/-/shebang-command-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { @@ -3070,7 +3065,7 @@ }, "shebang-regex": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/shebang-regex/-/shebang-regex-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, @@ -3115,7 +3110,7 @@ }, "define-property": { "version": "0.2.5", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-0.2.5.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { @@ -3124,7 +3119,7 @@ }, "extend-shallow": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/extend-shallow/-/extend-shallow-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { @@ -3146,7 +3141,7 @@ "dependencies": { "define-property": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { @@ -3195,7 +3190,7 @@ "dependencies": { "kind-of": { "version": "3.2.2", - "resolved": "http://192.168.250.101:4873/kind-of/-/kind-of-3.2.2.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { @@ -3206,7 +3201,7 @@ }, "source-map": { "version": "0.5.7", - "resolved": "http://192.168.250.101:4873/source-map/-/source-map-0.5.7.tgz", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true }, @@ -3225,7 +3220,7 @@ }, "source-map-url": { "version": "0.4.0", - "resolved": "http://192.168.250.101:4873/source-map-url/-/source-map-url-0.4.0.tgz", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, @@ -3255,7 +3250,7 @@ }, "static-extend": { "version": "0.1.2", - "resolved": "http://192.168.250.101:4873/static-extend/-/static-extend-0.1.2.tgz", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, "requires": { @@ -3265,7 +3260,7 @@ "dependencies": { "define-property": { "version": "0.2.5", - "resolved": "http://192.168.250.101:4873/define-property/-/define-property-0.2.5.tgz", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { @@ -3308,13 +3303,13 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "dev": true }, "strip-json-comments": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true }, @@ -3362,7 +3357,7 @@ }, "term-size": { "version": "1.2.0", - "resolved": "http://192.168.250.101:4873/term-size/-/term-size-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", "dev": true, "requires": { @@ -3376,7 +3371,7 @@ }, "timed-out": { "version": "4.0.1", - "resolved": "http://192.168.250.101:4873/timed-out/-/timed-out-4.0.1.tgz", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", "dev": true }, @@ -3387,7 +3382,7 @@ }, "to-object-path": { "version": "0.3.0", - "resolved": "http://192.168.250.101:4873/to-object-path/-/to-object-path-0.3.0.tgz", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { @@ -3396,7 +3391,7 @@ "dependencies": { "kind-of": { "version": "3.2.2", - "resolved": "http://192.168.250.101:4873/kind-of/-/kind-of-3.2.2.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { @@ -3419,7 +3414,7 @@ }, "to-regex-range": { "version": "2.1.1", - "resolved": "http://192.168.250.101:4873/to-regex-range/-/to-regex-range-2.1.1.tgz", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, "requires": { @@ -3531,7 +3526,7 @@ }, "unique-string": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/unique-string/-/unique-string-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", "dev": true, "requires": { @@ -3545,7 +3540,7 @@ }, "unset-value": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/unset-value/-/unset-value-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, "requires": { @@ -3555,7 +3550,7 @@ "dependencies": { "has-value": { "version": "0.3.1", - "resolved": "http://192.168.250.101:4873/has-value/-/has-value-0.3.1.tgz", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, "requires": { @@ -3566,7 +3561,7 @@ "dependencies": { "isobject": { "version": "2.1.0", - "resolved": "http://192.168.250.101:4873/isobject/-/isobject-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, "requires": { @@ -3577,7 +3572,7 @@ }, "has-values": { "version": "0.1.4", - "resolved": "http://192.168.250.101:4873/has-values/-/has-values-0.1.4.tgz", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", "dev": true } @@ -3585,7 +3580,7 @@ }, "unzip-response": { "version": "2.0.1", - "resolved": "http://192.168.250.101:4873/unzip-response/-/unzip-response-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", "dev": true }, @@ -3615,13 +3610,13 @@ }, "urix": { "version": "0.1.0", - "resolved": "http://192.168.250.101:4873/urix/-/urix-0.1.0.tgz", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "dev": true }, "url-parse-lax": { "version": "1.0.0", - "resolved": "http://192.168.250.101:4873/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", "dev": true, "requires": { @@ -3732,7 +3727,7 @@ }, "xdg-basedir": { "version": "3.0.0", - "resolved": "http://192.168.250.101:4873/xdg-basedir/-/xdg-basedir-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", "dev": true }, diff --git a/backend/package.json b/backend/package.json index f01e22373..f7d912471 100644 --- a/backend/package.json +++ b/backend/package.json @@ -23,7 +23,6 @@ "express": "^4.17.1", "express-swagger-generator": "^1.1.17", "jsonwebtoken": "^8.5.1", - "md5-node": "^1.0.1", "mysql2": "^2.2.5", "svg-captcha": "^1.4.0", "winston": "^3.3.3" diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 01fd4d15a..c14c8d890 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -52,7 +52,7 @@ export default { host: 'localhost', charset: 'utf8_general_ci', user: 'root', - password: 'admin' + password: '123456789' }, mongodb: {}, sqlite: {}, diff --git a/backend/src/router/api/mysql.ts b/backend/src/router/api/mysql.ts index 2aab9d4eb..fb04afca7 100644 --- a/backend/src/router/api/mysql.ts +++ b/backend/src/router/api/mysql.ts @@ -1,6 +1,7 @@ -import md5 from 'md5-node' -import jwt from "jsonwebtoken" -import jwtSecret from "../../config" + +import secret from "../../config" +import * as jwt from "jsonwebtoken" +import { createHash } from "crypto" import Logger from "../../loaders/logger" import { Request, Response } from "express" import { createMathExpr } from "svg-captcha" @@ -11,10 +12,10 @@ export interface dataModel { } // 保存验证码 -let verify: number | string +let generateVerify: number | string /** - * @typedef Point + * @typedef Login * @property {string} username.required - 用户名 * @property {string} password.required - 密码 * @property {string} verify.required - 验证码 @@ -33,56 +34,80 @@ let verify: number | string /** * 登录 * @route POST /login - * @param {Point.model} point.body.required - the new point + * @param {Login.model} point.body.required - the new point * @produces application/json application/xml * @consumes application/json application/xml * @returns {Response.model} 200 - * @returns {Array.} Point + * @returns {Array.} Login * @headers {integer} 200.X-Rate-Limit * @headers {string} 200.X-Expires-After * @security JWT */ const login = async (req: Request, res: Response) => { - console.log(req.body) - // if (verify !== req.query.verify) return res.json({ - // code: -1, - // info: "请输入正确的验证码" - // }) - //生成jwt(token令牌) {expiresIn:3600}为token的过期时间,这里设置的是1小时 - // const accessToken = jwt.sign({ - // accountId: account.id - // }, settings.accessTokenSecret, { expiresIn: 3600 }) - // const idToken = jwt.sign({ - // sub: account.id, - // preferred_username: account.username - // }, "some secret that doesn't matter") - // //返回token - // response.status(200).json({ - // access_token: accessToken, - // id_token: idToken - // }) - // accessToken -} - -/** - * 注册 - * @route POST /register - * @summary 注册 - * @group register - 注册 - * @param {string} username.query.required - username - * @param {string} password.query.required - password - * @param {string} verify.query.required - verify - * @returns {object} 200 - * @security JWT - */ - -const register = async (req: Request, res: Response) => { - if (verify !== req.query.verify) return res.json({ + const { username, password, verify } = req.body + if (generateVerify !== verify) return res.json({ code: -1, info: "请输入正确的验证码" }) - let sql: string = 'select * from users where username=' + "'" + req.query.username + "'" + let sql: string = 'select * from users where username=' + "'" + username + "'" + connection.query(sql, async function (err, data: dataModel) { + if (data.length == 0) { + await res.json({ + code: -1, + info: "账号尚未被注册" + }) + } else { + if (createHash('md5').update(password).digest('hex') == data[0].password) { + const accessToken = jwt.sign({ + accountId: data[0].id + }, secret.jwtSecret, { expiresIn: 3600 }) + await res.json({ + code: 0, + info: "登录成功", + accessToken + }) + } else { + await res.json({ + code: -1, + info: "密码错误" + }) + } + } + }) +} + +/** + * @typedef Register + * @property {string} username.required - 用户名 + * @property {string} password.required - 密码 + * @property {string} verify.required - 验证码 + */ + +/** +* 注册 +* @route POST /register +* @param {Register.model} point.body.required - the new point +* @produces application/json application/xml +* @consumes application/json application/xml +* @returns {Response.model} 200 +* @returns {Array.} Register +* @headers {integer} 200.X-Rate-Limit +* @headers {string} 200.X-Expires-After +* @security JWT +*/ + +const register = async (req: Request, res: Response) => { + const { username, password, verify } = req.body + if (generateVerify !== verify) return res.json({ + code: -1, + info: "请输入正确的验证码" + }) + if (password.length < 6) return res.json({ + code: -1, + info: "密码长度不能小于6位" + }) + let sql: string = 'select * from users where username=' + "'" + username + "'" connection.query(sql, async (err, data: dataModel) => { if (data.length > 0) { await res.json({ @@ -90,7 +115,7 @@ const register = async (req: Request, res: Response) => { info: "账号已被注册" }) } else { - let sql: string = 'insert into users (username,password) value(' + "'" + req.query.username + "'" + ',' + "'" + req.query.password + + let sql: string = 'insert into users (username,password) value(' + "'" + username + "'" + ',' + "'" + createHash('md5').update(password).digest('hex') + "'" + ')' connection.query(sql, async function (err) { if (err) { @@ -174,7 +199,7 @@ const captcha = async (req: Request, res: Response) => { mathMax: 4, mathOperator: "+" }) - verify = create.text + generateVerify = create.text res.type('svg') // 响应的类型 res.json({ code: 1, msg: create.text, svg: create.data }) } diff --git a/backend/src/server.ts b/backend/src/server.ts index 5007c5d41..38dcb1639 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -1,15 +1,14 @@ import app from "./app" import * as open from "open" -import config from './config' +import config from "./config" import { user } from "./models/mysql" -import Logger from './loaders/logger' +import Logger from "./loaders/logger" import { queryTable } from "./utils/initMysql" -const expressSwagger = require('express-swagger-generator')(app) +const expressSwagger = require("express-swagger-generator")(app) expressSwagger(config.options) queryTable(user) -// 引入测试数据 import { login, register, @@ -59,4 +58,4 @@ app.listen(config.port, () => { process.exit(1) }) -open(`http://localhost:${config.port}`) // 自动打开默认浏览器 \ No newline at end of file +// open(`http://localhost:${config.port}`) // 自动打开默认浏览器 \ No newline at end of file