upgrade to NestJS 11 (#766)

* upgrade to nest 11

* update dependencies
This commit is contained in:
Philip Okugbe
2025-02-20 21:17:03 +00:00
committed by GitHub
parent 3e5cb92621
commit 64ecef09bc
5 changed files with 2985 additions and 2570 deletions

View File

@ -28,47 +28,46 @@
"test:e2e": "jest --config test/jest-e2e.json" "test:e2e": "jest --config test/jest-e2e.json"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.701.0", "@aws-sdk/client-s3": "^3.750.0",
"@aws-sdk/s3-request-presigner": "^3.701.0", "@aws-sdk/s3-request-presigner": "^3.750.0",
"@casl/ability": "^6.7.2", "@casl/ability": "^6.7.3",
"@fastify/cookie": "^9.4.0", "@fastify/cookie": "^11.0.2",
"@fastify/multipart": "^8.3.0", "@fastify/multipart": "^9.0.3",
"@fastify/static": "^7.0.4", "@fastify/static": "^8.1.1",
"@nestjs/bullmq": "^10.2.2", "@nestjs/bullmq": "^11.0.2",
"@nestjs/common": "^10.4.9", "@nestjs/common": "^11.0.10",
"@nestjs/config": "^3.3.0", "@nestjs/config": "^4.0.0",
"@nestjs/core": "^10.4.9", "@nestjs/core": "^11.0.10",
"@nestjs/event-emitter": "^2.1.1", "@nestjs/event-emitter": "^3.0.0",
"@nestjs/jwt": "^10.2.0", "@nestjs/jwt": "^11.0.0",
"@nestjs/mapped-types": "^2.0.6", "@nestjs/mapped-types": "^2.1.0",
"@nestjs/passport": "^10.0.3", "@nestjs/passport": "^11.0.5",
"@nestjs/platform-fastify": "^10.4.9", "@nestjs/platform-fastify": "^11.0.10",
"@nestjs/platform-socket.io": "^10.4.9", "@nestjs/platform-socket.io": "^11.0.10",
"@nestjs/terminus": "^10.2.3", "@nestjs/terminus": "^11.0.0",
"@nestjs/websockets": "^10.4.9", "@nestjs/websockets": "^11.0.10",
"@react-email/components": "0.0.28", "@react-email/components": "0.0.28",
"@react-email/render": "^1.0.2", "@react-email/render": "^1.0.2",
"@socket.io/redis-adapter": "^8.3.0", "@socket.io/redis-adapter": "^8.3.0",
"bcrypt": "^5.1.1", "bcrypt": "^5.1.1",
"bullmq": "^5.29.1", "bullmq": "^5.41.3",
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.14.1", "class-validator": "^0.14.1",
"cookie": "^1.0.2", "cookie": "^1.0.2",
"fix-esm": "^1.0.1", "fix-esm": "^1.0.1",
"fs-extra": "^11.2.0", "fs-extra": "^11.3.0",
"happy-dom": "^15.11.6", "happy-dom": "^15.11.6",
"kysely": "^0.27.4", "kysely": "^0.27.5",
"kysely-migration-cli": "^0.4.2", "kysely-migration-cli": "^0.4.2",
"mime-types": "^2.1.35", "mime-types": "^2.1.35",
"nanoid": "^5.0.9", "nanoid": "^5.1.0",
"nestjs-kysely": "^1.0.0", "nestjs-kysely": "^1.1.0",
"nodemailer": "^6.9.16", "nodemailer": "^6.10.0",
"passport-jwt": "^4.0.1", "passport-jwt": "^4.0.1",
"pg": "^8.13.1", "pg": "^8.13.3",
"pg-tsquery": "^8.4.2", "pg-tsquery": "^8.4.2",
"postmark": "^4.0.5", "postmark": "^4.0.5",
"react": "^18.3.1", "react": "^18.3.1",
"redis": "^4.7.0",
"reflect-metadata": "^0.2.2", "reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"sanitize-filename-ts": "^1.0.2", "sanitize-filename-ts": "^1.0.2",
@ -76,36 +75,36 @@
"ws": "^8.18.0" "ws": "^8.18.0"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.16.0", "@eslint/js": "^9.20.0",
"@nestjs/cli": "^10.4.8", "@nestjs/cli": "^11.0.4",
"@nestjs/schematics": "^10.2.3", "@nestjs/schematics": "^11.0.1",
"@nestjs/testing": "^10.4.9", "@nestjs/testing": "^11.0.10",
"@types/bcrypt": "^5.0.2", "@types/bcrypt": "^5.0.2",
"@types/debounce": "^1.2.4", "@types/debounce": "^1.2.4",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.14", "@types/jest": "^29.5.14",
"@types/mime-types": "^2.1.4", "@types/mime-types": "^2.1.4",
"@types/node": "^22.10.0", "@types/node": "^22.13.4",
"@types/nodemailer": "^6.4.17", "@types/nodemailer": "^6.4.17",
"@types/passport-jwt": "^4.0.1", "@types/passport-jwt": "^4.0.1",
"@types/pg": "^8.11.10", "@types/pg": "^8.11.11",
"@types/supertest": "^6.0.2", "@types/supertest": "^6.0.2",
"@types/ws": "^8.5.13", "@types/ws": "^8.5.14",
"eslint": "^9.15.0", "eslint": "^9.20.1",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^10.0.1",
"globals": "^15.13.0", "globals": "^15.15.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"kysely-codegen": "^0.17.0", "kysely-codegen": "^0.17.0",
"prettier": "^3.4.1", "prettier": "^3.5.1",
"react-email": "^3.0.2", "react-email": "^3.0.2",
"source-map-support": "^0.5.21", "source-map-support": "^0.5.21",
"supertest": "^7.0.0", "supertest": "^7.0.0",
"ts-jest": "^29.2.5", "ts-jest": "^29.2.5",
"ts-loader": "^9.5.1", "ts-loader": "^9.5.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0", "tsconfig-paths": "^4.2.0",
"typescript": "^5.7.2", "typescript": "^5.7.3",
"typescript-eslint": "^8.17.0" "typescript-eslint": "^8.24.1"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [

View File

@ -1,31 +1,30 @@
import { InjectKysely } from 'nestjs-kysely'; import { InjectKysely } from 'nestjs-kysely';
import { import {
HealthCheckError,
HealthIndicator,
HealthIndicatorResult, HealthIndicatorResult,
HealthIndicatorService,
} from '@nestjs/terminus'; } from '@nestjs/terminus';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { sql } from 'kysely'; import { sql } from 'kysely';
import { KyselyDB } from '@docmost/db/types/kysely.types'; import { KyselyDB } from '@docmost/db/types/kysely.types';
@Injectable() @Injectable()
export class PostgresHealthIndicator extends HealthIndicator { export class PostgresHealthIndicator {
private readonly logger = new Logger(PostgresHealthIndicator.name); private readonly logger = new Logger(PostgresHealthIndicator.name);
constructor(@InjectKysely() private readonly db: KyselyDB) { constructor(
super(); private readonly healthIndicatorService: HealthIndicatorService,
} @InjectKysely() private readonly db: KyselyDB,
) {}
async pingCheck(key: string): Promise<HealthIndicatorResult> { async pingCheck(key: string): Promise<HealthIndicatorResult> {
const indicator = this.healthIndicatorService.check(key);
try { try {
await sql`SELECT 1=1`.execute(this.db); await sql`SELECT 1=1`.execute(this.db);
return this.getStatus(key, true); return indicator.up();
} catch (e) { } catch (e) {
this.logger.error(JSON.stringify(e)); this.logger.error(JSON.stringify(e));
throw new HealthCheckError( return indicator.down(`${key} is not available`);
`${key} is not available`,
this.getStatus(key, false),
);
} }
} }
} }

View File

@ -1,21 +1,23 @@
import { import {
HealthCheckError,
HealthIndicator,
HealthIndicatorResult, HealthIndicatorResult,
HealthIndicatorService,
} from '@nestjs/terminus'; } from '@nestjs/terminus';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { EnvironmentService } from '../environment/environment.service'; import { EnvironmentService } from '../environment/environment.service';
import { Redis } from 'ioredis'; import { Redis } from 'ioredis';
@Injectable() @Injectable()
export class RedisHealthIndicator extends HealthIndicator { export class RedisHealthIndicator {
private readonly logger = new Logger(RedisHealthIndicator.name); private readonly logger = new Logger(RedisHealthIndicator.name);
constructor(private environmentService: EnvironmentService) { constructor(
super(); private readonly healthIndicatorService: HealthIndicatorService,
} private environmentService: EnvironmentService,
) {}
async pingCheck(key: string): Promise<HealthIndicatorResult> { async pingCheck(key: string): Promise<HealthIndicatorResult> {
const indicator = this.healthIndicatorService.check(key);
try { try {
const redis = new Redis(this.environmentService.getRedisUrl(), { const redis = new Redis(this.environmentService.getRedisUrl(), {
maxRetriesPerRequest: 15, maxRetriesPerRequest: 15,
@ -23,13 +25,10 @@ export class RedisHealthIndicator extends HealthIndicator {
await redis.ping(); await redis.ping();
redis.disconnect(); redis.disconnect();
return this.getStatus(key, true); return indicator.up();
} catch (e) { } catch (e) {
this.logger.error(e); this.logger.error(e);
throw new HealthCheckError( return indicator.down(`${key} is not available`);
`${key} is not available`,
this.getStatus(key, false),
);
} }
} }
} }

View File

@ -61,23 +61,23 @@
"bytes": "^3.1.2", "bytes": "^3.1.2",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"dompurify": "^3.2.1", "dompurify": "^3.2.4",
"fractional-indexing-jittered": "^1.0.0", "fractional-indexing-jittered": "^1.0.0",
"ioredis": "^5.4.1", "ioredis": "^5.4.1",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"linkifyjs": "^4.2.0", "linkifyjs": "^4.2.0",
"marked": "^13.0.3", "marked": "^13.0.3",
"uuid": "^11.0.3", "uuid": "^11.1.0",
"y-indexeddb": "^9.0.12", "y-indexeddb": "^9.0.12",
"yjs": "^13.6.20" "yjs": "^13.6.20"
}, },
"devDependencies": { "devDependencies": {
"@nx/js": "20.1.3", "@nx/js": "20.4.5",
"@types/bytes": "^3.1.4", "@types/bytes": "^3.1.5",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"concurrently": "^9.1.0", "concurrently": "^9.1.2",
"nx": "20.1.3", "nx": "20.4.5",
"tsx": "^4.19.2" "tsx": "^4.19.3"
}, },
"workspaces": { "workspaces": {
"packages": [ "packages": [

5420
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff