5dfb66917c
## Overview This PR upgrades all NestJS dependencies from version 10.x to 11.x, following the [official migration guide](https://docs.nestjs.com/migration-guide). This builds on top of the v9 to v10 upgrade completed in PR #15835. ## Changes ### Dependencies Updated **Core packages (10.x → 11.x):** - `@nestjs/common`: 10.4.16 → 11.0.8 - `@nestjs/core`: 10.4.16 → 11.0.8 - `@nestjs/platform-express`: 10.4.16 → 11.0.8 - `@nestjs/config`: 3.2.3 → 3.3.0 - `@nestjs/passport`: 10.0.3 → 11.0.0 - `@nestjs/axios`: 3.0.2 → 3.1.2 - `@nestjs/schedule`: ^3.0.0 → ^4.1.1 - `@nestjs/serve-static`: 4.0.2 → 5.0.1 - `@nestjs/cache-manager`: ^2.2.1 → ^2.3.0 - `@nestjs/jwt`: 10.2.0 → 11.0.0 - `@nestjs/typeorm`: 10.0.2 → 11.0.0 - `@nestjs/terminus`: 11.0.0 (already on v11) - `@nestjs/event-emitter`: 2.1.0 (compatible) **DevDependencies:** - `@nestjs/testing`: ^10.4.16 → ^11.0.8 - `@nestjs/schematics`: ^10.1.0 → ^11.0.2 - `@nestjs/cli`: 10.3.0 → 11.0.0 ### Code Changes **Fixed: TwentyConfigModule conditional imports** - Updated `TwentyConfigModule.forRoot()` to use spread operator for conditional imports - Fixes TypeScript error with NestJS 11's stricter DynamicModule type checking **Cleanup: Removed unused package** - Removed `@revertdotdev/revert-react` (not being used anywhere in the codebase) ## Breaking Changes Addressed ### 1. ✅ Reflector Type Inference - **Impact**: None - codebase only uses `reflector.get()` method - **Analysis**: Does not use `getAllAndMerge()` or `getAllAndOverride()` (the methods with breaking changes) - **Files reviewed**: feature-flag.guard.ts, message-queue-metadata.accessor.ts, workspace-query-hook-metadata.accessor.ts ### 2. ✅ Lifecycle Hooks Execution Order - **Change**: Termination hooks (`OnModuleDestroy`, `BeforeApplicationShutdown`, `OnApplicationShutdown`) now execute in REVERSE order - **Analysis**: Reviewed all lifecycle hook implementations - Redis client cleanup - Database connection cleanup (GlobalWorkspaceDataSource) - BullMQ queue/worker cleanup - Cache storage cleanup - **Result**: Dependency order is safe - services using connections clean up before the connections themselves ### 3. ✅ Middleware Registration Order - **Change**: Global middleware now executes first regardless of import order - **Analysis**: Middleware is not registered as global, so execution order remains consistent - **Files reviewed**: app.module.ts, middleware.module.ts ## Testing All tests passing and build successful: **Unit Tests (283+ tests):** - ✅ Health module: 38 tests passed - ✅ Auth module: 115 tests passed (passport v11 integration) - ✅ REST API: 90 tests passed (middleware and express platform) - ✅ Feature flags: 17 tests passed (Reflector usage) - ✅ Workspace: 23 tests passed **Build & Quality:** - ✅ Type checking: Passed - ✅ Linting: Passed - ✅ Build: 3,683 files compiled successfully ## Verification Tested critical NestJS functionality: - ✅ Authentication & Security (JWT, OAuth, guards) - ✅ HTTP Platform (Express integration, REST endpoints) - ✅ Dependency Injection (Services, factories, providers) - ✅ Cache Management (Redis with @nestjs/cache-manager) - ✅ GraphQL (Query runners, resolvers) - ✅ Configuration (Environment config) - ✅ Scheduling (Cron jobs with @nestjs/schedule v4) - ✅ Lifecycle Hooks (Module initialization and cleanup) - ✅ Reflector (Metadata reflection in guards) ## Related PRs - #15835 - Upgrade NestJS from 9.x to 10.x (completed) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Upgrades NestJS to v11 and updates routing patterns, auth strategies, GraphQL schema options, and build/dist paths (scripts, Docker, Nx, migrations, assets), plus enables Devtools in development. > > - **Backend (NestJS 11 upgrade)**: > - Bump `@nestjs/*` packages (core, platform-express, jwt, passport, typeorm, serve-static, schedule, cli/testing/schematics) to v11. > - Update REST/route-trigger/file controllers to new wildcard syntax (`*path`). > - Refactor OAuth (Google/Microsoft) and SAML strategies (abstract base + explicit `validate`); minor typings. > - Enable `DevtoolsModule` in development. > - **GraphQL**: > - Add `buildSchemaOptions.orphanedTypes` for client-config types; keep Yoga/Sentry setup. > - **Build/Runtime & Config**: > - Standardize dist layout (remove `src` in paths): update scripts, Docker `CMD`, Nx `project.json`, render scripts, TypeORM migration paths, asset resolution. > - Adjust `nest-cli.json` (watchOptions, asset globs, migrations outDir, monorepo/root). > - Improve config module imports (spread conditional); tsconfig excludes `node_modules`. > - Minor Nx default: `start` target caching disabled. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 1139fd85a97d0c72314d416d07464cc3c9942783. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
259 lines
7.6 KiB
JSON
259 lines
7.6 KiB
JSON
{
|
|
"name": "twenty-server",
|
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
"projectType": "application",
|
|
"tags": ["scope:backend"],
|
|
"targets": {
|
|
"build": {
|
|
"executor": "nx:run-commands",
|
|
"cache": true,
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"parallel": false,
|
|
"commands": ["rimraf dist", "nest build --path ./tsconfig.build.json"]
|
|
},
|
|
"dependsOn": ["^build"]
|
|
},
|
|
"test:integration": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"commands": [
|
|
"NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" nx jest --config ./jest-integration.config.ts"
|
|
]
|
|
},
|
|
"parallel": false,
|
|
"configurations": {
|
|
"with-db-reset": {
|
|
"cwd": "packages/twenty-server",
|
|
"commands": [
|
|
"NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" nx database:reset > reset-logs.log && NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" nx jest --config ./jest-integration.config.ts"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"build:packageJson": {
|
|
"executor": "@nx/js:tsc",
|
|
"options": {
|
|
"main": "packages/twenty-server/dist/main.js",
|
|
"tsConfig": "packages/twenty-server/tsconfig.json",
|
|
"outputPath": "packages/twenty-server/dist",
|
|
"updateBuildableProjectDepsInPackageJson": true
|
|
}
|
|
},
|
|
"typecheck": {},
|
|
"start": {
|
|
"executor": "nx:run-commands",
|
|
"cache": false,
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "NODE_ENV=development nest start --watch"
|
|
}
|
|
},
|
|
"start:ci": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "NODE_ENV=development nest start"
|
|
}
|
|
},
|
|
"start:ci-if-needed": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "curl -f -s http://localhost:3000/healthz > /dev/null 2>&1 && echo '✅ Server already running' || (echo '🚀 Server not running, starting...' && nohup nest start > server.log 2>&1 &)"
|
|
}
|
|
},
|
|
"start:debug": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "nx start --debug"
|
|
}
|
|
},
|
|
"reset:env": {
|
|
"executor": "nx:run-commands",
|
|
"inputs": ["{projectRoot}/.env.example"],
|
|
"outputs": ["{projectRoot}/.env"],
|
|
"cache": true,
|
|
"options": {
|
|
"cwd": "{projectRoot}",
|
|
"command": "cp .env.example .env"
|
|
}
|
|
},
|
|
"command": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "node dist/command/command.js"
|
|
}
|
|
},
|
|
"command-no-deps": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "node dist/command/command.js"
|
|
}
|
|
},
|
|
"worker": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "node dist/queue-worker/queue-worker.js"
|
|
}
|
|
},
|
|
"typeorm": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "ts-node --transpile-only -P tsconfig.json ../../node_modules/typeorm/cli.js"
|
|
}
|
|
},
|
|
"ts-node": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "ts-node"
|
|
}
|
|
},
|
|
"ts-node-no-deps": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "ts-node"
|
|
}
|
|
},
|
|
"ts-node-no-deps-transpile-only": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "ts-node --transpile-only"
|
|
}
|
|
},
|
|
"lint": {
|
|
"options": {
|
|
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"],
|
|
"maxWarnings": 0
|
|
},
|
|
"configurations": {
|
|
"ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] },
|
|
"fix": {}
|
|
}
|
|
},
|
|
"test": {},
|
|
"test:debug": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register ../../node_modules/.bin/jest --runInBand"
|
|
}
|
|
},
|
|
"jest": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "jest"
|
|
}
|
|
},
|
|
"database:migrate": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"commands": [
|
|
"nx typeorm -- migration:run -d src/database/typeorm/core/core.datasource"
|
|
]
|
|
}
|
|
},
|
|
"database:migrate:generate": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "npx nx typeorm -- migration:generate src/database/typeorm/core/migrations/common/{args.migrationName} -d src/database/typeorm/core/core.datasource.ts"
|
|
}
|
|
},
|
|
"database:migrate:revert": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"commands": [
|
|
"nx typeorm -- migration:revert -d src/database/typeorm/core/core.datasource"
|
|
]
|
|
}
|
|
},
|
|
"generate:integration-test": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"commands": [
|
|
"nx ts-node-no-deps -- ./test/integration/graphql/codegen/index.ts"
|
|
],
|
|
"parallel": false
|
|
}
|
|
},
|
|
"database:reset": {
|
|
"executor": "nx:run-commands",
|
|
"dependsOn": ["build"],
|
|
"configurations": {
|
|
"no-seed": {
|
|
"cwd": "packages/twenty-server",
|
|
"commands": [
|
|
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
|
|
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
|
|
"nx database:migrate",
|
|
"nx command-no-deps -- cache:flush"
|
|
],
|
|
"parallel": false
|
|
},
|
|
"seed": {
|
|
"cwd": "packages/twenty-server",
|
|
"commands": [
|
|
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
|
|
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
|
|
"nx database:migrate",
|
|
"nx command-no-deps -- cache:flush",
|
|
"nx command-no-deps -- workspace:seed:dev"
|
|
],
|
|
"parallel": false
|
|
}
|
|
},
|
|
"defaultConfiguration": "seed"
|
|
},
|
|
"clickhouse:migrate": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "nx ts-node-no-deps -- src/database/clickHouse/migrations/run-migrations.ts"
|
|
}
|
|
},
|
|
"clickhouse:seed": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "packages/twenty-server",
|
|
"command": "nx ts-node-no-deps -- src/database/clickHouse/seeds/run-seeds.ts"
|
|
}
|
|
},
|
|
"lingui:extract": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "{projectRoot}",
|
|
"command": "lingui extract --overwrite --clean"
|
|
}
|
|
},
|
|
"lingui:compile": {
|
|
"executor": "nx:run-commands",
|
|
"options": {
|
|
"cwd": "{projectRoot}",
|
|
"command": "lingui compile --typescript"
|
|
}
|
|
}
|
|
}
|
|
}
|