feat/upgrade nest v9 (#620)
This commit is contained in:
35
package.json
35
package.json
@@ -31,6 +31,7 @@
|
||||
"build": "nest build",
|
||||
"build:webpack": "nest build --webpack --webpackPath ./configs/webpack.config.js -c ./configs/nest-cli.webpack.json",
|
||||
"dev": "npm run start",
|
||||
"repl": "npm run start -- --entryFile repl",
|
||||
"bundle": "rimraf out && npm run build && cd dist/src && npx ncc build main.js -o ../../out -m && cd ../.. && chmod +x out/index.js",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "cross-env NODE_ENV=development nest start -w --path tsconfig.json",
|
||||
@@ -69,18 +70,19 @@
|
||||
"@babel/plugin-transform-modules-commonjs": "7.18.6",
|
||||
"@babel/plugin-transform-typescript": "7.18.8",
|
||||
"@babel/types": "*",
|
||||
"@fastify/cookie": "6",
|
||||
"@fastify/multipart": "6",
|
||||
"@nestjs/common": "8.4.7",
|
||||
"@nestjs/core": "8.4.7",
|
||||
"@nestjs/event-emitter": "1.1.1",
|
||||
"@fastify/cookie": "7.0.0",
|
||||
"@fastify/multipart": "7.1.0",
|
||||
"@fastify/static": "6.4.0",
|
||||
"@nestjs/common": "9.0.2",
|
||||
"@nestjs/core": "9.0.2",
|
||||
"@nestjs/event-emitter": "1.2.0",
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/platform-fastify": "8.4.7",
|
||||
"@nestjs/platform-socket.io": "8.4.7",
|
||||
"@nestjs/schedule": "2.0.1",
|
||||
"@nestjs/swagger": "5.2.1",
|
||||
"@nestjs/throttler": "2.0.1",
|
||||
"@nestjs/websockets": "8.4.7",
|
||||
"@nestjs/platform-fastify": "9.0.2",
|
||||
"@nestjs/platform-socket.io": "9.0.2",
|
||||
"@nestjs/schedule": "2.1.0",
|
||||
"@nestjs/swagger": "6.0.1",
|
||||
"@nestjs/throttler": "3.0.0",
|
||||
"@nestjs/websockets": "9.0.2",
|
||||
"@socket.io/redis-adapter": "7.2.0",
|
||||
"@socket.io/redis-emitter": "4.1.1",
|
||||
"@typegoose/auto-increment": "1.4.1",
|
||||
@@ -90,7 +92,7 @@
|
||||
"axios": "*",
|
||||
"axios-retry": "3.3.1",
|
||||
"bcrypt": "5.0.1",
|
||||
"cache-manager": "4.0.1",
|
||||
"cache-manager": "4.1.0",
|
||||
"cache-manager-ioredis": "2.1.0",
|
||||
"camelcase-keys": "7.0.2",
|
||||
"class-transformer": "0.5.1",
|
||||
@@ -100,7 +102,6 @@
|
||||
"cos-nodejs-sdk-v5": "2.11.12",
|
||||
"dayjs": "1.11.3",
|
||||
"ejs": "3.1.8",
|
||||
"fastify-swagger": "npm:@fastify/swagger@6",
|
||||
"fs-extra": "*",
|
||||
"get-image-colors": "4.0.1",
|
||||
"image-size": "1.0.1",
|
||||
@@ -141,9 +142,9 @@
|
||||
"devDependencies": {
|
||||
"@innei/eslint-config-ts": "latest",
|
||||
"@innei/prettier": "latest",
|
||||
"@nestjs/cli": "8.2.8",
|
||||
"@nestjs/schematics": "8.0.11",
|
||||
"@nestjs/testing": "8.4.7",
|
||||
"@nestjs/cli": "9.0.0",
|
||||
"@nestjs/schematics": "9.0.1",
|
||||
"@nestjs/testing": "9.0.2",
|
||||
"@types/babel__core": "7.1.19",
|
||||
"@types/bcrypt": "5.0.0",
|
||||
"@types/cache-manager": "4.0.1",
|
||||
@@ -189,8 +190,6 @@
|
||||
"typescript": "4.7.4",
|
||||
"ioredis": "5.1.0",
|
||||
"webpack": "5.73.0",
|
||||
"fastify-cors": "npm:@fastify/cors@^7.0.0",
|
||||
"fastify-formbody": "npm:@fastify/formbody@^6.0.0",
|
||||
"semver": "^7"
|
||||
}
|
||||
}
|
||||
967
pnpm-lock.yaml
generated
967
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import { MiddlewareConsumer, Module, NestModule, Type } from '@nestjs/common'
|
||||
import { Module, NestModule, Type } from '@nestjs/common'
|
||||
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core'
|
||||
|
||||
import { isInDemoMode } from './app.config'
|
||||
@@ -140,6 +140,4 @@ import { RedisModule } from './processors/redis/redis.module'
|
||||
},
|
||||
],
|
||||
})
|
||||
export class AppModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer) {}
|
||||
}
|
||||
export class AppModule {}
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
* @author Surmon <https://github.com/surmon-china>
|
||||
* @author Innei <https://innei.ren>
|
||||
*/
|
||||
import { Observable } from 'rxjs'
|
||||
import { of } from 'rxjs'
|
||||
import { tap } from 'rxjs/operators'
|
||||
import { Observable, of, tap } from 'rxjs'
|
||||
|
||||
import {
|
||||
CallHandler,
|
||||
|
||||
@@ -62,7 +62,7 @@ export class DebugController {
|
||||
)
|
||||
|
||||
if (!res.sent) {
|
||||
res.send(result)
|
||||
return res.send(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export class FileController {
|
||||
)
|
||||
}
|
||||
|
||||
reply.send(stream)
|
||||
return reply.send(stream)
|
||||
} catch {
|
||||
throw new CannotFindException()
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ export class HealthController {
|
||||
}
|
||||
}
|
||||
reply.type('text/plain')
|
||||
reply.send(stream)
|
||||
return reply.send(stream)
|
||||
}
|
||||
|
||||
@Delete('/log/:type')
|
||||
|
||||
@@ -174,14 +174,14 @@ export class PageProxyController {
|
||||
...(await this.service.getUrlFromConfig()),
|
||||
from: 'server',
|
||||
})
|
||||
reply
|
||||
return reply
|
||||
.type('text/html')
|
||||
.send(this.service.rewriteAdminEntryAssetPath(injectEnv))
|
||||
} catch (e) {
|
||||
reply.code(500).send({
|
||||
isDev && console.error(e)
|
||||
return reply.code(500).send({
|
||||
message: e.message,
|
||||
})
|
||||
isDev && console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ export class PageProxyController {
|
||||
|
||||
const isPathExist = existsSync(path)
|
||||
if (!isPathExist) {
|
||||
return reply.code(404).send()
|
||||
return reply.code(404).send().callNotFound()
|
||||
}
|
||||
|
||||
const isFile = statSync(path).isFile()
|
||||
@@ -221,9 +221,9 @@ export class PageProxyController {
|
||||
new Date(Date.now() + 31536000 * 1000).toUTCString(),
|
||||
)
|
||||
if (minetype) {
|
||||
reply.type(minetype).send(stream)
|
||||
return reply.type(minetype).send(stream)
|
||||
} else {
|
||||
reply.send(stream)
|
||||
return reply.send(stream)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ export interface FunctionContextResponse {
|
||||
throws(code: number, message: any): void
|
||||
type(type: string): FunctionContextResponse
|
||||
status(code: number, statusMessage?: string): FunctionContextResponse
|
||||
send(data: any): void
|
||||
send(data: any): any
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export const createMockedContextResponse = (
|
||||
return response
|
||||
},
|
||||
send(data: any) {
|
||||
reply.send(data)
|
||||
return reply.send(data)
|
||||
},
|
||||
status(code: number, message?: string) {
|
||||
reply.raw.statusCode = code
|
||||
|
||||
@@ -89,7 +89,7 @@ export class ServerlessController {
|
||||
)
|
||||
|
||||
if (!reply.sent) {
|
||||
reply.send(result)
|
||||
return reply.send(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,13 @@ export class RedisConfigService implements CacheOptionsFactory {
|
||||
if (REDIS.password) {
|
||||
redisOptions.password = REDIS.password as any
|
||||
}
|
||||
|
||||
return {
|
||||
store: redisStore,
|
||||
ttl: REDIS.ttl ?? undefined,
|
||||
// https://github.com/dabroek/node-cache-manager-redis-store/blob/master/CHANGELOG.md#breaking-changes
|
||||
// Any value (undefined | null) return true (cacheable) after redisStore v2.0.0
|
||||
is_cacheable_value: () => true,
|
||||
isCacheableValue: () => true,
|
||||
max: REDIS.max,
|
||||
...redisOptions,
|
||||
}
|
||||
|
||||
10
src/repl.ts
Normal file
10
src/repl.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { repl } from '@nestjs/core'
|
||||
|
||||
import { register } from './global/index.global'
|
||||
|
||||
async function bootstrap() {
|
||||
register()
|
||||
const { AppModule } = await import('./app.module')
|
||||
await repl(AppModule)
|
||||
}
|
||||
bootstrap()
|
||||
@@ -14,7 +14,7 @@ describe('test UserModule service', () => {
|
||||
beforeEach(async () => {
|
||||
const storedUserList = []
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [CacheService],
|
||||
imports: [],
|
||||
providers: [
|
||||
UserService,
|
||||
AuthService,
|
||||
|
||||
Reference in New Issue
Block a user