diff --git a/.github/workflows/generator.yml b/.github/workflows/generator.yml index 89d43cb0a..af98b2470 100644 --- a/.github/workflows/generator.yml +++ b/.github/workflows/generator.yml @@ -19,6 +19,8 @@ jobs: with: node-version: 18 cache: 'npm' + - run: npm install + working-directory: ${{github.workspace}}/generators/node-server/resources - run: npm ci - run: npm run test - name: Run npm sonar:scanner diff --git a/generators/node-server/resources/package.json b/generators/node-server/resources/package.json index a1b34ac10..3370d5224 100644 --- a/generators/node-server/resources/package.json +++ b/generators/node-server/resources/package.json @@ -1,14 +1,14 @@ { "dependencies": { "browser-sync-client": "3.0.2", - "@nestjs/common": "7.5.1", - "@nestjs/core": "7.5.1", - "@nestjs/jwt": "7.2.0", - "@nestjs/passport": "7.1.0", - "@nestjs/platform-express": "7.5.1", - "@nestjs/serve-static": "2.1.4", - "@nestjs/swagger": "4.8.0", - "@nestjs/typeorm": "7.1.4", + "@nestjs/common": "8.4.7", + "@nestjs/core": "8.4.7", + "@nestjs/jwt": "8.0.1", + "@nestjs/passport": "8.0.1", + "@nestjs/platform-express": "8.4.7", + "@nestjs/serve-static": "2.2.2", + "@nestjs/swagger": "5.2.1", + "@nestjs/typeorm": "8.1.4", "bcrypt": "5.1.1", "class-transformer": "0.5.1", "class-validator": "0.13.1", @@ -18,25 +18,25 @@ "express-session": "1.17.3", "js-yaml": "4.1.0", "jwt-decode": "3.1.1", - "mongodb": "6.2.0", + "mongodb": "5.9.1", "mysql2": "2.2.5", - "pg": "8.4.2", - "oracledb": "5.0.0", - "mssql": "6.2.3", + "pg": "8.5.1", + "oracledb": "5.1.0", + "mssql": "9.1.1", "passport": "0.4.1", "passport-jwt": "4.0.0", "passport-oauth2": "1.7.0", "reflect-metadata": "0.1.14", - "rxjs": "6.6.3", + "rxjs": "7.8.1", "mongodb-memory-server": "6.9.2", "sqlite3": "5.1.6", "swagger-ui-express": "5.0.0", - "typeorm": "0.2.45", - "typeorm-encrypted": "0.5.6" + "typeorm": "0.3.17", + "typeorm-encrypted": "0.8.0" }, "devDependencies": { "@jest/globals": "29.7.0", - "@nestjs/testing": "7.5.1", + "@nestjs/testing": "8.4.7", "@types/bcrypt": "5.0.2", "@types/express": "4.17.1", "@types/express-serve-static-core": "4.17.3", diff --git a/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs b/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs index 99fea5b37..389d72a3c 100644 --- a/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs +++ b/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs @@ -7,10 +7,8 @@ export class CreateTables1570200270081 implements MigrationInterface { if (queryRunner.isTransactionActive) { await queryRunner.commitTransaction(); } - - - await queryRunner.connection.synchronize(); } + await queryRunner.connection.synchronize(); } // eslint-disable-next-line diff --git a/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs b/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs index a30839a6f..38d7d731e 100644 --- a/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs +++ b/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs @@ -1,5 +1,5 @@ <%_ const UserEntity = user.persistClass %> -import { MigrationInterface, QueryRunner, getRepository } from 'typeorm'; +import { MigrationInterface, QueryRunner } from 'typeorm'; <%_ if (authenticationType !== 'oauth2') { _%> import { <%= UserEntity %> } from '../domain/user.entity'; import { transformPassword } from '../security'; @@ -68,7 +68,7 @@ export class SeedUsersRoles1570200490072 implements MigrationInterface { // eslint-disable-next-line public async up(queryRunner: QueryRunner): Promise { - const authorityRepository = getRepository("<%- jhiTablePrefix %>_authority"); + const authorityRepository = queryRunner.connection.getRepository("<%- jhiTablePrefix %>_authority"); <%_ if (authenticationType === 'oauth2') { _%> @@ -79,7 +79,7 @@ export class SeedUsersRoles1570200490072 implements MigrationInterface { const adminRole = await authorityRepository.save(this.role1); const userRole = await authorityRepository.save(this.role2); - const userRepository = getRepository("<%- jhiTablePrefix %>_user"); + const userRepository = queryRunner.connection.getRepository("<%- jhiTablePrefix %>_user"); this.user1.authorities= [adminRole, userRole]; this.user3.authorities= [adminRole, userRole]; diff --git a/generators/node-server/templates/server/src/orm.config.ts.ejs b/generators/node-server/templates/server/src/orm.config.ts.ejs index 1a17b9508..7ce7c1654 100644 --- a/generators/node-server/templates/server/src/orm.config.ts.ejs +++ b/generators/node-server/templates/server/src/orm.config.ts.ejs @@ -40,7 +40,6 @@ _%> synchronize: true, entities: commonConf.ENTITIES, migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, migrationsRun: commonConf.MIGRATIONS_RUN, }; @@ -58,7 +57,6 @@ _%> synchronize: commonConf.SYNCRONIZE, entities: commonConf.ENTITIES, migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, migrationsRun: commonConf.MIGRATIONS_RUN, }; } @@ -82,7 +80,6 @@ _%> synchronize: true, entities: commonConf.ENTITIES, migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, migrationsRun: commonConf.MIGRATIONS_RUN, }; } @@ -101,7 +98,6 @@ _%> synchronize: commonConf.SYNCRONIZE, entities: commonConf.ENTITIES, migrations: commonConf.MIGRATIONS, - cli: commonConf.CLI, migrationsRun: commonConf.MIGRATIONS_RUN, }; } diff --git a/generators/node-server/templates/server/src/service/user.service.ts.ejs b/generators/node-server/templates/server/src/service/user.service.ts.ejs index 70bf7208d..8bbf81b09 100644 --- a/generators/node-server/templates/server/src/service/user.service.ts.ejs +++ b/generators/node-server/templates/server/src/service/user.service.ts.ejs @@ -12,7 +12,7 @@ export class UserService { constructor(@InjectRepository(UserRepository) private userRepository: UserRepository) {} async findById(id: <%= user.primaryKey.tsType %>): Promise<<%= user.dtoClass%> | undefined> { - const result = await this.userRepository.findOne(id); + const result = await this.userRepository.findOneBy({ id }); return UserMapper.fromEntityToDTO(this.flatAuthorities(result)) }