chore: code style
This commit is contained in:
@@ -93,7 +93,7 @@
|
||||
"class-validator": "0.13.2",
|
||||
"consola": "*",
|
||||
"cos-nodejs-sdk-v5": "2.11.6",
|
||||
"dayjs": "1.10.8",
|
||||
"dayjs": "1.11.0",
|
||||
"ejs": "3.1.6",
|
||||
"fastify-cookie": "5.6.0",
|
||||
"fastify-multipart": "5.3.1",
|
||||
@@ -131,8 +131,8 @@
|
||||
"zx": "4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@innei-util/eslint-config-ts": "latest",
|
||||
"@innei-util/prettier": "0.2.2",
|
||||
"@innei-util/eslint-config-ts": "0.5.0",
|
||||
"@innei-util/prettier": "0.4.1",
|
||||
"@nestjs/cli": "8.2.3",
|
||||
"@nestjs/schematics": "8.0.8",
|
||||
"@nestjs/testing": "8.4.1",
|
||||
|
||||
302
pnpm-lock.yaml
generated
302
pnpm-lock.yaml
generated
@@ -9,8 +9,8 @@ specifiers:
|
||||
'@algolia/client-search': '*'
|
||||
'@babel/core': 7.17.7
|
||||
'@babel/plugin-transform-typescript': 7.16.8
|
||||
'@innei-util/eslint-config-ts': latest
|
||||
'@innei-util/prettier': 0.2.2
|
||||
'@innei-util/eslint-config-ts': 0.5.0
|
||||
'@innei-util/prettier': 0.4.1
|
||||
'@innei/class-validator-jsonschema': 3.1.1
|
||||
'@nestjs/cli': 8.2.3
|
||||
'@nestjs/common': 8.4.1
|
||||
@@ -63,7 +63,7 @@ specifiers:
|
||||
cos-nodejs-sdk-v5: 2.11.6
|
||||
cron: '*'
|
||||
cross-env: 7.0.3
|
||||
dayjs: 1.10.8
|
||||
dayjs: 1.11.0
|
||||
ejs: 3.1.6
|
||||
eslint: '*'
|
||||
fastify-cookie: 5.6.0
|
||||
@@ -140,7 +140,7 @@ dependencies:
|
||||
'@typegoose/auto-increment': 1.2.0_mongoose@6.2.4
|
||||
'@typegoose/typegoose': 9.7.0_mongoose@6.2.4
|
||||
algoliasearch: 4.13.0
|
||||
axios: 0.26.0
|
||||
axios: 0.26.1
|
||||
axios-retry: 3.2.4
|
||||
bcrypt: 5.0.1
|
||||
cache-manager: 3.6.0
|
||||
@@ -150,7 +150,7 @@ dependencies:
|
||||
class-validator: 0.13.2
|
||||
consola: 2.15.3
|
||||
cos-nodejs-sdk-v5: 2.11.6
|
||||
dayjs: 1.10.8
|
||||
dayjs: 1.11.0
|
||||
ejs: 3.1.6
|
||||
fastify-cookie: 5.6.0
|
||||
fastify-multipart: 5.3.1
|
||||
@@ -192,8 +192,8 @@ optionalDependencies:
|
||||
redis-memory-server: 0.5.0
|
||||
|
||||
devDependencies:
|
||||
'@innei-util/eslint-config-ts': 0.4.0_typescript@4.6.2
|
||||
'@innei-util/prettier': 0.2.2_typescript@4.6.2
|
||||
'@innei-util/eslint-config-ts': 0.5.0_typescript@4.6.2
|
||||
'@innei-util/prettier': 0.4.1
|
||||
'@nestjs/cli': 8.2.3
|
||||
'@nestjs/schematics': 8.0.8_typescript@4.6.2
|
||||
'@nestjs/testing': 8.4.1_214a294e539403889bf33d78c1f08a26
|
||||
@@ -219,7 +219,7 @@ devDependencies:
|
||||
'@vercel/ncc': 0.33.3
|
||||
cron: 1.7.2
|
||||
cross-env: 7.0.3
|
||||
eslint: 8.10.0
|
||||
eslint: 8.11.0
|
||||
husky: 7.0.4
|
||||
i: 0.3.7
|
||||
ioredis: 4.28.5
|
||||
@@ -487,30 +487,6 @@ packages:
|
||||
resolution: {integrity: sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
/@babel/core/7.13.10:
|
||||
resolution: {integrity: sha512-bfIYcT0BdKeAZrovpMqX2Mx5NrgAckGbwT982AkdS5GNfn3KMGiprlBAtmBcFZRUmpaufS6WZFP8trvx8ptFDw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.16.7
|
||||
'@babel/generator': 7.17.7
|
||||
'@babel/helper-compilation-targets': 7.17.7_@babel+core@7.13.10
|
||||
'@babel/helper-module-transforms': 7.17.7
|
||||
'@babel/helpers': 7.17.7
|
||||
'@babel/parser': 7.17.7
|
||||
'@babel/template': 7.16.7
|
||||
'@babel/traverse': 7.17.3
|
||||
'@babel/types': 7.17.0
|
||||
convert-source-map: 1.8.0
|
||||
debug: 4.3.3
|
||||
gensync: 1.0.0-beta.2
|
||||
json5: 2.2.0
|
||||
lodash: 4.17.21
|
||||
semver: 6.3.0
|
||||
source-map: 0.5.7
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@babel/core/7.17.7:
|
||||
resolution: {integrity: sha512-djHlEfFHnSnTAcPb7dATbiM5HxGOP98+3JLBZtjRb5I7RXrw7kFRoG2dXM8cm3H+o11A8IFH/uprmJpwFynRNQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -533,14 +509,6 @@ packages:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
/@babel/generator/7.13.9:
|
||||
resolution: {integrity: sha512-mHOOmY0Axl/JCTkxTU6Lf5sWOg/v8nUa+Xkt4zMTftX0wqmb6Sh7J8gvcehBw7q0AhrhAR+FDacKjCZ2X8K+Sw==}
|
||||
dependencies:
|
||||
'@babel/types': 7.17.0
|
||||
jsesc: 2.5.2
|
||||
source-map: 0.5.7
|
||||
dev: true
|
||||
|
||||
/@babel/generator/7.17.7:
|
||||
resolution: {integrity: sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -556,19 +524,6 @@ packages:
|
||||
'@babel/types': 7.17.0
|
||||
dev: false
|
||||
|
||||
/@babel/helper-compilation-targets/7.17.7_@babel+core@7.13.10:
|
||||
resolution: {integrity: sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0
|
||||
dependencies:
|
||||
'@babel/compat-data': 7.17.7
|
||||
'@babel/core': 7.13.10
|
||||
'@babel/helper-validator-option': 7.16.7
|
||||
browserslist: 4.19.3
|
||||
semver: 6.3.0
|
||||
dev: true
|
||||
|
||||
/@babel/helper-compilation-targets/7.17.7_@babel+core@7.17.7:
|
||||
resolution: {integrity: sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -715,12 +670,6 @@ packages:
|
||||
chalk: 2.4.2
|
||||
js-tokens: 4.0.0
|
||||
|
||||
/@babel/parser/7.14.6:
|
||||
resolution: {integrity: sha512-oG0ej7efjEXxb4UgE+klVx+3j4MVo+A2vCzm7OUN4CLo6WhQ+vSOD2yJ8m7B+DghObxtLxt3EfgMWpq+AsWehQ==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/@babel/parser/7.17.3:
|
||||
resolution: {integrity: sha512-7yJPvPV+ESz2IUTPbOL+YkIGyCqOyNIzdguKQuJGnH7bg1WTIifuM21YqokFt/THWh1AkCRn9IgoykTRCBVpzA==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
@@ -879,22 +828,6 @@ packages:
|
||||
'@babel/parser': 7.17.7
|
||||
'@babel/types': 7.17.0
|
||||
|
||||
/@babel/traverse/7.13.0:
|
||||
resolution: {integrity: sha512-xys5xi5JEhzC3RzEmSGrs/b3pJW/o87SypZ+G/PhaE7uqVQNv/jlmVIBXuoh5atqQ434LfXV+sf23Oxj0bchJQ==}
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.16.7
|
||||
'@babel/generator': 7.17.7
|
||||
'@babel/helper-function-name': 7.16.7
|
||||
'@babel/helper-split-export-declaration': 7.16.7
|
||||
'@babel/parser': 7.17.7
|
||||
'@babel/types': 7.17.0
|
||||
debug: 4.3.3
|
||||
globals: 11.12.0
|
||||
lodash: 4.17.21
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@babel/traverse/7.17.3:
|
||||
resolution: {integrity: sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -912,14 +845,6 @@ packages:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
/@babel/types/7.13.0:
|
||||
resolution: {integrity: sha512-hE+HE8rnG1Z6Wzo+MhaKE5lM5eMx71T4EHJgku2E3xIfaULhDcxiiRxUYgwX8qwP1BBSlag+TdGOt6JAidIZTA==}
|
||||
dependencies:
|
||||
'@babel/helper-validator-identifier': 7.16.7
|
||||
lodash: 4.17.21
|
||||
to-fast-properties: 2.0.0
|
||||
dev: true
|
||||
|
||||
/@babel/types/7.17.0:
|
||||
resolution: {integrity: sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -943,15 +868,15 @@ packages:
|
||||
'@cspotcode/source-map-consumer': 0.8.0
|
||||
dev: true
|
||||
|
||||
/@eslint/eslintrc/1.2.0:
|
||||
resolution: {integrity: sha512-igm9SjJHNEJRiUnecP/1R5T3wKLEJ7pL6e2P+GUSfCd0dGjPYYZve08uzw8L2J8foVHFz+NGu12JxRcU2gGo6w==}
|
||||
/@eslint/eslintrc/1.2.1:
|
||||
resolution: {integrity: sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dependencies:
|
||||
ajv: 6.12.6
|
||||
debug: 4.3.3
|
||||
espree: 9.3.1
|
||||
globals: 13.12.1
|
||||
ignore: 4.0.6
|
||||
globals: 13.13.0
|
||||
ignore: 5.2.0
|
||||
import-fresh: 3.3.0
|
||||
js-yaml: 4.1.0
|
||||
minimatch: 3.1.2
|
||||
@@ -988,31 +913,26 @@ packages:
|
||||
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
|
||||
dev: true
|
||||
|
||||
/@innei-util/eslint-config-ts/0.4.0_typescript@4.6.2:
|
||||
resolution: {integrity: sha512-AJaDdhPUp4VJvQK4VisfU305dVdz7uhccSJUiY4dXBRto1VEDDvp6G5Yu81sB0rBb6l90C1Ik3VgnBT+zVx/1A==}
|
||||
/@innei-util/eslint-config-ts/0.5.0_typescript@4.6.2:
|
||||
resolution: {integrity: sha512-5r/nzXmAEvIjWyRUYH78ifkkwQI24ejVQ2pXd8nrQabqQlUsSB4K3RJiuNmgaZJ8xVzSa985sq1U7JVOzaoseg==}
|
||||
peerDependencies:
|
||||
typescript: '>=4'
|
||||
dependencies:
|
||||
'@typescript-eslint/eslint-plugin': 5.10.1_33fffc354ccfa91fbe7d1677b9395a0a
|
||||
'@typescript-eslint/parser': 5.13.0_eslint@8.10.0+typescript@4.6.2
|
||||
eslint: 8.10.0
|
||||
eslint-config-prettier: 8.5.0_eslint@8.10.0
|
||||
eslint-plugin-import: 2.25.4_eslint@8.10.0
|
||||
'@typescript-eslint/eslint-plugin': 5.10.2_f2c49ce7d0e93ebcfdb4b7d25b131b28
|
||||
'@typescript-eslint/parser': 5.15.0_eslint@8.11.0+typescript@4.6.2
|
||||
eslint: 8.11.0
|
||||
eslint-config-prettier: 8.5.0_eslint@8.11.0
|
||||
eslint-plugin-import: 2.25.4_eslint@8.11.0
|
||||
typescript: 4.6.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@innei-util/prettier/0.2.2_typescript@4.6.2:
|
||||
resolution: {integrity: sha512-2bSj6hOGSd2VuPOb9OA2o+DT7ARozmvvatqf+7kOz4ZKSHnBbvl2YW4cpBc+bgkFzuxcPhz3Ou/jiTOHsE0OuQ==}
|
||||
/@innei-util/prettier/0.4.1:
|
||||
resolution: {integrity: sha512-wodhITa9pR9141ASldYHX1n5B1gZ6KRorJjAU37Qiva8KaeJ4+FJVCl/O0abSwwuLOgM6GRuYcLmg9b3ZAjLRA==}
|
||||
dependencies:
|
||||
'@trivago/prettier-plugin-sort-imports': 3.1.1_prettier@2.5.1
|
||||
prettier: 2.5.1
|
||||
prettier-package-json: 2.6.0
|
||||
prettier-plugin-organize-imports: 2.3.4_prettier@2.5.1+typescript@4.6.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
- typescript
|
||||
dev: true
|
||||
|
||||
/@innei/class-validator-jsonschema/3.1.1_279461c9b8c03a205cdbc4878bc60cf8:
|
||||
@@ -1650,23 +1570,6 @@ packages:
|
||||
engines: {node: '>= 10'}
|
||||
dev: false
|
||||
|
||||
/@trivago/prettier-plugin-sort-imports/3.1.1_prettier@2.5.1:
|
||||
resolution: {integrity: sha512-T9EJNEOugWts4WxdmpWeY+sp+2fUHhvGh9QSBCowEGJfcbnu355HQRqok5bKwejdieMaI1+uGZhuTNMZwjqOCQ==}
|
||||
peerDependencies:
|
||||
prettier: 2.x
|
||||
dependencies:
|
||||
'@babel/core': 7.13.10
|
||||
'@babel/generator': 7.13.9
|
||||
'@babel/parser': 7.14.6
|
||||
'@babel/traverse': 7.13.0
|
||||
'@babel/types': 7.13.0
|
||||
javascript-natural-sort: 0.7.1
|
||||
lodash: 4.17.21
|
||||
prettier: 2.5.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@tsconfig/node10/1.0.8:
|
||||
resolution: {integrity: sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==}
|
||||
dev: true
|
||||
@@ -2064,8 +1967,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@typescript-eslint/eslint-plugin/5.10.1_33fffc354ccfa91fbe7d1677b9395a0a:
|
||||
resolution: {integrity: sha512-xN3CYqFlyE/qOcy978/L0xLR2HlcAGIyIK5sMOasxaaAPfQRj/MmMV6OC3I7NZO84oEUdWCOju34Z9W8E0pFDQ==}
|
||||
/@typescript-eslint/eslint-plugin/5.10.2_f2c49ce7d0e93ebcfdb4b7d25b131b28:
|
||||
resolution: {integrity: sha512-4W/9lLuE+v27O/oe7hXJKjNtBLnZE8tQAFpapdxwSVHqtmIoPB1gph3+ahNwVuNL37BX7YQHyGF9Xv6XCnIX2Q==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
'@typescript-eslint/parser': ^5.0.0
|
||||
@@ -2075,12 +1978,12 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/parser': 5.13.0_eslint@8.10.0+typescript@4.6.2
|
||||
'@typescript-eslint/scope-manager': 5.10.1
|
||||
'@typescript-eslint/type-utils': 5.10.1_eslint@8.10.0+typescript@4.6.2
|
||||
'@typescript-eslint/utils': 5.10.1_eslint@8.10.0+typescript@4.6.2
|
||||
'@typescript-eslint/parser': 5.15.0_eslint@8.11.0+typescript@4.6.2
|
||||
'@typescript-eslint/scope-manager': 5.10.2
|
||||
'@typescript-eslint/type-utils': 5.10.2_eslint@8.11.0+typescript@4.6.2
|
||||
'@typescript-eslint/utils': 5.10.2_eslint@8.11.0+typescript@4.6.2
|
||||
debug: 4.3.3
|
||||
eslint: 8.10.0
|
||||
eslint: 8.11.0
|
||||
functional-red-black-tree: 1.0.1
|
||||
ignore: 5.2.0
|
||||
regexpp: 3.2.0
|
||||
@@ -2091,8 +1994,8 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/parser/5.13.0_eslint@8.10.0+typescript@4.6.2:
|
||||
resolution: {integrity: sha512-GdrU4GvBE29tm2RqWOM0P5QfCtgCyN4hXICj/X9ibKED16136l9ZpoJvCL5pSKtmJzA+NRDzQ312wWMejCVVfg==}
|
||||
/@typescript-eslint/parser/5.15.0_eslint@8.11.0+typescript@4.6.2:
|
||||
resolution: {integrity: sha512-NGAYP/+RDM2sVfmKiKOCgJYPstAO40vPAgACoWPO/+yoYKSgAXIFaBKsV8P0Cc7fwKgvj27SjRNX4L7f4/jCKQ==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
@@ -2101,34 +2004,34 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/scope-manager': 5.13.0
|
||||
'@typescript-eslint/types': 5.13.0
|
||||
'@typescript-eslint/typescript-estree': 5.13.0_typescript@4.6.2
|
||||
'@typescript-eslint/scope-manager': 5.15.0
|
||||
'@typescript-eslint/types': 5.15.0
|
||||
'@typescript-eslint/typescript-estree': 5.15.0_typescript@4.6.2
|
||||
debug: 4.3.3
|
||||
eslint: 8.10.0
|
||||
eslint: 8.11.0
|
||||
typescript: 4.6.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/scope-manager/5.10.1:
|
||||
resolution: {integrity: sha512-Lyvi559Gvpn94k7+ElXNMEnXu/iundV5uFmCUNnftbFrUbAJ1WBoaGgkbOBm07jVZa682oaBU37ao/NGGX4ZDg==}
|
||||
/@typescript-eslint/scope-manager/5.10.2:
|
||||
resolution: {integrity: sha512-39Tm6f4RoZoVUWBYr3ekS75TYgpr5Y+X0xLZxXqcZNDWZdJdYbKd3q2IR4V9y5NxxiPu/jxJ8XP7EgHiEQtFnw==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 5.10.1
|
||||
'@typescript-eslint/visitor-keys': 5.10.1
|
||||
'@typescript-eslint/types': 5.10.2
|
||||
'@typescript-eslint/visitor-keys': 5.10.2
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/scope-manager/5.13.0:
|
||||
resolution: {integrity: sha512-T4N8UvKYDSfVYdmJq7g2IPJYCRzwtp74KyDZytkR4OL3NRupvswvmJQJ4CX5tDSurW2cvCc1Ia1qM7d0jpa7IA==}
|
||||
/@typescript-eslint/scope-manager/5.15.0:
|
||||
resolution: {integrity: sha512-EFiZcSKrHh4kWk0pZaa+YNJosvKE50EnmN4IfgjkA3bTHElPtYcd2U37QQkNTqwMCS7LXeDeZzEqnsOH8chjSg==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 5.13.0
|
||||
'@typescript-eslint/visitor-keys': 5.13.0
|
||||
'@typescript-eslint/types': 5.15.0
|
||||
'@typescript-eslint/visitor-keys': 5.15.0
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/type-utils/5.10.1_eslint@8.10.0+typescript@4.6.2:
|
||||
resolution: {integrity: sha512-AfVJkV8uck/UIoDqhu+ptEdBoQATON9GXnhOpPLzkQRJcSChkvD//qsz9JVffl2goxX+ybs5klvacE9vmrQyCw==}
|
||||
/@typescript-eslint/type-utils/5.10.2_eslint@8.11.0+typescript@4.6.2:
|
||||
resolution: {integrity: sha512-uRKSvw/Ccs5FYEoXW04Z5VfzF2iiZcx8Fu7DGIB7RHozuP0VbKNzP1KfZkHBTM75pCpsWxIthEH1B33dmGBKHw==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
eslint: '*'
|
||||
@@ -2137,27 +2040,27 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/utils': 5.10.1_eslint@8.10.0+typescript@4.6.2
|
||||
'@typescript-eslint/utils': 5.10.2_eslint@8.11.0+typescript@4.6.2
|
||||
debug: 4.3.3
|
||||
eslint: 8.10.0
|
||||
eslint: 8.11.0
|
||||
tsutils: 3.21.0_typescript@4.6.2
|
||||
typescript: 4.6.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/types/5.10.1:
|
||||
resolution: {integrity: sha512-ZvxQ2QMy49bIIBpTqFiOenucqUyjTQ0WNLhBM6X1fh1NNlYAC6Kxsx8bRTY3jdYsYg44a0Z/uEgQkohbR0H87Q==}
|
||||
/@typescript-eslint/types/5.10.2:
|
||||
resolution: {integrity: sha512-Qfp0qk/5j2Rz3p3/WhWgu4S1JtMcPgFLnmAKAW061uXxKSa7VWKZsDXVaMXh2N60CX9h6YLaBoy9PJAfCOjk3w==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/types/5.13.0:
|
||||
resolution: {integrity: sha512-LmE/KO6DUy0nFY/OoQU0XelnmDt+V8lPQhh8MOVa7Y5k2gGRd6U9Kp3wAjhB4OHg57tUO0nOnwYQhRRyEAyOyg==}
|
||||
/@typescript-eslint/types/5.15.0:
|
||||
resolution: {integrity: sha512-yEiTN4MDy23vvsIksrShjNwQl2vl6kJeG9YkVJXjXZnkJElzVK8nfPsWKYxcsGWG8GhurYXP4/KGj3aZAxbeOA==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/typescript-estree/5.10.1_typescript@4.6.2:
|
||||
resolution: {integrity: sha512-PwIGnH7jIueXv4opcwEbVGDATjGPO1dx9RkUl5LlHDSe+FXxPwFL5W/qYd5/NHr7f6lo/vvTrAzd0KlQtRusJQ==}
|
||||
/@typescript-eslint/typescript-estree/5.10.2_typescript@4.6.2:
|
||||
resolution: {integrity: sha512-WHHw6a9vvZls6JkTgGljwCsMkv8wu8XU8WaYKeYhxhWXH/atZeiMW6uDFPLZOvzNOGmuSMvHtZKd6AuC8PrwKQ==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
typescript: '*'
|
||||
@@ -2165,8 +2068,8 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 5.10.1
|
||||
'@typescript-eslint/visitor-keys': 5.10.1
|
||||
'@typescript-eslint/types': 5.10.2
|
||||
'@typescript-eslint/visitor-keys': 5.10.2
|
||||
debug: 4.3.3
|
||||
globby: 11.1.0
|
||||
is-glob: 4.0.3
|
||||
@@ -2177,8 +2080,8 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/typescript-estree/5.13.0_typescript@4.6.2:
|
||||
resolution: {integrity: sha512-Q9cQow0DeLjnp5DuEDjLZ6JIkwGx3oYZe+BfcNuw/POhtpcxMTy18Icl6BJqTSd+3ftsrfuVb7mNHRZf7xiaNA==}
|
||||
/@typescript-eslint/typescript-estree/5.15.0_typescript@4.6.2:
|
||||
resolution: {integrity: sha512-Hb0e3dGc35b75xLzixM3cSbG1sSbrTBQDfIScqdyvrfJZVEi4XWAT+UL/HMxEdrJNB8Yk28SKxPLtAhfCbBInA==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
typescript: '*'
|
||||
@@ -2186,8 +2089,8 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 5.13.0
|
||||
'@typescript-eslint/visitor-keys': 5.13.0
|
||||
'@typescript-eslint/types': 5.15.0
|
||||
'@typescript-eslint/visitor-keys': 5.15.0
|
||||
debug: 4.3.3
|
||||
globby: 11.1.0
|
||||
is-glob: 4.0.3
|
||||
@@ -2198,37 +2101,37 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/utils/5.10.1_eslint@8.10.0+typescript@4.6.2:
|
||||
resolution: {integrity: sha512-RRmlITiUbLuTRtn/gcPRi4202niF+q7ylFLCKu4c+O/PcpRvZ/nAUwQ2G00bZgpWkhrNLNnvhZLbDn8Ml0qsQw==}
|
||||
/@typescript-eslint/utils/5.10.2_eslint@8.11.0+typescript@4.6.2:
|
||||
resolution: {integrity: sha512-vuJaBeig1NnBRkf7q9tgMLREiYD7zsMrsN1DA3wcoMDvr3BTFiIpKjGiYZoKPllfEwN7spUjv7ZqD+JhbVjEPg==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
dependencies:
|
||||
'@types/json-schema': 7.0.9
|
||||
'@typescript-eslint/scope-manager': 5.10.1
|
||||
'@typescript-eslint/types': 5.10.1
|
||||
'@typescript-eslint/typescript-estree': 5.10.1_typescript@4.6.2
|
||||
eslint: 8.10.0
|
||||
'@typescript-eslint/scope-manager': 5.10.2
|
||||
'@typescript-eslint/types': 5.10.2
|
||||
'@typescript-eslint/typescript-estree': 5.10.2_typescript@4.6.2
|
||||
eslint: 8.11.0
|
||||
eslint-scope: 5.1.1
|
||||
eslint-utils: 3.0.0_eslint@8.10.0
|
||||
eslint-utils: 3.0.0_eslint@8.11.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
- typescript
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/visitor-keys/5.10.1:
|
||||
resolution: {integrity: sha512-NjQ0Xinhy9IL979tpoTRuLKxMc0zJC7QVSdeerXs2/QvOy2yRkzX5dRb10X5woNUdJgU8G3nYRDlI33sq1K4YQ==}
|
||||
/@typescript-eslint/visitor-keys/5.10.2:
|
||||
resolution: {integrity: sha512-zHIhYGGGrFJvvyfwHk5M08C5B5K4bewkm+rrvNTKk1/S15YHR+SA/QUF8ZWscXSfEaB8Nn2puZj+iHcoxVOD/Q==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 5.10.1
|
||||
'@typescript-eslint/types': 5.10.2
|
||||
eslint-visitor-keys: 3.3.0
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/visitor-keys/5.13.0:
|
||||
resolution: {integrity: sha512-HLKEAS/qA1V7d9EzcpLFykTePmOQqOFim8oCvhY3pZgQ8Hi38hYpHd9e5GN6nQBFQNecNhws5wkS9Y5XIO0s/g==}
|
||||
/@typescript-eslint/visitor-keys/5.15.0:
|
||||
resolution: {integrity: sha512-+vX5FKtgvyHbmIJdxMJ2jKm9z2BIlXJiuewI8dsDYMp5LzPUcuTT78Ya5iwvQg3VqSVdmxyM8Anj1Jeq7733ZQ==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 5.13.0
|
||||
'@typescript-eslint/types': 5.15.0
|
||||
eslint-visitor-keys: 3.3.0
|
||||
dev: true
|
||||
|
||||
@@ -2715,14 +2618,6 @@ packages:
|
||||
is-retry-allowed: 2.2.0
|
||||
dev: false
|
||||
|
||||
/axios/0.26.0:
|
||||
resolution: {integrity: sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og==}
|
||||
dependencies:
|
||||
follow-redirects: 1.14.9
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
dev: false
|
||||
|
||||
/axios/0.26.1:
|
||||
resolution: {integrity: sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==}
|
||||
dependencies:
|
||||
@@ -3390,8 +3285,8 @@ packages:
|
||||
whatwg-url: 10.0.0
|
||||
dev: false
|
||||
|
||||
/dayjs/1.10.8:
|
||||
resolution: {integrity: sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==}
|
||||
/dayjs/1.11.0:
|
||||
resolution: {integrity: sha512-JLC809s6Y948/FuCZPm5IX8rRhQwOiyMb2TfVVQEixG7P8Lm/gt5S7yoQZmC8x1UehI9Pb7sksEt4xx14m+7Ug==}
|
||||
dev: false
|
||||
|
||||
/debounce-fn/4.0.0:
|
||||
@@ -3768,13 +3663,13 @@ packages:
|
||||
optionalDependencies:
|
||||
source-map: 0.6.1
|
||||
|
||||
/eslint-config-prettier/8.5.0_eslint@8.10.0:
|
||||
/eslint-config-prettier/8.5.0_eslint@8.11.0:
|
||||
resolution: {integrity: sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
eslint: '>=7.0.0'
|
||||
dependencies:
|
||||
eslint: 8.10.0
|
||||
eslint: 8.11.0
|
||||
dev: true
|
||||
|
||||
/eslint-import-resolver-node/0.3.6:
|
||||
@@ -3792,7 +3687,7 @@ packages:
|
||||
find-up: 2.1.0
|
||||
dev: true
|
||||
|
||||
/eslint-plugin-import/2.25.4_eslint@8.10.0:
|
||||
/eslint-plugin-import/2.25.4_eslint@8.11.0:
|
||||
resolution: {integrity: sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA==}
|
||||
engines: {node: '>=4'}
|
||||
peerDependencies:
|
||||
@@ -3802,7 +3697,7 @@ packages:
|
||||
array.prototype.flat: 1.2.5
|
||||
debug: 2.6.9
|
||||
doctrine: 2.1.0
|
||||
eslint: 8.10.0
|
||||
eslint: 8.11.0
|
||||
eslint-import-resolver-node: 0.3.6
|
||||
eslint-module-utils: 2.7.3
|
||||
has: 1.0.3
|
||||
@@ -3830,13 +3725,13 @@ packages:
|
||||
estraverse: 5.3.0
|
||||
dev: true
|
||||
|
||||
/eslint-utils/3.0.0_eslint@8.10.0:
|
||||
/eslint-utils/3.0.0_eslint@8.11.0:
|
||||
resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==}
|
||||
engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0}
|
||||
peerDependencies:
|
||||
eslint: '>=5'
|
||||
dependencies:
|
||||
eslint: 8.10.0
|
||||
eslint: 8.11.0
|
||||
eslint-visitor-keys: 2.1.0
|
||||
dev: true
|
||||
|
||||
@@ -3850,12 +3745,12 @@ packages:
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
dev: true
|
||||
|
||||
/eslint/8.10.0:
|
||||
resolution: {integrity: sha512-tcI1D9lfVec+R4LE1mNDnzoJ/f71Kl/9Cv4nG47jOueCMBrCCKYXr4AUVS7go6mWYGFD4+EoN6+eXSrEbRzXVw==}
|
||||
/eslint/8.11.0:
|
||||
resolution: {integrity: sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@eslint/eslintrc': 1.2.0
|
||||
'@eslint/eslintrc': 1.2.1
|
||||
'@humanwhocodes/config-array': 0.9.5
|
||||
ajv: 6.12.6
|
||||
chalk: 4.1.2
|
||||
@@ -3864,7 +3759,7 @@ packages:
|
||||
doctrine: 3.0.0
|
||||
escape-string-regexp: 4.0.0
|
||||
eslint-scope: 7.1.1
|
||||
eslint-utils: 3.0.0_eslint@8.10.0
|
||||
eslint-utils: 3.0.0_eslint@8.11.0
|
||||
eslint-visitor-keys: 3.3.0
|
||||
espree: 9.3.1
|
||||
esquery: 1.4.0
|
||||
@@ -3873,7 +3768,7 @@ packages:
|
||||
file-entry-cache: 6.0.1
|
||||
functional-red-black-tree: 1.0.1
|
||||
glob-parent: 6.0.2
|
||||
globals: 13.12.1
|
||||
globals: 13.13.0
|
||||
ignore: 5.2.0
|
||||
import-fresh: 3.3.0
|
||||
imurmurhash: 0.1.4
|
||||
@@ -4558,8 +4453,8 @@ packages:
|
||||
resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
/globals/13.12.1:
|
||||
resolution: {integrity: sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==}
|
||||
/globals/13.13.0:
|
||||
resolution: {integrity: sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
type-fest: 0.20.2
|
||||
@@ -4778,11 +4673,6 @@ packages:
|
||||
/ieee754/1.2.1:
|
||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||
|
||||
/ignore/4.0.6:
|
||||
resolution: {integrity: sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==}
|
||||
engines: {node: '>= 4'}
|
||||
dev: true
|
||||
|
||||
/ignore/5.2.0:
|
||||
resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==}
|
||||
engines: {node: '>= 4'}
|
||||
@@ -5148,10 +5038,6 @@ packages:
|
||||
minimatch: 3.1.2
|
||||
dev: false
|
||||
|
||||
/javascript-natural-sort/0.7.1:
|
||||
resolution: {integrity: sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k=}
|
||||
dev: true
|
||||
|
||||
/jest-changed-files/27.5.1:
|
||||
resolution: {integrity: sha512-buBLMiByfWGCoMsLLzGUUSpAmIAGnbR2KJoMN10ziLhOLvP4e0SlypHnAel8iqQXTrcbmfEY9sSqae5sgUsTvw==}
|
||||
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
|
||||
@@ -5913,8 +5799,8 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/lines-and-columns/1.1.6:
|
||||
resolution: {integrity: sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=}
|
||||
/lines-and-columns/1.2.4:
|
||||
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
|
||||
dev: true
|
||||
|
||||
/lint-staged/12.3.5:
|
||||
@@ -6807,7 +6693,7 @@ packages:
|
||||
'@babel/code-frame': 7.16.7
|
||||
error-ex: 1.3.2
|
||||
json-parse-even-better-errors: 2.3.1
|
||||
lines-and-columns: 1.1.6
|
||||
lines-and-columns: 1.2.4
|
||||
dev: true
|
||||
|
||||
/parse5/6.0.1:
|
||||
@@ -6963,16 +6849,6 @@ packages:
|
||||
sort-order: 1.0.1
|
||||
dev: true
|
||||
|
||||
/prettier-plugin-organize-imports/2.3.4_prettier@2.5.1+typescript@4.6.2:
|
||||
resolution: {integrity: sha512-R8o23sf5iVL/U71h9SFUdhdOEPsi3nm42FD/oDYIZ2PQa4TNWWuWecxln6jlIQzpZTDMUeO1NicJP6lLn2TtRw==}
|
||||
peerDependencies:
|
||||
prettier: '>=2.0'
|
||||
typescript: '>=2.9'
|
||||
dependencies:
|
||||
prettier: 2.5.1
|
||||
typescript: 4.6.2
|
||||
dev: true
|
||||
|
||||
/prettier/2.5.1:
|
||||
resolution: {integrity: sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import cluster from 'cluster'
|
||||
import { performance } from 'perf_hooks'
|
||||
import { Logger, RequestMethod, ValidationPipe } from '@nestjs/common'
|
||||
import { NestFactory } from '@nestjs/core'
|
||||
import { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
import cluster from 'cluster'
|
||||
import { performance } from 'perf_hooks'
|
||||
import { API_VERSION, CROSS_DOMAIN, PORT } from './app.config'
|
||||
import { AppModule } from './app.module'
|
||||
import { fastifyApp } from './common/adapters/fastify.adapter'
|
||||
@@ -96,9 +96,7 @@ export async function bootstrap() {
|
||||
consola.success(
|
||||
`[${prefix + pid}] Admin Local Dashboard: ${url}/proxy/qaqdmin`,
|
||||
)
|
||||
Logger.log(
|
||||
'Server is up. ' + chalk.yellow('+' + (performance.now() | 0) + 'ms'),
|
||||
)
|
||||
Logger.log(`Server is up. ${chalk.yellow(`+${performance.now() | 0}ms`)}`)
|
||||
})
|
||||
|
||||
if (module.hot) {
|
||||
|
||||
@@ -7,9 +7,9 @@ export class Cluster {
|
||||
const cpus = os.cpus().length
|
||||
|
||||
consola.info(`Primary server started on ${process.pid}`)
|
||||
consola.info('CPU:' + cpus)
|
||||
//ensure workers exit cleanly
|
||||
process.on('SIGINT', function () {
|
||||
consola.info(`CPU:${cpus}`)
|
||||
// ensure workers exit cleanly
|
||||
process.on('SIGINT', () => {
|
||||
consola.info('Cluster shutting down...')
|
||||
for (const id in cluster.workers) {
|
||||
cluster.workers[id].kill()
|
||||
@@ -24,15 +24,15 @@ export class Cluster {
|
||||
cluster.fork()
|
||||
}
|
||||
|
||||
cluster.on('fork', function (worker) {
|
||||
worker.on('message', function (msg) {
|
||||
Object.keys(cluster.workers).forEach(function (id) {
|
||||
cluster.on('fork', (worker) => {
|
||||
worker.on('message', (msg) => {
|
||||
Object.keys(cluster.workers).forEach((id) => {
|
||||
cluster.workers[id].send(msg)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
cluster.on('online', function (worker) {
|
||||
cluster.on('online', (worker) => {
|
||||
consola.info('Worker %s is online', worker.process.pid)
|
||||
})
|
||||
cluster.on('exit', (worker, code, signal) => {
|
||||
|
||||
@@ -63,7 +63,7 @@ const logWarn = (desc: string, req: FastifyRequest, context: string) => {
|
||||
const ua = req.raw.headers['user-agent']
|
||||
Logger.warn(
|
||||
// prettier-ignore
|
||||
desc + '\n' +
|
||||
`${desc}\n` +
|
||||
`Path: ${req.url}\n` +
|
||||
`IP: ${getIp(req)}\n` +
|
||||
`UA: ${ua}`,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { applyDecorators, UseGuards } from '@nestjs/common'
|
||||
import { UseGuards, applyDecorators } from '@nestjs/common'
|
||||
import { ApiBearerAuth, ApiUnauthorizedResponse } from '@nestjs/swagger'
|
||||
import { SECURITY } from '~/app.config'
|
||||
import { JWTAuthGuard } from '../guard/auth.guard'
|
||||
import { SECURITY } from '~/app.config'
|
||||
|
||||
export function Auth() {
|
||||
const decorators = []
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
import { ExecutionContext, createParamDecorator } from '@nestjs/common'
|
||||
import { FastifyRequest } from 'fastify'
|
||||
|
||||
export const Cookies = createParamDecorator(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
import { ExecutionContext, createParamDecorator } from '@nestjs/common'
|
||||
import { getNestExecutionContextRequest } from '~/utils/nest.util'
|
||||
|
||||
export const CurrentUser = createParamDecorator(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { applyDecorators, SetMetadata } from '@nestjs/common'
|
||||
import { SetMetadata, applyDecorators } from '@nestjs/common'
|
||||
import { ApiBody, ApiConsumes } from '@nestjs/swagger'
|
||||
import { HTTP_RES_TRANSFORM_PAGINATE } from '~/constants/meta.constant'
|
||||
import * as SYSTEM from '~/constants/system.constant'
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @Coding with Love
|
||||
*/
|
||||
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
import { ExecutionContext, createParamDecorator } from '@nestjs/common'
|
||||
import { FastifyRequest } from 'fastify'
|
||||
import { getIp } from '~/utils/ip.util'
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@ export const ApiName: ClassDecorator = (target) => {
|
||||
return
|
||||
}
|
||||
const [name] = target.name.split('Controller')
|
||||
ApiTags(name + ' Routes').call(null, target)
|
||||
ApiTags(`${name} Routes`).call(null, target)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
import { ExecutionContext, createParamDecorator } from '@nestjs/common'
|
||||
import { getNestExecutionContextRequest } from '~/utils/nest.util'
|
||||
|
||||
export const IsGuest = createParamDecorator(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { WriteStream } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import {
|
||||
ArgumentsHost,
|
||||
Catch,
|
||||
@@ -9,14 +11,12 @@ import {
|
||||
} from '@nestjs/common'
|
||||
import { Reflector } from '@nestjs/core'
|
||||
import { FastifyReply, FastifyRequest } from 'fastify'
|
||||
import { WriteStream } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { getIp } from '../../utils/ip.util'
|
||||
import { LoggingInterceptor } from '../interceptors/logging.interceptor'
|
||||
import { HTTP_REQUEST_TIME } from '~/constants/meta.constant'
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
import { REFLECTOR } from '~/constants/system.constant'
|
||||
import { isDev } from '~/global/env.global'
|
||||
import { getIp } from '../../utils/ip.util'
|
||||
import { LoggingInterceptor } from '../interceptors/logging.interceptor'
|
||||
|
||||
type myError = {
|
||||
readonly status: number
|
||||
@@ -62,9 +62,7 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
||||
`[${new Date().toISOString()}] ${decodeURI(request.raw.url)}: ${
|
||||
(exception as any)?.response?.message ||
|
||||
(exception as myError)?.message
|
||||
}\n` +
|
||||
(exception as Error).stack +
|
||||
'\n',
|
||||
}\n${(exception as Error).stack}\n`,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -79,11 +77,11 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
||||
const prevRequestTs = this.reflector.get(HTTP_REQUEST_TIME, request as any)
|
||||
|
||||
if (prevRequestTs) {
|
||||
const content = request.method + ' -> ' + request.url
|
||||
const content = `${request.method} -> ${request.url}`
|
||||
Logger.debug(
|
||||
'--- 响应异常请求:' +
|
||||
content +
|
||||
chalk.yellow(` +${+new Date() - prevRequestTs}ms`),
|
||||
`--- 响应异常请求:${content}${chalk.yellow(
|
||||
` +${+new Date() - prevRequestTs}ms`,
|
||||
)}`,
|
||||
LoggingInterceptor.name,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class SpiderGuard implements CanActivate {
|
||||
if (ua && !isSpiderUA) {
|
||||
return true
|
||||
}
|
||||
throw new ForbiddenException('爬虫是被禁止的哦,UA: ' + ua)
|
||||
throw new ForbiddenException(`爬虫是被禁止的哦,UA: ${ua}`)
|
||||
}
|
||||
|
||||
getRequest(context: ExecutionContext) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* @module interceptor/analyze
|
||||
* @author Innei <https://github.com/Innei>
|
||||
*/
|
||||
import { URL } from 'url'
|
||||
import {
|
||||
CallHandler,
|
||||
ExecutionContext,
|
||||
@@ -15,7 +16,6 @@ import isbot from 'isbot'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { Observable } from 'rxjs'
|
||||
import UAParser from 'ua-parser-js'
|
||||
import { URL } from 'url'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { AnalyzeModel } from '~/modules/analyze/analyze.model'
|
||||
import { OptionModel } from '~/modules/configs/configs.model'
|
||||
@@ -82,7 +82,7 @@ export class AnalyzeInterceptor implements NestInterceptor {
|
||||
await this.model.create({
|
||||
ip,
|
||||
ua,
|
||||
path: new URL('http://a.com' + url).pathname,
|
||||
path: new URL(`http://a.com${url}`).pathname,
|
||||
})
|
||||
const apiCallTimeRecord = await this.options.findOne({
|
||||
name: 'apiCallTime',
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '@nestjs/common'
|
||||
import { Reflector } from '@nestjs/core'
|
||||
import { isArrayLike, isObjectLike } from 'lodash'
|
||||
import { map, Observable } from 'rxjs'
|
||||
import { Observable, map } from 'rxjs'
|
||||
import snakecaseKeys from 'snakecase-keys'
|
||||
import { RESPONSE_PASSTHROUGH_METADATA } from '~/constants/system.constant'
|
||||
|
||||
|
||||
@@ -31,15 +31,15 @@ export class LoggingInterceptor implements NestInterceptor {
|
||||
): Observable<any> {
|
||||
const call$ = next.handle()
|
||||
const request = this.getRequest(context)
|
||||
const content = request.method + ' -> ' + request.url
|
||||
this.logger.debug('+++ 收到请求:' + content)
|
||||
const content = `${request.method} -> ${request.url}`
|
||||
this.logger.debug(`+++ 收到请求:${content}`)
|
||||
const now = +new Date()
|
||||
SetMetadata(HTTP_REQUEST_TIME, now)(this.getRequest(context) as any)
|
||||
|
||||
return call$.pipe(
|
||||
tap(() =>
|
||||
this.logger.debug(
|
||||
'--- 响应请求:' + content + chalk.yellow(` +${+new Date() - now}ms`),
|
||||
`--- 响应请求:${content}${chalk.yellow(` +${+new Date() - now}ms`)}`,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* @author Innei <https://innei.ren>
|
||||
*/
|
||||
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common'
|
||||
import { IncomingMessage, ServerResponse } from 'http'
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common'
|
||||
import { parseRelativeUrl } from '~/utils/ip.util'
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/* eslint-disable prefer-rest-params */
|
||||
import { CronExpression } from '@nestjs/schedule'
|
||||
import consola_, { FancyReporter, LogLevel } from 'consola'
|
||||
import { CronJob } from 'cron'
|
||||
import { createWriteStream } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import consola_, { FancyReporter, LogLevel } from 'consola'
|
||||
import { CronJob } from 'cron'
|
||||
import { CronExpression } from '@nestjs/schedule'
|
||||
import { argv } from 'zx'
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
import { redisSubPub } from '../utils/redis-subpub.util'
|
||||
import { getShortDate, getShortTime } from '../utils/time.util'
|
||||
import { isDev, isTest } from './env.global'
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
|
||||
export const getTodayLogFilePath = () =>
|
||||
resolve(LOG_DIR, 'stdout_' + getShortDate(new Date()) + '.log')
|
||||
resolve(LOG_DIR, `stdout_${getShortDate(new Date())}.log`)
|
||||
|
||||
class Reporter extends FancyReporter {
|
||||
isInVirtualTerminal = typeof process.stdout.columns === 'undefined' // HACK: if got `undefined` that means in PM2 pty
|
||||
@@ -21,11 +21,9 @@ class Reporter extends FancyReporter {
|
||||
|
||||
protected formatLogObj(): string {
|
||||
return this.isInVirtualTerminal
|
||||
? (
|
||||
chalk.gray(getShortTime(new Date())) +
|
||||
' ' +
|
||||
super.formatLogObj.apply(this, arguments).replace(/^\n/, '')
|
||||
).trimEnd()
|
||||
? `${chalk.gray(getShortTime(new Date()))} ${super.formatLogObj
|
||||
.apply(this, arguments)
|
||||
.replace(/^\n/, '')}`.trimEnd()
|
||||
: super.formatLogObj.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
import { Logger } from '@nestjs/common'
|
||||
/* eslint-disable import/order */
|
||||
import 'zx/globals'
|
||||
import './dayjs.global'
|
||||
import { consola, registerStdLogger } from './consola.global'
|
||||
|
||||
import cluster from 'cluster'
|
||||
import { mkdirSync } from 'fs'
|
||||
import 'zx/globals'
|
||||
import { CLUSTER } from '~/app.config'
|
||||
import { Logger } from '@nestjs/common'
|
||||
import {
|
||||
DATA_DIR,
|
||||
LOG_DIR,
|
||||
TEMP_DIR,
|
||||
USER_ASSET_DIR,
|
||||
} from '~/constants/path.constant'
|
||||
import { consola, registerStdLogger } from './consola.global'
|
||||
import './dayjs.global'
|
||||
|
||||
import { isDev } from './env.global'
|
||||
import { CLUSTER } from '~/app.config'
|
||||
|
||||
// 建立目录
|
||||
function mkdirs() {
|
||||
if (!CLUSTER.enable || cluster.isPrimary) {
|
||||
mkdirSync(DATA_DIR, { recursive: true })
|
||||
Logger.log(chalk.blue('数据目录已经建好: ' + DATA_DIR))
|
||||
Logger.log(chalk.blue(`数据目录已经建好: ${DATA_DIR}`))
|
||||
mkdirSync(TEMP_DIR, { recursive: true })
|
||||
Logger.log(chalk.blue('临时目录已经建好: ' + TEMP_DIR))
|
||||
Logger.log(chalk.blue(`临时目录已经建好: ${TEMP_DIR}`))
|
||||
mkdirSync(LOG_DIR, { recursive: true })
|
||||
Logger.log(chalk.blue('日志目录已经建好: ' + LOG_DIR))
|
||||
Logger.log(chalk.blue(`日志目录已经建好: ${LOG_DIR}`))
|
||||
mkdirSync(USER_ASSET_DIR, { recursive: true })
|
||||
Logger.log(chalk.blue('资源目录已经建好: ' + USER_ASSET_DIR))
|
||||
Logger.log(chalk.blue(`资源目录已经建好: ${USER_ASSET_DIR}`))
|
||||
}
|
||||
}
|
||||
|
||||
function registerGlobal() {
|
||||
$.verbose = isDev
|
||||
Object.assign(globalThis, {
|
||||
isDev: isDev,
|
||||
isDev,
|
||||
consola,
|
||||
})
|
||||
console.debug = (...rest) => {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { CacheKey, CacheTTL, Controller, Get, Query } from '@nestjs/common'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { omit } from 'lodash'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { CacheKeys } from '~/constants/cache.constant'
|
||||
import { AnalyzeService } from '../analyze/analyze.service'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { TimelineQueryDto, TopQueryDto } from './aggregate.dto'
|
||||
import { AggregateService } from './aggregate.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { CacheKeys } from '~/constants/cache.constant'
|
||||
|
||||
@Controller('aggregate')
|
||||
@ApiName
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { forwardRef, Module } from '@nestjs/common'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
import { Module, forwardRef } from '@nestjs/common'
|
||||
import { AnalyzeModule } from '../analyze/analyze.module'
|
||||
import { CategoryModule } from '../category/category.module'
|
||||
import { CommentModule } from '../comment/comment.module'
|
||||
@@ -11,6 +10,7 @@ import { RecentlyModule } from '../recently/recently.module'
|
||||
import { SayModule } from '../say/say.module'
|
||||
import { AggregateController } from './aggregate.controller'
|
||||
import { AggregateService } from './aggregate.service'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
import { forwardRef, Inject, Injectable } from '@nestjs/common'
|
||||
import { OnEvent } from '@nestjs/event-emitter'
|
||||
import { DocumentType, ReturnModelType } from '@typegoose/typegoose'
|
||||
import { AnyParamConstructor } from '@typegoose/typegoose/lib/types'
|
||||
import dayjs from 'dayjs'
|
||||
import { pick } from 'lodash'
|
||||
import { FilterQuery } from 'mongoose'
|
||||
import { URL } from 'url'
|
||||
import { CacheKeys, RedisKeys } from '~/constants/cache.constant'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { addYearCondition } from '~/utils/query.util'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { getShortDate } from '~/utils/time.util'
|
||||
import { FilterQuery } from 'mongoose'
|
||||
import { pick } from 'lodash'
|
||||
import dayjs from 'dayjs'
|
||||
import { AnyParamConstructor } from '@typegoose/typegoose/lib/types'
|
||||
import { DocumentType, ReturnModelType } from '@typegoose/typegoose'
|
||||
import { OnEvent } from '@nestjs/event-emitter'
|
||||
import { Inject, Injectable, forwardRef } from '@nestjs/common'
|
||||
import { CategoryModel } from '../category/category.model'
|
||||
import { CategoryService } from '../category/category.service'
|
||||
import { CommentState } from '../comment/comment.model'
|
||||
@@ -28,6 +21,13 @@ import { RecentlyService } from '../recently/recently.service'
|
||||
import { SayService } from '../say/say.service'
|
||||
import { TimelineType } from './aggregate.dto'
|
||||
import { RSSProps } from './aggregate.interface'
|
||||
import { getShortDate } from '~/utils/time.util'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { addYearCondition } from '~/utils/query.util'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { CacheKeys, RedisKeys } from '~/constants/cache.constant'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
@Injectable()
|
||||
export class AggregateService {
|
||||
constructor(
|
||||
@@ -138,10 +138,7 @@ export class AggregateService {
|
||||
// ? item.text.slice(0, 150) + '...'
|
||||
// : item.text),
|
||||
url: encodeURI(
|
||||
'/posts/' +
|
||||
(item.category as CategoryModel).slug +
|
||||
'/' +
|
||||
item.slug,
|
||||
`/posts/${(item.category as CategoryModel).slug}/${item.slug}`,
|
||||
),
|
||||
})),
|
||||
)
|
||||
@@ -296,7 +293,7 @@ export class AggregateService {
|
||||
text: isSecret ? '这篇文章暂时没有公开呢' : note.text,
|
||||
created: note.created,
|
||||
modified: note.modified,
|
||||
link: new URL('/notes/' + note.nid, baseURL).toString(),
|
||||
link: new URL(`/notes/${note.nid}`, baseURL).toString(),
|
||||
}
|
||||
})
|
||||
return postsRss
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Controller, Delete, Get, HttpCode, Query, Scope } from '@nestjs/common'
|
||||
import dayjs from 'dayjs'
|
||||
import { AnalyzeDto } from './analyze.dto'
|
||||
import { AnalyzeService } from './analyze.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { Paginator } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
@@ -8,8 +10,6 @@ import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { PagerDto } from '~/shared/dto/pager.dto'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { getTodayEarly, getWeekStart } from '~/utils/time.util'
|
||||
import { AnalyzeDto } from './analyze.dto'
|
||||
import { AnalyzeService } from './analyze.service'
|
||||
|
||||
@Controller({ path: 'analyze', scope: Scope.REQUEST })
|
||||
@ApiName
|
||||
@@ -67,12 +67,12 @@ export class AnalyzeController {
|
||||
.map((v, i) => {
|
||||
return [
|
||||
{
|
||||
hour: i + '时',
|
||||
hour: `${i}时`,
|
||||
key: 'ip',
|
||||
value: day[i.toString().padStart(2, '0')]?.ip || 0,
|
||||
},
|
||||
{
|
||||
hour: i + '时',
|
||||
hour: `${i}时`,
|
||||
key: 'pv',
|
||||
value: day[i.toString().padStart(2, '0')]?.pv || 0,
|
||||
},
|
||||
@@ -83,11 +83,11 @@ export class AnalyzeController {
|
||||
const weekData = all
|
||||
.slice(0, 7)
|
||||
.map((item) => {
|
||||
const date =
|
||||
'周' +
|
||||
const date = `周${
|
||||
['日', '一', '二', '三', '四', '五', '六'][
|
||||
dayjs(item.date).get('day')
|
||||
]
|
||||
}`
|
||||
return [
|
||||
{
|
||||
day: date,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiHideProperty } from '@nestjs/swagger'
|
||||
import { index, modelOptions, prop, Severity } from '@typegoose/typegoose'
|
||||
import { Severity, index, modelOptions, prop } from '@typegoose/typegoose'
|
||||
import { SchemaTypes } from 'mongoose'
|
||||
import type { UAParser } from 'ua-parser-js'
|
||||
import { BaseModel } from '~/shared/model/base.model'
|
||||
|
||||
@@ -4,11 +4,11 @@ import dayjs from 'dayjs'
|
||||
import { merge } from 'lodash'
|
||||
import { PipelineStage } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { OptionModel } from '../configs/configs.model'
|
||||
import { AnalyzeModel } from './analyze.model'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { OptionModel } from '../configs/configs.model'
|
||||
import { AnalyzeModel } from './analyze.model'
|
||||
|
||||
@Injectable()
|
||||
export class AnalyzeService {
|
||||
|
||||
@@ -12,17 +12,17 @@ import { ApiBearerAuth, ApiOperation } from '@nestjs/swagger'
|
||||
import { Transform } from 'class-transformer'
|
||||
import {
|
||||
IsDate,
|
||||
isMongoId,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
isMongoId,
|
||||
} from 'class-validator'
|
||||
import { AuthService } from './auth.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster as Master } from '~/common/decorator/role.decorator'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { AuthService } from './auth.service'
|
||||
|
||||
export class TokenDto {
|
||||
@IsDate()
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import cluster from 'cluster'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { JwtModule } from '@nestjs/jwt'
|
||||
import { PassportModule } from '@nestjs/passport'
|
||||
import cluster from 'cluster'
|
||||
import { machineIdSync } from 'node-machine-id'
|
||||
import { CLUSTER, SECURITY } from '~/app.config'
|
||||
import { AuthController } from './auth.controller'
|
||||
import { AuthService } from './auth.service'
|
||||
import { JwtStrategy } from './jwt.strategy'
|
||||
import { CLUSTER, SECURITY } from '~/app.config'
|
||||
|
||||
const getMachineId = () => {
|
||||
const id = machineIdSync()
|
||||
|
||||
@@ -5,13 +5,13 @@ import dayjs from 'dayjs'
|
||||
import { isDate, omit } from 'lodash'
|
||||
import { customAlphabet } from 'nanoid/async'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import {
|
||||
TokenModel,
|
||||
UserDocument,
|
||||
UserModel as User,
|
||||
} from '~/modules/user/user.model'
|
||||
import { TokenDto } from './auth.controller'
|
||||
import { JwtPayload } from './interfaces/jwt-payload.interface'
|
||||
import {
|
||||
TokenModel,
|
||||
UserModel as User,
|
||||
UserDocument,
|
||||
} from '~/modules/user/user.model'
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@@ -53,11 +53,10 @@ export class AuthService {
|
||||
|
||||
async generateAccessToken() {
|
||||
const ap = customAlphabet(
|
||||
'1234567890' +
|
||||
Array(26)
|
||||
.fill(null)
|
||||
.map((_, i) => String.fromCharCode(97 + i))
|
||||
.join(''),
|
||||
`1234567890${Array(26)
|
||||
.fill(null)
|
||||
.map((_, i) => String.fromCharCode(97 + i))
|
||||
.join('')}`,
|
||||
40,
|
||||
)
|
||||
return await ap()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Readable } from 'stream'
|
||||
import {
|
||||
BadRequestException,
|
||||
Controller,
|
||||
@@ -14,13 +15,12 @@ import {
|
||||
} from '@nestjs/common'
|
||||
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger'
|
||||
import { FastifyRequest } from 'fastify'
|
||||
import { Readable } from 'stream'
|
||||
import { BackupService } from './backup.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { UploadService } from '~/processors/helper/helper.upload.service'
|
||||
import { getMediumDateTime } from '~/utils'
|
||||
import { BackupService } from './backup.service'
|
||||
|
||||
@Controller({ path: 'backups', scope: Scope.REQUEST })
|
||||
@ApiName
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { exec } from 'child_process'
|
||||
import { existsSync, statSync } from 'fs'
|
||||
import { readFile, readdir, rm, writeFile } from 'fs/promises'
|
||||
import { join, resolve } from 'path'
|
||||
import { Readable } from 'stream'
|
||||
import { promisify } from 'util'
|
||||
import mkdirp from 'mkdirp'
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
} from '@nestjs/common'
|
||||
import { exec } from 'child_process'
|
||||
import { existsSync, statSync } from 'fs'
|
||||
import { readdir, readFile, rm, writeFile } from 'fs/promises'
|
||||
import mkdirp from 'mkdirp'
|
||||
import { join, resolve } from 'path'
|
||||
import { Readable } from 'stream'
|
||||
import { promisify } from 'util'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { MONGO_DB } from '~/app.config'
|
||||
import { BACKUP_DIR, DATA_DIR } from '~/constants/path.constant'
|
||||
import { AdminEventsGateway } from '~/processors/gateway/admin/events.gateway'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
import { getMediumDateTime } from '~/utils'
|
||||
import { getFolderSize } from '~/utils/system.util'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
|
||||
@Injectable()
|
||||
export class BackupService {
|
||||
@@ -94,12 +94,12 @@ export class BackupService {
|
||||
this.logger.log('--> 备份成功')
|
||||
} catch (e) {
|
||||
this.logger.error(
|
||||
'--> 备份失败, 请确保已安装 zip 或 mongo-tools, mongo-tools 的版本需要与 mongod 版本一致, ' +
|
||||
e.message || e.stderr,
|
||||
`--> 备份失败, 请确保已安装 zip 或 mongo-tools, mongo-tools 的版本需要与 mongod 版本一致, ${e.message}` ||
|
||||
e.stderr,
|
||||
)
|
||||
throw e
|
||||
}
|
||||
const path = join(backupDirPath, 'backup-' + dateDir + '.zip')
|
||||
const path = join(backupDirPath, `backup-${dateDir}.zip`)
|
||||
|
||||
return {
|
||||
buffer: await readFile(path),
|
||||
@@ -118,7 +118,7 @@ export class BackupService {
|
||||
}
|
||||
|
||||
checkBackupExist(dirname: string) {
|
||||
const path = join(BACKUP_DIR, dirname, 'backup-' + dirname + '.zip')
|
||||
const path = join(BACKUP_DIR, dirname, `backup-${dirname}.zip`)
|
||||
if (!existsSync(path)) {
|
||||
throw new BadRequestException('文件不存在')
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
forwardRef,
|
||||
Get,
|
||||
HttpCode,
|
||||
Inject,
|
||||
@@ -12,14 +11,10 @@ import {
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
forwardRef,
|
||||
} from '@nestjs/common'
|
||||
import { ApiQuery } from '@nestjs/swagger'
|
||||
import { isValidObjectId } from 'mongoose'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { PostService } from '../post/post.service'
|
||||
import {
|
||||
MultiCategoriesQueryDto,
|
||||
@@ -32,6 +27,11 @@ import {
|
||||
PartialCategoryModel,
|
||||
} from './category.model'
|
||||
import { CategoryService } from './category.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
|
||||
@Controller({ path: 'categories' })
|
||||
@ApiName
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
IsString,
|
||||
} from 'class-validator'
|
||||
import { uniq } from 'lodash'
|
||||
import { IsBooleanOrString } from '~/utils/validator/isBooleanOrString'
|
||||
import { CategoryType } from './category.model'
|
||||
import { IsBooleanOrString } from '~/utils/validator/isBooleanOrString'
|
||||
|
||||
export class SlugOrIdDto {
|
||||
@IsString()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { forwardRef, Module } from '@nestjs/common'
|
||||
import { Module, forwardRef } from '@nestjs/common'
|
||||
import { PostModule } from '../post/post.module'
|
||||
import { CategoryController } from './category.controller'
|
||||
import { CategoryService } from './category.service'
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { forwardRef, Inject, Injectable } from '@nestjs/common'
|
||||
import { Inject, Injectable, forwardRef } from '@nestjs/common'
|
||||
import { DocumentType, ReturnModelType } from '@typegoose/typegoose'
|
||||
import { omit } from 'lodash'
|
||||
import { FilterQuery } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
import { PostModel } from '../post/post.model'
|
||||
import { PostService } from '../post/post.service'
|
||||
import { CategoryModel, CategoryType } from './category.model'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
|
||||
@Injectable()
|
||||
export class CategoryService {
|
||||
|
||||
@@ -14,6 +14,16 @@ import {
|
||||
} from '@nestjs/common'
|
||||
import { ApiOperation, ApiParam } from '@nestjs/swagger'
|
||||
import { DocumentType } from '@typegoose/typegoose'
|
||||
import { UserModel } from '../user/user.model'
|
||||
import {
|
||||
CommentDto,
|
||||
CommentRefTypesDto,
|
||||
StateDto,
|
||||
TextOnlyDto,
|
||||
} from './comment.dto'
|
||||
import { CommentFilterEmailInterceptor } from './comment.interceptor'
|
||||
import { CommentModel, CommentState } from './comment.model'
|
||||
import { CommentService } from './comment.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { CurrentUser } from '~/common/decorator/current-user.decorator'
|
||||
import { IpLocation, IpRecord } from '~/common/decorator/ip.decorator'
|
||||
@@ -26,16 +36,6 @@ import { ReplyMailType } from '~/processors/helper/helper.email.service'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { PagerDto } from '~/shared/dto/pager.dto'
|
||||
import { transformDataToPaginate } from '~/utils/transfrom.util'
|
||||
import { UserModel } from '../user/user.model'
|
||||
import {
|
||||
CommentDto,
|
||||
CommentRefTypesDto,
|
||||
StateDto,
|
||||
TextOnlyDto,
|
||||
} from './comment.dto'
|
||||
import { CommentFilterEmailInterceptor } from './comment.interceptor'
|
||||
import { CommentModel, CommentState } from './comment.model'
|
||||
import { CommentService } from './comment.service'
|
||||
|
||||
@Controller({ path: 'comments' })
|
||||
@UseInterceptors(CommentFilterEmailInterceptor)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { URL } from 'url'
|
||||
import {
|
||||
DocumentType,
|
||||
Ref,
|
||||
modelOptions,
|
||||
pre,
|
||||
prop,
|
||||
Ref,
|
||||
} from '@typegoose/typegoose'
|
||||
import { BeAnObject } from '@typegoose/typegoose/lib/types'
|
||||
import { Query, Types } from 'mongoose'
|
||||
import { URL } from 'url'
|
||||
import { BaseModel } from '~/shared/model/base.model'
|
||||
import { getAvatar } from '~/utils'
|
||||
import { NoteModel } from '../note/note.model'
|
||||
import { PageModel } from '../page/page.model'
|
||||
import { PostModel } from '../post/post.model'
|
||||
import { getAvatar } from '~/utils'
|
||||
import { BaseModel } from '~/shared/model/base.model'
|
||||
|
||||
function autoPopulateSubs(
|
||||
this: Query<
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
import { UserModule } from '../user/user.module'
|
||||
import { CommentController } from './comment.controller'
|
||||
import { CommentService } from './comment.service'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
|
||||
@Module({
|
||||
controllers: [CommentController],
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { URL } from 'url'
|
||||
import { BadRequestException, Injectable, Logger } from '@nestjs/common'
|
||||
import { DocumentType } from '@typegoose/typegoose'
|
||||
import { BeAnObject } from '@typegoose/typegoose/lib/types'
|
||||
import { LeanDocument, Types } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { URL } from 'url'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { UserService } from '../user/user.service'
|
||||
import BlockedKeywords from './block-keywords.json'
|
||||
import { CommentModel, CommentRefTypes } from './comment.model'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
import { DatabaseService } from '~/processors/database/database.service'
|
||||
import {
|
||||
@@ -12,10 +16,6 @@ import {
|
||||
} from '~/processors/helper/helper.email.service'
|
||||
import { WriteBaseModel } from '~/shared/model/base.model'
|
||||
import { hasChinese } from '~/utils'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { UserService } from '../user/user.service'
|
||||
import BlockedKeywords from './block-keywords.json'
|
||||
import { CommentModel, CommentRefTypes } from './comment.model'
|
||||
@Injectable()
|
||||
export class CommentService {
|
||||
private readonly logger: Logger = new Logger(CommentService.name)
|
||||
@@ -234,7 +234,7 @@ export class CommentService {
|
||||
} = await this.configs.waitForConfigReady()
|
||||
switch (type) {
|
||||
case CommentRefTypes.Note: {
|
||||
return new URL('/notes/' + model.nid, base).toString()
|
||||
return new URL(`/notes/${model.nid}`, base).toString()
|
||||
}
|
||||
case CommentRefTypes.Page: {
|
||||
return new URL(`/${model.slug}`, base).toString()
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
ArrayUnique,
|
||||
IsBoolean,
|
||||
IsEmail,
|
||||
IsInt,
|
||||
IsIP,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { modelOptions, prop, Severity } from '@typegoose/typegoose'
|
||||
import { Severity, modelOptions, prop } from '@typegoose/typegoose'
|
||||
import { Schema } from 'mongoose'
|
||||
|
||||
@modelOptions({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import cluster from 'cluster'
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
@@ -9,16 +10,10 @@ import { DocumentType, ReturnModelType } from '@typegoose/typegoose'
|
||||
import { BeAnObject } from '@typegoose/typegoose/lib/types'
|
||||
import camelcaseKeys from 'camelcase-keys'
|
||||
import { ClassConstructor, plainToInstance } from 'class-transformer'
|
||||
import { validateSync, ValidatorOptions } from 'class-validator'
|
||||
import cluster from 'cluster'
|
||||
import { ValidatorOptions, validateSync } from 'class-validator'
|
||||
import { cloneDeep, mergeWith } from 'lodash'
|
||||
import { LeanDocument } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { sleep } from '~/utils'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import * as optionDtos from '../configs/configs.dto'
|
||||
import { UserModel } from '../user/user.model'
|
||||
import { UserService } from '../user/user.service'
|
||||
@@ -29,6 +24,11 @@ import {
|
||||
} from './configs.dto'
|
||||
import { IConfig, IConfigKeys } from './configs.interface'
|
||||
import { OptionModel } from './configs.model'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { sleep } from '~/utils'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
const allOptionKeys: Set<IConfigKeys> = new Set()
|
||||
const map: Record<string, any> = Object.entries(optionDtos).reduce(
|
||||
@@ -50,7 +50,7 @@ const generateDefaultConfig: () => IConfig = () => ({
|
||||
description: '哈喽~欢迎光临',
|
||||
},
|
||||
url: {
|
||||
wsUrl: '', //todo
|
||||
wsUrl: '', // todo
|
||||
adminUrl: '',
|
||||
serverUrl: '',
|
||||
webUrl: '',
|
||||
|
||||
@@ -7,14 +7,14 @@ import {
|
||||
Request,
|
||||
Response,
|
||||
} from '@nestjs/common'
|
||||
import { createMockedContextResponse } from '../serverless/mock-response.util'
|
||||
import { ServerlessService } from '../serverless/serverless.service'
|
||||
import { SnippetModel, SnippetType } from '../snippet/snippet.model'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { AdminEventsGateway } from '~/processors/gateway/admin/events.gateway'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { PagerDto } from '~/shared/dto/pager.dto'
|
||||
import { createMockedContextResponse } from '../serverless/mock-response.util'
|
||||
import { ServerlessService } from '../serverless/serverless.service'
|
||||
import { SnippetModel, SnippetType } from '../snippet/snippet.model'
|
||||
|
||||
@Controller('debug')
|
||||
export class DebugController {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { CacheKey, CacheTTL, Controller, Get, Header } from '@nestjs/common'
|
||||
import { minify } from 'html-minifier'
|
||||
import xss from 'xss'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { CacheKeys } from '~/constants/cache.constant'
|
||||
import { AggregateService } from '../aggregate/aggregate.service'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { MarkdownService } from '../markdown/markdown.service'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { CacheKeys } from '~/constants/cache.constant'
|
||||
|
||||
@Controller('feed')
|
||||
@ApiName
|
||||
@@ -62,7 +62,7 @@ export class FeedController {
|
||||
)}'>${xss(item.link)}</a></blockquote>
|
||||
${this.markdownService.renderMarkdownContent(item.text)}
|
||||
<p style='text-align: right'>
|
||||
<a href='${xss(item.link) + '#comments'}'>看完了?说点什么呢</a>
|
||||
<a href='${`${xss(item.link)}#comments`}'>看完了?说点什么呢</a>
|
||||
</p>`,
|
||||
{
|
||||
collapseWhitespace: true,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { resolve } from 'path'
|
||||
import { Readable } from 'stream'
|
||||
import {
|
||||
BadRequestException,
|
||||
Controller,
|
||||
@@ -14,8 +16,7 @@ import { Reflector } from '@nestjs/core'
|
||||
import { SchedulerRegistry } from '@nestjs/schedule'
|
||||
import type { FastifyReply } from 'fastify'
|
||||
import { isFunction, isString } from 'lodash'
|
||||
import { resolve } from 'path'
|
||||
import { Readable } from 'stream'
|
||||
import { LogQueryDto, LogTypeDto } from './health.dto'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
@@ -25,7 +26,6 @@ import { SCHEDULE_CRON_OPTIONS } from '~/constants/system.constant'
|
||||
import { getTodayLogFilePath } from '~/global/consola.global'
|
||||
import { CronService } from '~/processors/helper/helper.cron.service'
|
||||
import { TaskQueueService } from '~/processors/helper/helper.tq.service'
|
||||
import { LogQueryDto, LogTypeDto } from './health.dto'
|
||||
@Controller({
|
||||
path: 'health',
|
||||
scope: Scope.REQUEST,
|
||||
@@ -174,7 +174,7 @@ export class HealthController {
|
||||
throw new BadRequestException('log dir not exists')
|
||||
}
|
||||
const filename =
|
||||
__filename ?? `mx-server-${type}${index === 0 ? '' : '-' + index}.log`
|
||||
__filename ?? `mx-server-${type}${index === 0 ? '' : `-${index}`}.log`
|
||||
const logPath = path.join(logDir, filename)
|
||||
if (!fs.existsSync(logPath)) {
|
||||
throw new BadRequestException('log file not exists')
|
||||
|
||||
@@ -9,10 +9,10 @@ import {
|
||||
Scope,
|
||||
UnprocessableEntityException,
|
||||
} from '@nestjs/common'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { ConfigKeyDto } from '../option/dtos/config.dto'
|
||||
import { InitService } from './init.service'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
|
||||
@Controller({
|
||||
path: '/init',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { DATA_DIR, TEMP_DIR } from '~/constants/path.constant'
|
||||
import { UserService } from '../user/user.service'
|
||||
import { DATA_DIR, TEMP_DIR } from '~/constants/path.constant'
|
||||
|
||||
@Injectable()
|
||||
export class InitService {
|
||||
|
||||
@@ -8,15 +8,15 @@ import {
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common'
|
||||
import { LinkQueryDto } from './link.dto'
|
||||
import { LinkModel } from './link.model'
|
||||
import { LinkService } from './link.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { Paginator } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { PagerDto } from '~/shared/dto/pager.dto'
|
||||
import { BaseCrudFactory } from '~/utils/crud.util'
|
||||
import { LinkQueryDto } from './link.dto'
|
||||
import { LinkModel } from './link.model'
|
||||
import { LinkService } from './link.service'
|
||||
|
||||
const paths = ['links', 'friends']
|
||||
@Controller(paths)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { URL } from 'url'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { modelOptions, prop } from '@typegoose/typegoose'
|
||||
import { Transform } from 'class-transformer'
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
MaxLength,
|
||||
} from 'class-validator'
|
||||
import { range } from 'lodash'
|
||||
import { URL } from 'url'
|
||||
import { BaseModel } from '~/shared/model/base.model'
|
||||
|
||||
export enum LinkType {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
import { LinkController, LinkControllerCrud } from './link.controller'
|
||||
import { LinkService } from './link.service'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
|
||||
@Module({
|
||||
controllers: [LinkController, LinkControllerCrud],
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { BadRequestException, Injectable, Logger } from '@nestjs/common'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { LinkModel, LinkState, LinkType } from './link.model'
|
||||
import { isDev } from '~/global/env.global'
|
||||
import { AdminEventsGateway } from '~/processors/gateway/admin/events.gateway'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
@@ -8,8 +10,6 @@ import {
|
||||
LinkApplyEmailType,
|
||||
} from '~/processors/helper/helper.email.service'
|
||||
import { HttpService } from '~/processors/helper/helper.http.service'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { LinkModel, LinkState, LinkType } from './link.model'
|
||||
|
||||
@Injectable()
|
||||
export class LinkService {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { join } from 'path'
|
||||
import { performance } from 'perf_hooks'
|
||||
import { Readable } from 'stream'
|
||||
import { URL } from 'url'
|
||||
import {
|
||||
Body,
|
||||
CacheTTL,
|
||||
@@ -15,19 +19,7 @@ import { render } from 'ejs'
|
||||
import { minify } from 'html-minifier'
|
||||
import JSZip from 'jszip'
|
||||
import { isNil } from 'lodash'
|
||||
import { join } from 'path'
|
||||
import { performance } from 'perf_hooks'
|
||||
import { Readable } from 'stream'
|
||||
import { URL } from 'url'
|
||||
import xss from 'xss'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HttpCache } from '~/common/decorator/cache.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { ArticleTypeEnum } from '~/constants/article.constant'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { getShortDateTime } from '~/utils'
|
||||
import { CategoryModel } from '../category/category.model'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { NoteModel } from '../note/note.model'
|
||||
@@ -40,6 +32,14 @@ import {
|
||||
} from './markdown.dto'
|
||||
import { MarkdownYAMLProperty } from './markdown.interface'
|
||||
import { MarkdownService } from './markdown.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HttpCache } from '~/common/decorator/cache.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { ArticleTypeEnum } from '~/constants/article.constant'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { getShortDateTime } from '~/utils'
|
||||
|
||||
@Controller('markdown')
|
||||
@ApiName
|
||||
@@ -109,7 +109,7 @@ export class MarkdownController {
|
||||
convertor(post, {
|
||||
categories: (post.category as CategoryModel).name,
|
||||
type: 'post',
|
||||
permalink: 'posts/' + post.slug,
|
||||
permalink: `posts/${post.slug}`,
|
||||
}),
|
||||
)
|
||||
const convertNote = notes.map((note) =>
|
||||
@@ -117,7 +117,7 @@ export class MarkdownController {
|
||||
mood: note.mood,
|
||||
weather: note.weather,
|
||||
id: note.nid,
|
||||
permalink: 'notes/' + note.nid,
|
||||
permalink: `notes/${note.nid}`,
|
||||
type: 'note',
|
||||
slug: note.nid.toString(),
|
||||
}),
|
||||
|
||||
@@ -7,14 +7,14 @@ import { marked } from 'marked'
|
||||
import { Types } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import xss from 'xss'
|
||||
import { DatabaseService } from '~/processors/database/database.service'
|
||||
import { AssetService } from '~/processors/helper/helper.asset.service'
|
||||
import { CategoryModel } from '../category/category.model'
|
||||
import { NoteModel } from '../note/note.model'
|
||||
import { PageModel } from '../page/page.model'
|
||||
import { PostModel } from '../post/post.model'
|
||||
import { DatatypeDto } from './markdown.dto'
|
||||
import { MarkdownYAMLProperty } from './markdown.interface'
|
||||
import { AssetService } from '~/processors/helper/helper.asset.service'
|
||||
import { DatabaseService } from '~/processors/database/database.service'
|
||||
@Injectable()
|
||||
export class MarkdownService {
|
||||
constructor(
|
||||
@@ -74,7 +74,7 @@ export class MarkdownService {
|
||||
for await (const item of data) {
|
||||
if (!item.meta) {
|
||||
models.push({
|
||||
title: '未命名-' + count++,
|
||||
title: `未命名-${count++}`,
|
||||
slug: new Date().getTime(),
|
||||
text: item.text,
|
||||
...genDate(item),
|
||||
@@ -294,13 +294,11 @@ ${text.trim()}
|
||||
|
||||
code(code, lang) {
|
||||
if (lang == 'mermaid') {
|
||||
return '<pre class="mermaid">' + code + '</pre>'
|
||||
return `<pre class="mermaid">${code}</pre>`
|
||||
} else {
|
||||
return (
|
||||
`<pre><code class="language-${lang}">` +
|
||||
xss(code) +
|
||||
'</code></pre>'
|
||||
)
|
||||
return `<pre><code class="language-${lang}">${xss(
|
||||
code,
|
||||
)}</code></pre>`
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -319,7 +317,7 @@ ${text.trim()}
|
||||
})
|
||||
|
||||
const themeStyleSheet = await this.assetService.getAsset(
|
||||
'/markdown/theme/' + theme + '.css',
|
||||
`/markdown/theme/${theme}.css`,
|
||||
{ encoding: 'utf-8' },
|
||||
)
|
||||
return {
|
||||
|
||||
@@ -13,6 +13,14 @@ import {
|
||||
Query,
|
||||
} from '@nestjs/common'
|
||||
import { ApiOperation } from '@nestjs/swagger'
|
||||
import {
|
||||
ListQueryDto,
|
||||
NidType,
|
||||
NoteQueryDto,
|
||||
PasswordQueryDto,
|
||||
} from './note.dto'
|
||||
import { NoteModel, PartialNoteModel } from './note.model'
|
||||
import { NoteService } from './note.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { Paginator } from '~/common/decorator/http.decorator'
|
||||
import { IpLocation, IpRecord } from '~/common/decorator/ip.decorator'
|
||||
@@ -26,14 +34,6 @@ import {
|
||||
addHidePasswordAndHideCondition,
|
||||
addYearCondition,
|
||||
} from '~/utils/query.util'
|
||||
import {
|
||||
ListQueryDto,
|
||||
NidType,
|
||||
NoteQueryDto,
|
||||
PasswordQueryDto,
|
||||
} from './note.dto'
|
||||
import { NoteModel, PartialNoteModel } from './note.model'
|
||||
import { NoteService } from './note.service'
|
||||
|
||||
@ApiName
|
||||
@Controller({ path: 'notes' })
|
||||
@@ -54,7 +54,7 @@ export class NoteController {
|
||||
isMaster ? '+location +coordinates' : '-location -coordinates',
|
||||
)
|
||||
|
||||
return { data: latest, next: next }
|
||||
return { data: latest, next }
|
||||
}
|
||||
|
||||
@Get('/')
|
||||
@@ -92,7 +92,7 @@ export class NoteController {
|
||||
_id: id,
|
||||
...condition,
|
||||
})
|
||||
.select('+password ' + (isMaster ? '+location +coordinates' : ''))
|
||||
.select(`+password ${isMaster ? '+location +coordinates' : ''}`)
|
||||
.lean()
|
||||
if (!current) {
|
||||
throw new CannotFindException()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
import { NoteController } from './note.controller'
|
||||
import { NoteService } from './note.service'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
|
||||
@Module({
|
||||
controllers: [NoteController],
|
||||
|
||||
@@ -4,13 +4,13 @@ import { DocumentType } from '@typegoose/typegoose'
|
||||
import { isDefined, isMongoId } from 'class-validator'
|
||||
import { FilterQuery } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { NoteModel } from './note.model'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { ImageService } from '~/processors/helper/helper.image.service'
|
||||
import { deleteKeys } from '~/utils'
|
||||
import { NoteModel } from './note.model'
|
||||
|
||||
@Injectable()
|
||||
export class NoteService {
|
||||
|
||||
@@ -7,12 +7,12 @@ import {
|
||||
UnprocessableEntityException,
|
||||
} from '@nestjs/common'
|
||||
import { instanceToPlain } from 'class-transformer'
|
||||
import { ConfigKeyDto } from '../dtos/config.dto'
|
||||
import { OptionController } from '../option.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { IConfig } from '~/modules/configs/configs.interface'
|
||||
import { ConfigsService } from '~/modules/configs/configs.service'
|
||||
import { classToJsonSchema } from '~/utils/jsonschema.util'
|
||||
import { ConfigKeyDto } from '../dtos/config.dto'
|
||||
import { OptionController } from '../option.decorator'
|
||||
|
||||
@OptionController()
|
||||
export class BaseOptionController {
|
||||
@@ -36,7 +36,7 @@ export class BaseOptionController {
|
||||
async getOptionKey(@Param('key') key: keyof IConfig) {
|
||||
if (typeof key !== 'string' && !key) {
|
||||
throw new UnprocessableEntityException(
|
||||
'key must be IConfigKeys, got ' + key,
|
||||
`key must be IConfigKeys, got ${key}`,
|
||||
)
|
||||
}
|
||||
const value = await this.configs.get(key)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Body, Delete, Get, Put, Query } from '@nestjs/common'
|
||||
import { ReplyEmailBodyDto, ReplyEmailTypeDto } from '../dtos/email.dto'
|
||||
import { OptionController } from '../option.decorator'
|
||||
import {
|
||||
EmailService,
|
||||
EmailTemplateRenderProps,
|
||||
ReplyMailType,
|
||||
} from '~/processors/helper/helper.email.service'
|
||||
import { ReplyEmailBodyDto, ReplyEmailTypeDto } from '../dtos/email.dto'
|
||||
import { OptionController } from '../option.decorator'
|
||||
|
||||
@OptionController('Email', 'email')
|
||||
export class EmailOptionController {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { applyDecorators, Controller } from '@nestjs/common'
|
||||
import { Controller, applyDecorators } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
|
||||
@@ -7,8 +7,8 @@ export function OptionController(name?: string, postfixRoute?: string) {
|
||||
return applyDecorators(
|
||||
Auth(),
|
||||
Controller(
|
||||
postfixRoute ? routes.map((route) => route + '/' + postfixRoute) : routes,
|
||||
postfixRoute ? routes.map((route) => `${route}/${postfixRoute}`) : routes,
|
||||
),
|
||||
ApiTags(`${name ? name + ' ' : ''}Option Routes`),
|
||||
ApiTags(`${name ? `${name} ` : ''}Option Routes`),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
import { BaseOptionController } from './controllers/base.option.controller'
|
||||
import { EmailOptionController } from './controllers/email.option.controller'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
|
||||
@Module({
|
||||
imports: [GatewayModule],
|
||||
|
||||
@@ -10,14 +10,14 @@ import {
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common'
|
||||
import { PageQueryDto } from './page.dto'
|
||||
import { PageModel, PartialPageModel } from './page.model'
|
||||
import { PageService } from './page.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { Paginator } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { PageQueryDto } from './page.dto'
|
||||
import { PageModel, PartialPageModel } from './page.model'
|
||||
import { PageService } from './page.service'
|
||||
|
||||
@Controller('pages')
|
||||
@ApiName
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
import { PageController } from './page.controller'
|
||||
import { PageService } from './page.service'
|
||||
import { GatewayModule } from '~/processors/gateway/gateway.module'
|
||||
|
||||
@Module({
|
||||
imports: [GatewayModule],
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Injectable } from '@nestjs/common'
|
||||
import { isDefined } from 'class-validator'
|
||||
import { omit } from 'lodash'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { PageModel } from './page.model'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { ImageService } from '~/processors/helper/helper.image.service'
|
||||
import { PageModel } from './page.model'
|
||||
|
||||
@Injectable()
|
||||
export class PageService {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { createReadStream, existsSync, statSync } from 'fs'
|
||||
import fs from 'fs/promises'
|
||||
import { extname, join } from 'path'
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
@@ -7,11 +10,11 @@ import {
|
||||
Res,
|
||||
} from '@nestjs/common'
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify'
|
||||
import { createReadStream, existsSync, statSync } from 'fs'
|
||||
import fs from 'fs/promises'
|
||||
import { isNull } from 'lodash'
|
||||
import PKG from 'package.json'
|
||||
import { extname, join } from 'path'
|
||||
import { dashboard } from '../../../package.json'
|
||||
import { PageProxyDebugDto } from './pageproxy.dto'
|
||||
import { PageProxyService } from './pageproxy.service'
|
||||
import { Cookies } from '~/common/decorator/cookie.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
@@ -19,9 +22,6 @@ import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { LOCAL_ADMIN_ASSET_PATH } from '~/constants/path.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { dashboard } from '../../../package.json'
|
||||
import { PageProxyDebugDto } from './pageproxy.dto'
|
||||
import { PageProxyService } from './pageproxy.service'
|
||||
|
||||
@Controller('/')
|
||||
@ApiName
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { URL } from 'url'
|
||||
import { Injectable, InternalServerErrorException } from '@nestjs/common'
|
||||
import jsdom from 'jsdom'
|
||||
import { URL } from 'url'
|
||||
import PKG from '~/../package.json'
|
||||
import { API_VERSION } from '~/app.config'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { InitService } from '../init/init.service'
|
||||
import PKG from '~/../package.json'
|
||||
import { API_VERSION } from '~/app.config'
|
||||
@Injectable()
|
||||
export class PageProxyService {
|
||||
constructor(
|
||||
@@ -63,7 +63,7 @@ export class PageProxyService {
|
||||
BASE_API
|
||||
? `window.injectData.BASE_API = '${BASE_API}'`
|
||||
: `window.injectData.BASE_API = location.origin + '${
|
||||
!isDev ? '/api/v' + API_VERSION : ''
|
||||
!isDev ? `/api/v${API_VERSION}` : ''
|
||||
}';`
|
||||
}
|
||||
${
|
||||
|
||||
@@ -14,6 +14,9 @@ import {
|
||||
} from '@nestjs/common'
|
||||
import { ApiOperation } from '@nestjs/swagger'
|
||||
import { Types } from 'mongoose'
|
||||
import { CategoryAndSlugDto, PostQueryDto } from './post.dto'
|
||||
import { PartialPostModel, PostModel } from './post.model'
|
||||
import { PostService } from './post.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { Paginator } from '~/common/decorator/http.decorator'
|
||||
import { IpLocation, IpRecord } from '~/common/decorator/ip.decorator'
|
||||
@@ -24,9 +27,6 @@ import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
import { CountingService } from '~/processors/helper/helper.counting.service'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { addYearCondition } from '~/utils/query.util'
|
||||
import { CategoryAndSlugDto, PostQueryDto } from './post.dto'
|
||||
import { PartialPostModel, PostModel } from './post.model'
|
||||
import { PostService } from './post.service'
|
||||
|
||||
@Controller('posts')
|
||||
@ApiName
|
||||
|
||||
@@ -2,12 +2,12 @@ import { PartialType } from '@nestjs/mapped-types'
|
||||
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger'
|
||||
import {
|
||||
DocumentType,
|
||||
Ref,
|
||||
Severity,
|
||||
index,
|
||||
modelOptions,
|
||||
pre,
|
||||
prop,
|
||||
Ref,
|
||||
Severity,
|
||||
} from '@typegoose/typegoose'
|
||||
import { BeAnObject } from '@typegoose/typegoose/lib/types'
|
||||
import {
|
||||
@@ -19,9 +19,9 @@ import {
|
||||
IsString,
|
||||
} from 'class-validator'
|
||||
import { Query } from 'mongoose'
|
||||
import { CategoryModel as Category } from '../category/category.model'
|
||||
import { Paginator } from '~/shared/interface/paginator.interface'
|
||||
import { CountMixed as Count, WriteBaseModel } from '~/shared/model/base.model'
|
||||
import { CategoryModel as Category } from '../category/category.model'
|
||||
|
||||
function autoPopulateCategory(
|
||||
this: Query<
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { forwardRef, Module } from '@nestjs/common'
|
||||
import { Module, forwardRef } from '@nestjs/common'
|
||||
import { CategoryModule } from '../category/category.module'
|
||||
import { PostController } from './post.controller'
|
||||
import { PostService } from './post.service'
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
forwardRef,
|
||||
Inject,
|
||||
Injectable,
|
||||
forwardRef,
|
||||
} from '@nestjs/common'
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter'
|
||||
import { isDefined } from 'class-validator'
|
||||
import { omit } from 'lodash'
|
||||
import { FilterQuery, PaginateOptions } from 'mongoose'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { CategoryService } from '../category/category.service'
|
||||
import { CommentModel } from '../comment/comment.model'
|
||||
import { PostModel } from './post.model'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { ImageService } from '~/processors/helper/helper.image.service'
|
||||
import { CategoryService } from '../category/category.service'
|
||||
import { CommentModel } from '../comment/comment.model'
|
||||
import { PostModel } from './post.model'
|
||||
|
||||
@Injectable()
|
||||
export class PostService {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BaseCrudFactory } from '~/utils/crud.util'
|
||||
import { ProjectModel } from './project.model'
|
||||
import { BaseCrudFactory } from '~/utils/crud.util'
|
||||
|
||||
export class ProjectController extends BaseCrudFactory({
|
||||
model: ProjectModel,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Controller, Get, Scope } from '@nestjs/common'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { PTYService } from './pty.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
|
||||
@Auth()
|
||||
@Controller({ path: 'pty', scope: Scope.REQUEST })
|
||||
|
||||
@@ -10,12 +10,12 @@ import {
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common'
|
||||
import { RecentlyModel } from './recently.model'
|
||||
import { RecentlyService } from './recently.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { OffsetDto } from '~/shared/dto/pager.dto'
|
||||
import { RecentlyModel } from './recently.model'
|
||||
import { RecentlyService } from './recently.service'
|
||||
|
||||
@Controller(['recently', 'shorthand'])
|
||||
@ApiName
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { RecentlyModel } from './recently.model'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { RecentlyModel } from './recently.model'
|
||||
|
||||
@Injectable()
|
||||
export class RecentlyService {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Body, Delete, Get, Param, Post } from '@nestjs/common'
|
||||
import { sample } from 'lodash'
|
||||
import { SayModel } from './say.model'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { EventTypes } from '~/processors/gateway/events.types'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { BaseCrudFactory } from '~/utils/crud.util'
|
||||
import { SayModel } from './say.model'
|
||||
|
||||
export class SayController extends BaseCrudFactory({ model: SayModel }) {
|
||||
@Get('/random')
|
||||
|
||||
@@ -5,11 +5,11 @@ import {
|
||||
Param,
|
||||
Query,
|
||||
} from '@nestjs/common'
|
||||
import { SearchService } from './search.service'
|
||||
import { HttpCache } from '~/common/decorator/cache.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { SearchDto } from '~/modules/search/search.dto'
|
||||
import { SearchService } from './search.service'
|
||||
|
||||
@Controller('search')
|
||||
@ApiName
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { forwardRef, Module } from '@nestjs/common'
|
||||
import { Module, forwardRef } from '@nestjs/common'
|
||||
import { NoteModule } from '../note/note.module'
|
||||
import { PostModule } from '../post/post.module'
|
||||
import { SearchController } from './search.controller'
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import type { SearchResponse } from '@algolia/client-search'
|
||||
import {
|
||||
BadRequestException,
|
||||
forwardRef,
|
||||
Inject,
|
||||
Injectable,
|
||||
forwardRef,
|
||||
} from '@nestjs/common'
|
||||
import algoliasearch from 'algoliasearch'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { NoteService } from '../note/note.service'
|
||||
import { PostService } from '../post/post.service'
|
||||
import { SearchDto } from '~/modules/search/search.dto'
|
||||
import { DatabaseService } from '~/processors/database/database.service'
|
||||
import { Pagination } from '~/shared/interface/paginator.interface'
|
||||
import { transformDataToPaginate } from '~/utils/transfrom.util'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { NoteService } from '../note/note.service'
|
||||
import { PostService } from '../post/post.service'
|
||||
|
||||
@Injectable()
|
||||
export class SearchService {
|
||||
|
||||
@@ -10,14 +10,14 @@ import {
|
||||
Response,
|
||||
} from '@nestjs/common'
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { SnippetType } from '../snippet/snippet.model'
|
||||
import { createMockedContextResponse } from './mock-response.util'
|
||||
import { ServerlessReferenceDto } from './serverless.dto'
|
||||
import { ServerlessService } from './serverless.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
|
||||
@ApiName
|
||||
@Controller('serverless')
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import fs, { mkdir, stat } from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { nextTick } from 'process'
|
||||
import { transformAsync } from '@babel/core'
|
||||
import {
|
||||
Injectable,
|
||||
@@ -6,11 +9,14 @@ import {
|
||||
} from '@nestjs/common'
|
||||
import { Interval } from '@nestjs/schedule'
|
||||
import { isURL } from 'class-validator'
|
||||
import fs, { mkdir, stat } from 'fs/promises'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import path from 'path'
|
||||
import { nextTick } from 'process'
|
||||
import PKG from '../../../package.json'
|
||||
import { SnippetModel } from '../snippet/snippet.model'
|
||||
import {
|
||||
FunctionContextRequest,
|
||||
FunctionContextResponse,
|
||||
} from './function.types'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { DATA_DIR, NODE_REQUIRE_PATH } from '~/constants/path.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
@@ -21,12 +27,6 @@ import { UniqueArray } from '~/ts-hepler/unique'
|
||||
import { getRedisKey, safePathJoin } from '~/utils'
|
||||
import { safeEval } from '~/utils/safe-eval.util'
|
||||
import { isBuiltinModule } from '~/utils/sys.util'
|
||||
import PKG from '../../../package.json'
|
||||
import { SnippetModel } from '../snippet/snippet.model'
|
||||
import {
|
||||
FunctionContextRequest,
|
||||
FunctionContextResponse,
|
||||
} from './function.types'
|
||||
@Injectable()
|
||||
export class ServerlessService {
|
||||
constructor(
|
||||
@@ -73,7 +73,7 @@ export class ServerlessService {
|
||||
context: { req: FunctionContextRequest; res: FunctionContextResponse },
|
||||
) {
|
||||
const { raw: functionString } = model
|
||||
const logger = new Logger('ServerlessFunction/' + model.name)
|
||||
const logger = new Logger(`ServerlessFunction/${model.name}`)
|
||||
const document = await this.model.findById(model.id)
|
||||
const globalContext = {
|
||||
context: {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { CacheKey, CacheTTL, Controller, Get, Header } from '@nestjs/common'
|
||||
import { minify } from 'html-minifier'
|
||||
import { AggregateService } from '../aggregate/aggregate.service'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { CacheKeys } from '~/constants/cache.constant'
|
||||
import { AggregateService } from '../aggregate/aggregate.service'
|
||||
@Controller('sitemap')
|
||||
@ApiName
|
||||
export class SitemapController {
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common'
|
||||
import { SnippetModel, SnippetType } from './snippet.model'
|
||||
import { SnippetService } from './snippet.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
@@ -16,8 +18,6 @@ import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { MongoIdDto } from '~/shared/dto/id.dto'
|
||||
import { PagerDto } from '~/shared/dto/pager.dto'
|
||||
import { transformDataToPaginate } from '~/utils/transfrom.util'
|
||||
import { SnippetModel, SnippetType } from './snippet.model'
|
||||
import { SnippetService } from './snippet.service'
|
||||
|
||||
@ApiName
|
||||
@Controller('snippets')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 数据配置区块
|
||||
*/
|
||||
import { forwardRef, Module } from '@nestjs/common'
|
||||
import { Module, forwardRef } from '@nestjs/common'
|
||||
import { ServerlessModule } from '../serverless/serverless.module'
|
||||
import { SnippetController } from './snippet.controller'
|
||||
import { SnippetService } from './snippet.service'
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
forwardRef,
|
||||
Inject,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
forwardRef,
|
||||
} from '@nestjs/common'
|
||||
import { load } from 'js-yaml'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { ServerlessService } from '../serverless/serverless.service'
|
||||
import { SnippetModel, SnippetType } from './snippet.model'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { getRedisKey } from '~/utils'
|
||||
import { ServerlessService } from '../serverless/serverless.service'
|
||||
import { SnippetModel, SnippetType } from './snippet.model'
|
||||
|
||||
@Injectable()
|
||||
export class SnippetService {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { CacheTTL, Controller, Get, Param, Query } from '@nestjs/common'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { GaodeMapLocationDto, GaodeMapSearchDto, IpDto } from './tool.dto'
|
||||
import { ToolService } from './tool.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HttpCache } from '~/common/decorator/cache.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { GaodeMapLocationDto, GaodeMapSearchDto, IpDto } from './tool.dto'
|
||||
import { ToolService } from './tool.service'
|
||||
|
||||
@Controller('tools')
|
||||
@ApiName
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { isIPv4, isIPv6 } from 'net'
|
||||
import { URLSearchParams } from 'url'
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
UnprocessableEntityException,
|
||||
} from '@nestjs/common'
|
||||
import { isIPv4, isIPv6 } from 'net'
|
||||
import { URLSearchParams } from 'url'
|
||||
import { HttpService } from '~/processors/helper/helper.http.service'
|
||||
import { ConfigsService } from '../configs/configs.service'
|
||||
import { IP } from './tool.interface'
|
||||
import { HttpService } from '~/processors/helper/helper.http.service'
|
||||
|
||||
@Injectable()
|
||||
export class ToolService {
|
||||
@@ -26,12 +26,12 @@ export class ToolService {
|
||||
|
||||
if (isV4) {
|
||||
const { data } = await this.httpService.axiosRef.get(
|
||||
'https://api.i-meto.com/ip/v1/qqwry/' + ip,
|
||||
`https://api.i-meto.com/ip/v1/qqwry/${ip}`,
|
||||
)
|
||||
return data as IP
|
||||
} else {
|
||||
const { data } = (await this.httpService.axiosRef.get(
|
||||
'http://ip-api.com/json/' + ip,
|
||||
`http://ip-api.com/json/${ip}`,
|
||||
)) as any
|
||||
|
||||
return {
|
||||
@@ -53,9 +53,7 @@ export class ToolService {
|
||||
throw new BadRequestException('高德地图 API Key 未配置')
|
||||
}
|
||||
const data = await fetch(
|
||||
'https://restapi.amap.com/v3/geocode/regeo?key=' +
|
||||
gaodemapKey +
|
||||
'&location=' +
|
||||
`https://restapi.amap.com/v3/geocode/regeo?key=${gaodemapKey}&location=` +
|
||||
`${longitude},${latitude}`,
|
||||
)
|
||||
.then((response) => response.json())
|
||||
@@ -85,7 +83,7 @@ export class ToolService {
|
||||
])
|
||||
|
||||
const data = await fetch(
|
||||
'https://restapi.amap.com/v3/place/text?' + params.toString(),
|
||||
`https://restapi.amap.com/v3/place/text?${params.toString()}`,
|
||||
)
|
||||
.then((response) => response.json())
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { Body, Controller, Get, HttpCode, Patch, Post } from '@nestjs/common'
|
||||
import { ApiOperation } from '@nestjs/swagger'
|
||||
import { AuthService } from '../auth/auth.service'
|
||||
import { LoginDto, UserDto, UserPatchDto } from './user.dto'
|
||||
import { UserDocument, UserModel } from './user.model'
|
||||
import { UserService } from './user.service'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HttpCache } from '~/common/decorator/cache.decorator'
|
||||
import { CurrentUser } from '~/common/decorator/current-user.decorator'
|
||||
@@ -7,10 +11,6 @@ import { IpLocation, IpRecord } from '~/common/decorator/ip.decorator'
|
||||
import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { IsMaster } from '~/common/decorator/role.decorator'
|
||||
import { getAvatar } from '~/utils'
|
||||
import { AuthService } from '../auth/auth.service'
|
||||
import { LoginDto, UserDto, UserPatchDto } from './user.dto'
|
||||
import { UserDocument, UserModel } from './user.model'
|
||||
import { UserService } from './user.service'
|
||||
|
||||
@ApiName
|
||||
@Controller(['master', 'user'])
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
DocumentType,
|
||||
Severity,
|
||||
modelOptions,
|
||||
prop,
|
||||
Severity,
|
||||
} from '@typegoose/typegoose'
|
||||
import { hashSync } from 'bcrypt'
|
||||
import { Schema } from 'mongoose'
|
||||
|
||||
@@ -9,12 +9,12 @@ import { ReturnModelType } from '@typegoose/typegoose'
|
||||
import { compareSync } from 'bcrypt'
|
||||
import { nanoid } from 'nanoid'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { AuthService } from '../auth/auth.service'
|
||||
import { UserDocument, UserModel } from './user.model'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { getAvatar, sleep } from '~/utils'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { AuthService } from '../auth/auth.service'
|
||||
import { UserDocument, UserModel } from './user.model'
|
||||
|
||||
@Injectable()
|
||||
export class UserService {
|
||||
@@ -45,7 +45,7 @@ export class UserService {
|
||||
async getMasterInfo(getLoginIp = false) {
|
||||
const user = await this.userModel
|
||||
.findOne()
|
||||
.select('-authCode' + (getLoginIp ? ' +lastLoginIp' : ''))
|
||||
.select(`-authCode${getLoginIp ? ' +lastLoginIp' : ''}`)
|
||||
.lean({ virtuals: true })
|
||||
if (!user) {
|
||||
throw new BadRequestException('没有完成初始化!')
|
||||
@@ -137,7 +137,7 @@ export class UserService {
|
||||
)
|
||||
})
|
||||
|
||||
this.Logger.warn('主人已登录, IP: ' + ip)
|
||||
this.Logger.warn(`主人已登录, IP: ${ip}`)
|
||||
return PrevFootstep
|
||||
}
|
||||
|
||||
|
||||
2
src/processors/cache/cache.module.ts
vendored
2
src/processors/cache/cache.module.ts
vendored
@@ -5,7 +5,7 @@
|
||||
* @author Surmon <https://github.com/surmon-china>
|
||||
*/
|
||||
|
||||
import { CacheModule as NestCacheModule, Global, Module } from '@nestjs/common'
|
||||
import { Global, Module, CacheModule as NestCacheModule } from '@nestjs/common'
|
||||
import { CacheConfigService } from './cache.config.service'
|
||||
import { CacheService } from './cache.service'
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import { TypegooseModule } from 'nestjs-typegoose'
|
||||
import { CategoryModel } from '../../modules/category/category.model'
|
||||
import { PostModel } from '../../modules/post/post.model'
|
||||
import { UserModel } from '../../modules/user/user.model'
|
||||
import { DatabaseService } from './database.service'
|
||||
import { MONGO_DB } from '~/app.config'
|
||||
import { AnalyzeModel } from '~/modules/analyze/analyze.model'
|
||||
import { CommentModel } from '~/modules/comment/comment.model'
|
||||
@@ -11,10 +15,6 @@ import { ProjectModel } from '~/modules/project/project.model'
|
||||
import { RecentlyModel } from '~/modules/recently/recently.model'
|
||||
import { SayModel } from '~/modules/say/say.model'
|
||||
import { SnippetModel } from '~/modules/snippet/snippet.model'
|
||||
import { CategoryModel } from '../../modules/category/category.model'
|
||||
import { PostModel } from '../../modules/post/post.model'
|
||||
import { UserModel } from '../../modules/user/user.model'
|
||||
import { DatabaseService } from './database.service'
|
||||
|
||||
const models = TypegooseModule.forFeature([
|
||||
AnalyzeModel,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { mongoose, ReturnModelType } from '@typegoose/typegoose'
|
||||
import { getConnectionToken, InjectModel } from 'nestjs-typegoose'
|
||||
import { ReturnModelType, mongoose } from '@typegoose/typegoose'
|
||||
import { InjectModel, getConnectionToken } from 'nestjs-typegoose'
|
||||
import { NoteModel } from '~/modules/note/note.model'
|
||||
import { PageModel } from '~/modules/page/page.model'
|
||||
import { PostModel } from '~/modules/post/post.model'
|
||||
|
||||
@@ -6,10 +6,10 @@ import {
|
||||
WebSocketServer,
|
||||
} from '@nestjs/websockets'
|
||||
import { Namespace, Socket } from 'socket.io'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { AuthService } from '~/modules/auth/auth.service'
|
||||
import { BaseGateway } from '../base.gateway'
|
||||
import { EventTypes } from '../events.types'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { AuthService } from '~/modules/auth/auth.service'
|
||||
|
||||
export abstract class AuthGateway
|
||||
extends BaseGateway
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import {
|
||||
GatewayMetadata,
|
||||
@@ -7,14 +8,13 @@ import {
|
||||
WebSocketGateway,
|
||||
} from '@nestjs/websockets'
|
||||
import { Emitter } from '@socket.io/redis-emitter'
|
||||
import { resolve } from 'path'
|
||||
import SocketIO, { Socket } from 'socket.io'
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
import { getTodayLogFilePath } from '~/global/consola.global'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { AuthService } from '../../../modules/auth/auth.service'
|
||||
import { EventTypes } from '../events.types'
|
||||
import { AuthGateway } from './auth.gateway'
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
import { getTodayLogFilePath } from '~/global/consola.global'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
|
||||
@WebSocketGateway<GatewayMetadata>({ namespace: 'admin' })
|
||||
export class AdminEventsGateway
|
||||
|
||||
@@ -10,13 +10,13 @@ import { isNil } from 'lodash'
|
||||
import { nanoid } from 'nanoid'
|
||||
import { IPty, spawn } from 'node-pty'
|
||||
import { Socket } from 'socket.io'
|
||||
import { EventTypes } from '../events.types'
|
||||
import { AuthGateway } from './auth.gateway'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { AuthService } from '~/modules/auth/auth.service'
|
||||
import { ConfigsService } from '~/modules/configs/configs.service'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { getIp, getRedisKey } from '~/utils'
|
||||
import { EventTypes } from '../events.types'
|
||||
import { AuthGateway } from './auth.gateway'
|
||||
|
||||
@WebSocketGateway<GatewayMetadata>({ namespace: 'pty' })
|
||||
export class PTYGateway
|
||||
@@ -100,7 +100,7 @@ export class PTYGateway
|
||||
getRedisKey(RedisKeys.PTYSession),
|
||||
nid,
|
||||
|
||||
new Date().toISOString() + ',' + ip,
|
||||
`${new Date().toISOString()},${ip}`,
|
||||
)
|
||||
pty.onExit(async () => {
|
||||
const hvalue = await this.cacheService
|
||||
@@ -112,7 +112,7 @@ export class PTYGateway
|
||||
.hset(
|
||||
getRedisKey(RedisKeys.PTYSession),
|
||||
nid,
|
||||
hvalue + ',' + new Date().toISOString(),
|
||||
`${hvalue},${new Date().toISOString()}`,
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
IsHexColor,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsHexColor,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from 'class-validator'
|
||||
export class DanmakuDto {
|
||||
|
||||
@@ -12,13 +12,13 @@ import { Emitter } from '@socket.io/redis-emitter'
|
||||
import { plainToClass } from 'class-transformer'
|
||||
import { validate } from 'class-validator'
|
||||
import SocketIO from 'socket.io'
|
||||
import { BaseGateway } from '../base.gateway'
|
||||
import { EventTypes } from '../events.types'
|
||||
import { DanmakuDto } from './dtos/danmaku.dto'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/cache/cache.service'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { getShortDate } from '~/utils/time.util'
|
||||
import { BaseGateway } from '../base.gateway'
|
||||
import { EventTypes } from '../events.types'
|
||||
import { DanmakuDto } from './dtos/danmaku.dto'
|
||||
|
||||
@WebSocketGateway<GatewayMetadata>({
|
||||
namespace: 'web',
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
* @author Innei
|
||||
* @description 用于获取静态资源的服务
|
||||
*/
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { existsSync } from 'fs'
|
||||
import fs from 'fs/promises'
|
||||
import path, { join } from 'path'
|
||||
import { USER_ASSET_DIR } from '~/constants/path.constant'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { HttpService } from './helper.http.service'
|
||||
import { USER_ASSET_DIR } from '~/constants/path.constant'
|
||||
|
||||
// 先从 ASSET_DIR 找用户自定义的资源, 没有就从默认的 ASSET_DIR 找, 没有就从网上拉取, 存到默认的 ASSET_DIR
|
||||
@Injectable()
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { CacheService } from '../cache/cache.service'
|
||||
import { DatabaseService } from '../database/database.service'
|
||||
import { ArticleType } from '~/constants/article.constant'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { NoteModel } from '~/modules/note/note.model'
|
||||
import { PostModel } from '~/modules/post/post.model'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { CacheService } from '../cache/cache.service'
|
||||
import { DatabaseService } from '../database/database.service'
|
||||
|
||||
@Injectable()
|
||||
export class CountingService {
|
||||
@@ -58,14 +58,14 @@ export class CountingService {
|
||||
ip,
|
||||
)
|
||||
if (isReadBefore) {
|
||||
this.logger.debug('已经增加过计数了, ' + id)
|
||||
this.logger.debug(`已经增加过计数了, ${id}`)
|
||||
return
|
||||
}
|
||||
await Promise.all([
|
||||
redis.sadd(getRedisKey(RedisKeys.Read, doc._id), ip),
|
||||
doc.updateOne({ $inc: { 'count.read': 1 } }),
|
||||
])
|
||||
this.logger.debug('增加阅读计数, (' + doc.title)
|
||||
this.logger.debug(`增加阅读计数, (${doc.title}`)
|
||||
}
|
||||
|
||||
public async updateLikeCount(
|
||||
@@ -91,14 +91,14 @@ export class CountingService {
|
||||
ip,
|
||||
)
|
||||
if (isLikeBefore) {
|
||||
this.logger.debug('已经增加过计数了, ' + id)
|
||||
this.logger.debug(`已经增加过计数了, ${id}`)
|
||||
return false
|
||||
}
|
||||
await Promise.all([
|
||||
redis.sadd(getRedisKey(RedisKeys.Like, doc._id), ip),
|
||||
doc.updateOne({ $inc: { 'count.like': 1 } }),
|
||||
])
|
||||
this.logger.debug('增加喜欢计数, (' + doc.title)
|
||||
this.logger.debug(`增加喜欢计数, (${doc.title}`)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { OnEvent } from '@nestjs/event-emitter'
|
||||
import { Cron, CronExpression } from '@nestjs/schedule'
|
||||
import cluster from 'cluster'
|
||||
import COS from 'cos-nodejs-sdk-v5'
|
||||
import dayjs from 'dayjs'
|
||||
import { existsSync } from 'fs'
|
||||
import { readdir, rm } from 'fs/promises'
|
||||
import { join } from 'path'
|
||||
import { Inject, Injectable, Logger, forwardRef } from '@nestjs/common'
|
||||
import { OnEvent } from '@nestjs/event-emitter'
|
||||
import { Cron, CronExpression } from '@nestjs/schedule'
|
||||
import COS from 'cos-nodejs-sdk-v5'
|
||||
import dayjs from 'dayjs'
|
||||
import mkdirp from 'mkdirp'
|
||||
import { InjectModel } from 'nestjs-typegoose'
|
||||
import { join } from 'path'
|
||||
import { CacheService } from '../cache/cache.service'
|
||||
import { HttpService } from './helper.http.service'
|
||||
import { isMainCluster } from '~/app.config'
|
||||
import { CronDescription } from '~/common/decorator/cron-description.decorator'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
@@ -23,8 +25,6 @@ import { PageService } from '~/modules/page/page.service'
|
||||
import { PostService } from '~/modules/post/post.service'
|
||||
import { SearchService } from '~/modules/search/search.service'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { CacheService } from '../cache/cache.service'
|
||||
import { HttpService } from './helper.http.service'
|
||||
|
||||
@Injectable()
|
||||
export class CronService {
|
||||
@@ -185,7 +185,7 @@ export class CronService {
|
||||
mkdirp.sync(TEMP_DIR)
|
||||
this.logger.log('--> 清理临时文件成功')
|
||||
}
|
||||
//“At 00:05.”
|
||||
// “At 00:05.”
|
||||
@Cron('5 0 * * *', { name: 'cleanTempDirectory' })
|
||||
@CronDescription('清理日志文件')
|
||||
async cleanLogFile() {
|
||||
@@ -241,7 +241,7 @@ export class CronService {
|
||||
this.logger.log(`百度站长提交结果: ${JSON.stringify(res.data)}`)
|
||||
return res.data
|
||||
} catch (e) {
|
||||
this.logger.error('百度推送错误: ' + e.message)
|
||||
this.logger.error(`百度推送错误: ${e.message}`)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import cluster from 'cluster'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { OnEvent } from '@nestjs/event-emitter'
|
||||
import cluster from 'cluster'
|
||||
import { render } from 'ejs'
|
||||
import { createTransport } from 'nodemailer'
|
||||
import { CacheService } from '../cache/cache.service'
|
||||
import { AssetService } from './helper.asset.service'
|
||||
import { EventBusEvents } from '~/constants/event.constant'
|
||||
import { ConfigsService } from '~/modules/configs/configs.service'
|
||||
import { LinkModel } from '~/modules/link/link.model'
|
||||
import { CacheService } from '../cache/cache.service'
|
||||
import { AssetService } from './helper.asset.service'
|
||||
|
||||
export enum ReplyMailType {
|
||||
Owner = 'owner',
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user