From a462f736a9cd4cbb7ce9db7bd2685f0c8d238b5c Mon Sep 17 00:00:00 2001 From: Meysam Hadeli <35596795+meysamhadeli@users.noreply.github.com> Date: Thu, 26 Dec 2024 19:55:25 +0330 Subject: [PATCH] chore: update .gitignore --- src/booking/eslint.config.js | 12 ------------ src/booking/eslint.config.mjs | 11 +++++++++++ src/booking/package.json | 9 ++++++--- src/booking/src/booking/entities/booking.entity.ts | 2 +- src/booking/src/main.ts | 3 +-- src/building-blocks/eslint.config.js | 12 ------------ src/building-blocks/eslint.config.mjs | 12 ++++++++++++ src/building-blocks/package.json | 10 +++++++--- .../test/container/postgres/postgres-container.d.ts | 2 +- .../test/container/postgres/postgres-container.ts | 2 +- .../test/container/rabbitmq/rabbitmq-container.ts | 9 ++------- src/flight/eslint.config.js | 12 ------------ src/flight/eslint.config.mjs | 11 +++++++++++ src/flight/package.json | 9 ++++++--- src/flight/src/aircraft/entities/aircraft.entity.ts | 2 +- src/flight/src/airport/entities/airport.entity.ts | 2 +- src/flight/src/flight/entities/flight.entity.ts | 2 +- src/flight/src/main.ts | 3 +-- src/flight/src/seat/entities/seat.entity.ts | 2 +- src/identity/eslint.config.js | 12 ------------ src/identity/eslint.config.mjs | 11 +++++++++++ src/identity/package.json | 9 ++++++--- src/identity/src/app.module.ts | 2 +- src/identity/src/auth/auth.module.ts | 1 - src/identity/src/auth/features/v1/login/login.ts | 2 +- src/identity/src/auth/features/v1/logout/logout.ts | 2 -- .../auth/features/v1/refresh-token/refresh-token.ts | 4 ++-- src/identity/src/main.ts | 3 +-- .../v1/delete-user-by-id/delete-user-by-id.ts | 5 +---- .../features/v1/get-user-by-id/get-user-by-id.ts | 1 - .../src/user/features/v1/get-users/get-users.ts | 2 +- src/identity/src/user/user.module.ts | 2 -- .../user/features/create-user.test.ts | 4 ++-- .../test/shared/fixtures/integration-test.fixture.ts | 2 +- .../test/unit-test/user/features/create-user.test.ts | 3 --- src/passenger/eslint.config.js | 12 ------------ src/passenger/eslint.config.mjs | 11 +++++++++++ src/passenger/package.json | 9 ++++++--- src/passenger/src/main.ts | 3 +-- 39 files changed, 109 insertions(+), 118 deletions(-) delete mode 100644 src/booking/eslint.config.js create mode 100644 src/booking/eslint.config.mjs delete mode 100644 src/building-blocks/eslint.config.js create mode 100644 src/building-blocks/eslint.config.mjs delete mode 100644 src/flight/eslint.config.js create mode 100644 src/flight/eslint.config.mjs delete mode 100644 src/identity/eslint.config.js create mode 100644 src/identity/eslint.config.mjs delete mode 100644 src/passenger/eslint.config.js create mode 100644 src/passenger/eslint.config.mjs diff --git a/src/booking/eslint.config.js b/src/booking/eslint.config.js deleted file mode 100644 index 53c4d9d..0000000 --- a/src/booking/eslint.config.js +++ /dev/null @@ -1,12 +0,0 @@ -// https://denar90.github.io/eslint.github.io/docs/rules/ -export default [ - { - rules: { - semi: 'error', - 'prefer-const': 'warn', - 'no-unused-vars': 'warn', - 'no-debugger': 'warn', - 'no-console': 'warn' - } - } -]; diff --git a/src/booking/eslint.config.mjs b/src/booking/eslint.config.mjs new file mode 100644 index 0000000..ee41fb3 --- /dev/null +++ b/src/booking/eslint.config.mjs @@ -0,0 +1,11 @@ +import globals from "globals"; +import tseslint from "typescript-eslint"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {files: ["**/*.{js,mjs,cjs,ts}"]}, + {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, + {languageOptions: { globals: globals.browser }}, + ...tseslint.configs.recommended, +]; \ No newline at end of file diff --git a/src/booking/package.json b/src/booking/package.json index e081540..7de11aa 100644 --- a/src/booking/package.json +++ b/src/booking/package.json @@ -9,7 +9,7 @@ "build": "nest build", "dev": "nest start --watch", "format": "prettier --write \"**/*.{ts,js}\"", - "lint": "eslint . --fix", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "typeorm": "npm run build && npx typeorm -d ./dist/data/data-source.js", "migration:generate": "npm run typeorm -- migration:generate", "migration:run": "npm run typeorm -- migration:run", @@ -43,16 +43,19 @@ "ts-mapper": "^1.2.4" }, "devDependencies": { + "@eslint/js": "^9.17.0", "@faker-js/faker": "^9.3.0", "@types/express": "^5.0.0", "@types/jest": "29.5.14", "@types/supertest": "6.0.2", + "eslint": "^9.17.0", + "globals": "^15.14.0", "jest": "29.7.0", "jest-serial-runner": "^1.2.1", + "prettier": "3.4.2", "supertest": "7.0.0", "ts-jest": "29.2.5", "typemoq": "^2.1.0", - "prettier": "3.4.2", - "eslint": "9.17.0" + "typescript-eslint": "^8.18.2" } } diff --git a/src/booking/src/booking/entities/booking.entity.ts b/src/booking/src/booking/entities/booking.entity.ts index add2a8c..92cabff 100644 --- a/src/booking/src/booking/entities/booking.entity.ts +++ b/src/booking/src/booking/entities/booking.entity.ts @@ -1,4 +1,4 @@ -import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; +import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; @Entity() export class Booking { diff --git a/src/booking/src/main.ts b/src/booking/src/main.ts index 288a484..cfd40d1 100644 --- a/src/booking/src/main.ts +++ b/src/booking/src/main.ts @@ -5,7 +5,6 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { PrometheusMetrics } from 'building-blocks/monitoring/prometheus.metrics'; import { ErrorHandlersFilter } from 'building-blocks/filters/error-handlers.filter'; import configs from 'building-blocks/configs/configs'; -import { Request, Response } from 'express'; async function bootstrap() { const app = await NestFactory.create(AppModule); @@ -31,7 +30,7 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe({ transform: true })); - app.use((req: Request, res: Response, next: any) => { + app.use((req, res, next) => { if (req.originalUrl == '/' || req.originalUrl.includes('favicon.ico')) { return res.send(configs.serviceName); } diff --git a/src/building-blocks/eslint.config.js b/src/building-blocks/eslint.config.js deleted file mode 100644 index 53c4d9d..0000000 --- a/src/building-blocks/eslint.config.js +++ /dev/null @@ -1,12 +0,0 @@ -// https://denar90.github.io/eslint.github.io/docs/rules/ -export default [ - { - rules: { - semi: 'error', - 'prefer-const': 'warn', - 'no-unused-vars': 'warn', - 'no-debugger': 'warn', - 'no-console': 'warn' - } - } -]; diff --git a/src/building-blocks/eslint.config.mjs b/src/building-blocks/eslint.config.mjs new file mode 100644 index 0000000..00cb03a --- /dev/null +++ b/src/building-blocks/eslint.config.mjs @@ -0,0 +1,12 @@ +import globals from "globals"; +import tseslint from "typescript-eslint"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {files: ["**/*.{js,mjs,cjs,ts}"]}, + {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, + {languageOptions: { globals: globals.browser }}, + ...tseslint.configs.recommended, + +]; diff --git a/src/building-blocks/package.json b/src/building-blocks/package.json index 23f135b..f298eb8 100644 --- a/src/building-blocks/package.json +++ b/src/building-blocks/package.json @@ -6,13 +6,12 @@ "scripts": { "build": "tsc", "format": "prettier --write \"**/*.{ts,js}\"", - "lint": "eslint . --fix" + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix" }, "author": "Meysam", "license": "ISC", "keywords": [], "dependencies": { - "@eslint/js": "^9.17.0", "@nestjs/cli": "10.4.9", "@nestjs/cqrs": "^10.2.8", "@nestjs/passport": "^10.0.3", @@ -47,7 +46,6 @@ "bcryptjs": "^2.4.3", "date-fns": "^4.1.0", "dotenv": "^16.4.7", - "eslint": "9.17.0", "express": "4.21.2", "http-problem-details": "^0.1.5", "joi": "^17.13.3", @@ -61,5 +59,11 @@ "ts-node": "10.9.2", "typeorm": "^0.3.20", "typescript": "5.7.2" + }, + "devDependencies": { + "@eslint/js": "^9.17.0", + "eslint": "^9.17.0", + "globals": "^15.14.0", + "typescript-eslint": "^8.18.2" } } diff --git a/src/building-blocks/test/container/postgres/postgres-container.d.ts b/src/building-blocks/test/container/postgres/postgres-container.d.ts index d002413..06e24d1 100644 --- a/src/building-blocks/test/container/postgres/postgres-container.d.ts +++ b/src/building-blocks/test/container/postgres/postgres-container.d.ts @@ -10,7 +10,7 @@ export interface PostgresContainerOptions { username: string; password: string; synchronize: boolean; - entities: MixedList; + entities: MixedList; migrationsRun: boolean; } export declare class PostgresContainer { diff --git a/src/building-blocks/test/container/postgres/postgres-container.ts b/src/building-blocks/test/container/postgres/postgres-container.ts index 0b90839..42fa917 100644 --- a/src/building-blocks/test/container/postgres/postgres-container.ts +++ b/src/building-blocks/test/container/postgres/postgres-container.ts @@ -12,7 +12,7 @@ export interface PostgresContainerOptions { username: string; password: string; synchronize: boolean; - entities: MixedList; + entities: MixedList; migrationsRun: boolean; } diff --git a/src/building-blocks/test/container/rabbitmq/rabbitmq-container.ts b/src/building-blocks/test/container/rabbitmq/rabbitmq-container.ts index a8f5da3..eed0bc8 100644 --- a/src/building-blocks/test/container/rabbitmq/rabbitmq-container.ts +++ b/src/building-blocks/test/container/rabbitmq/rabbitmq-container.ts @@ -2,7 +2,6 @@ import 'reflect-metadata'; import { GenericContainer, StartedTestContainer } from 'testcontainers'; import { Logger } from '@nestjs/common'; import configs from '../../../configs/configs'; -import { RabbitmqOptions } from '../../../rabbitmq/rabbitmq-connection'; export interface RabbitmqContainerOptions { host: string; @@ -13,7 +12,7 @@ export interface RabbitmqContainerOptions { } export class RabbitmqContainer { - public async start(): Promise<[StartedTestContainer, RabbitmqOptions]> { + public async start(): Promise { const defaultRabbitmqOptions = await this.getDefaultRabbitmqTestContainers(); const rabbitmqContainerStarted = await this.getContainerStarted(defaultRabbitmqOptions); @@ -28,13 +27,9 @@ export class RabbitmqContainer { host: defaultRabbitmqOptions.host }; - const rabbitmqOptions: RabbitmqOptions = { - ...configs.rabbitmq - }; - Logger.log(`Test rabbitmq with port ${containerPort} established`); - return [rabbitmqContainerStarted, rabbitmqOptions]; + return rabbitmqContainerStarted; } private async getContainerStarted( diff --git a/src/flight/eslint.config.js b/src/flight/eslint.config.js deleted file mode 100644 index 53c4d9d..0000000 --- a/src/flight/eslint.config.js +++ /dev/null @@ -1,12 +0,0 @@ -// https://denar90.github.io/eslint.github.io/docs/rules/ -export default [ - { - rules: { - semi: 'error', - 'prefer-const': 'warn', - 'no-unused-vars': 'warn', - 'no-debugger': 'warn', - 'no-console': 'warn' - } - } -]; diff --git a/src/flight/eslint.config.mjs b/src/flight/eslint.config.mjs new file mode 100644 index 0000000..ee41fb3 --- /dev/null +++ b/src/flight/eslint.config.mjs @@ -0,0 +1,11 @@ +import globals from "globals"; +import tseslint from "typescript-eslint"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {files: ["**/*.{js,mjs,cjs,ts}"]}, + {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, + {languageOptions: { globals: globals.browser }}, + ...tseslint.configs.recommended, +]; \ No newline at end of file diff --git a/src/flight/package.json b/src/flight/package.json index 5887e61..4dab6ac 100644 --- a/src/flight/package.json +++ b/src/flight/package.json @@ -9,7 +9,7 @@ "build": "nest build", "dev": "nest start --watch", "format": "prettier --write \"**/*.{ts,js}\"", - "lint": "eslint . --fix", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "typeorm": "npm run build && npx typeorm -d ./dist/data/data-source.js", "migration:generate": "npm run typeorm -- migration:generate", "migration:run": "npm run typeorm -- migration:run", @@ -42,16 +42,19 @@ "ts-mapper": "^1.2.4" }, "devDependencies": { + "@eslint/js": "^9.17.0", "@faker-js/faker": "^9.3.0", "@types/express": "^5.0.0", "@types/jest": "29.5.14", "@types/supertest": "6.0.2", + "eslint": "^9.17.0", + "globals": "^15.14.0", "jest": "29.7.0", "jest-serial-runner": "^1.2.1", + "prettier": "3.4.2", "supertest": "7.0.0", "ts-jest": "29.2.5", "typemoq": "^2.1.0", - "prettier": "3.4.2", - "eslint": "9.17.0" + "typescript-eslint": "^8.18.2" } } diff --git a/src/flight/src/aircraft/entities/aircraft.entity.ts b/src/flight/src/aircraft/entities/aircraft.entity.ts index dc19b54..2a958cc 100644 --- a/src/flight/src/aircraft/entities/aircraft.entity.ts +++ b/src/flight/src/aircraft/entities/aircraft.entity.ts @@ -1,4 +1,4 @@ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne } from 'typeorm'; +import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'; import { Flight } from '../../flight/entities/flight.entity'; @Entity() diff --git a/src/flight/src/airport/entities/airport.entity.ts b/src/flight/src/airport/entities/airport.entity.ts index 6c97612..e3b027c 100644 --- a/src/flight/src/airport/entities/airport.entity.ts +++ b/src/flight/src/airport/entities/airport.entity.ts @@ -1,4 +1,4 @@ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne } from 'typeorm'; +import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'; import { Flight } from '../../flight/entities/flight.entity'; @Entity() diff --git a/src/flight/src/flight/entities/flight.entity.ts b/src/flight/src/flight/entities/flight.entity.ts index d25e1ea..e538db1 100644 --- a/src/flight/src/flight/entities/flight.entity.ts +++ b/src/flight/src/flight/entities/flight.entity.ts @@ -1,4 +1,4 @@ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, JoinColumn } from 'typeorm'; +import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne } from 'typeorm'; import { FlightStatus } from '../enums/flight-status.enum'; import { Aircraft } from '../../aircraft/entities/aircraft.entity'; import { Airport } from '../../airport/entities/airport.entity'; diff --git a/src/flight/src/main.ts b/src/flight/src/main.ts index de1f31a..e6e4163 100644 --- a/src/flight/src/main.ts +++ b/src/flight/src/main.ts @@ -5,7 +5,6 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { PrometheusMetrics } from 'building-blocks/monitoring/prometheus.metrics'; import { ErrorHandlersFilter } from 'building-blocks/filters/error-handlers.filter'; import configs from 'building-blocks/configs/configs'; -import { Request, Response } from 'express'; async function bootstrap() { const app = await NestFactory.create(AppModule); @@ -31,7 +30,7 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe({ transform: true })); - app.use((req: Request, res: Response, next: any) => { + app.use((req, res, next) => { if (req.originalUrl == '/' || req.originalUrl.includes('favicon.ico')) { return res.send(configs.serviceName); } diff --git a/src/flight/src/seat/entities/seat.entity.ts b/src/flight/src/seat/entities/seat.entity.ts index 066afa1..1690c57 100644 --- a/src/flight/src/seat/entities/seat.entity.ts +++ b/src/flight/src/seat/entities/seat.entity.ts @@ -1,4 +1,4 @@ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, JoinColumn } from 'typeorm'; +import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'; import { SeatClass } from '../enums/seat-class.enum'; import { SeatType } from '../enums/seat-type.enum'; import { Flight } from '../../flight/entities/flight.entity'; diff --git a/src/identity/eslint.config.js b/src/identity/eslint.config.js deleted file mode 100644 index 53c4d9d..0000000 --- a/src/identity/eslint.config.js +++ /dev/null @@ -1,12 +0,0 @@ -// https://denar90.github.io/eslint.github.io/docs/rules/ -export default [ - { - rules: { - semi: 'error', - 'prefer-const': 'warn', - 'no-unused-vars': 'warn', - 'no-debugger': 'warn', - 'no-console': 'warn' - } - } -]; diff --git a/src/identity/eslint.config.mjs b/src/identity/eslint.config.mjs new file mode 100644 index 0000000..ee41fb3 --- /dev/null +++ b/src/identity/eslint.config.mjs @@ -0,0 +1,11 @@ +import globals from "globals"; +import tseslint from "typescript-eslint"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {files: ["**/*.{js,mjs,cjs,ts}"]}, + {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, + {languageOptions: { globals: globals.browser }}, + ...tseslint.configs.recommended, +]; \ No newline at end of file diff --git a/src/identity/package.json b/src/identity/package.json index 6b816c7..e8b7a63 100644 --- a/src/identity/package.json +++ b/src/identity/package.json @@ -9,7 +9,7 @@ "build": "nest build", "dev": "nest start --watch", "format": "prettier --write \"**/*.{ts,js}\"", - "lint": "eslint . --fix", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "typeorm": "npm run build && npx typeorm -d ./dist/identity/src/data/data-source.js", "migration:generate": "npm run typeorm -- migration:generate", "migration:run": "npm run typeorm -- migration:run", @@ -42,16 +42,19 @@ "ts-mapper": "^1.2.4" }, "devDependencies": { + "@eslint/js": "^9.17.0", "@faker-js/faker": "^9.3.0", "@types/express": "^5.0.0", "@types/jest": "29.5.14", "@types/supertest": "6.0.2", + "eslint": "^9.17.0", + "globals": "^15.14.0", "jest": "29.7.0", "jest-serial-runner": "^1.2.1", + "prettier": "3.4.2", "supertest": "7.0.0", "ts-jest": "29.2.5", "typemoq": "^2.1.0", - "prettier": "3.4.2", - "eslint": "9.17.0" + "typescript-eslint": "^8.18.2" } } diff --git a/src/identity/src/app.module.ts b/src/identity/src/app.module.ts index 243608b..19a87d1 100644 --- a/src/identity/src/app.module.ts +++ b/src/identity/src/app.module.ts @@ -3,7 +3,7 @@ import { RouterModule } from '@nestjs/core'; import { TypeOrmModule } from '@nestjs/typeorm'; import { UserModule } from './user/user.module'; import { AuthModule } from './auth/auth.module'; -import { PassportModule, Type } from '@nestjs/passport'; +import { PassportModule } from '@nestjs/passport'; import { JwtModule } from '@nestjs/jwt'; import { OpenTelemetryModule } from 'building-blocks/openTelemetry/open-telemetry.module'; import { JwtStrategy } from 'building-blocks/passport/jwt.strategy'; diff --git a/src/identity/src/auth/auth.module.ts b/src/identity/src/auth/auth.module.ts index 1c49a3d..dc28e57 100644 --- a/src/identity/src/auth/auth.module.ts +++ b/src/identity/src/auth/auth.module.ts @@ -14,7 +14,6 @@ import { ValidateTokenHandler } from './features/v1/validate-token/validate-toke import { User } from '../user/entities/user.entity'; import { UserRepository } from '../data/repositories/user.repository'; import { RabbitmqModule } from 'building-blocks/rabbitmq/rabbitmq.module'; -import { RabbitmqOptions } from 'building-blocks/rabbitmq/rabbitmq-connection'; @Module({ imports: [CqrsModule, RabbitmqModule.forRoot(), TypeOrmModule.forFeature([Token, User])], diff --git a/src/identity/src/auth/features/v1/login/login.ts b/src/identity/src/auth/features/v1/login/login.ts index 6f406d3..c995727 100644 --- a/src/identity/src/auth/features/v1/login/login.ts +++ b/src/identity/src/auth/features/v1/login/login.ts @@ -1,7 +1,7 @@ import Joi from 'joi'; import { GenerateToken } from '../generate-token/generate-token'; import { ApiBearerAuth, ApiProperty, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { Body, Controller, Get, HttpStatus, Inject, Post, UseGuards } from '@nestjs/common'; +import { Body, Controller, Inject, Post } from '@nestjs/common'; import { AuthDto } from '../../../dtos/auth.dto'; import { CommandBus, CommandHandler, ICommandHandler } from '@nestjs/cqrs'; import { IAuthRepository } from '../../../../data/repositories/auth.repository'; diff --git a/src/identity/src/auth/features/v1/logout/logout.ts b/src/identity/src/auth/features/v1/logout/logout.ts index 5bc00d7..eebe2b8 100644 --- a/src/identity/src/auth/features/v1/logout/logout.ts +++ b/src/identity/src/auth/features/v1/logout/logout.ts @@ -6,9 +6,7 @@ import { HttpStatus, Inject, NotFoundException, - Param, Post, - Query, Res } from '@nestjs/common'; import { CommandBus, CommandHandler, ICommandHandler } from '@nestjs/cqrs'; diff --git a/src/identity/src/auth/features/v1/refresh-token/refresh-token.ts b/src/identity/src/auth/features/v1/refresh-token/refresh-token.ts index 06a8e6e..bf9d381 100644 --- a/src/identity/src/auth/features/v1/refresh-token/refresh-token.ts +++ b/src/identity/src/auth/features/v1/refresh-token/refresh-token.ts @@ -1,7 +1,7 @@ import Joi from 'joi'; import { GenerateToken } from '../generate-token/generate-token'; import { ApiBearerAuth, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { Body, Controller, Inject, Post, Query, UnauthorizedException } from '@nestjs/common'; +import { Body, Controller, Inject, Post, UnauthorizedException } from '@nestjs/common'; import { CommandBus, CommandHandler, ICommandHandler } from '@nestjs/cqrs'; import { AuthDto } from '../../../dtos/auth.dto'; import { IAuthRepository } from '../../../../data/repositories/auth.repository'; @@ -69,7 +69,7 @@ export class RefreshTokenHandler implements ICommandHandler { const result = await this.commandBus.execute(new GenerateToken({ userId: userId })); return result; - } catch (error) { + } catch { throw new UnauthorizedException('Please authenticate'); } } diff --git a/src/identity/src/main.ts b/src/identity/src/main.ts index 0b543b7..23b8f5b 100644 --- a/src/identity/src/main.ts +++ b/src/identity/src/main.ts @@ -5,7 +5,6 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { PrometheusMetrics } from 'building-blocks/monitoring/prometheus.metrics'; import { ErrorHandlersFilter } from 'building-blocks/filters/error-handlers.filter'; import configs from 'building-blocks/configs/configs'; -import { Request, Response } from 'express'; async function bootstrap() { const app = await NestFactory.create(AppModule); @@ -31,7 +30,7 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe({ transform: true })); - app.use((req: Request, res: Response, next: any) => { + app.use((req, res, next) => { if (req.originalUrl == '/' || req.originalUrl.includes('favicon.ico')) { return res.send(configs.serviceName); } diff --git a/src/identity/src/user/features/v1/delete-user-by-id/delete-user-by-id.ts b/src/identity/src/user/features/v1/delete-user-by-id/delete-user-by-id.ts index 16dbb85..944cfee 100644 --- a/src/identity/src/user/features/v1/delete-user-by-id/delete-user-by-id.ts +++ b/src/identity/src/user/features/v1/delete-user-by-id/delete-user-by-id.ts @@ -5,14 +5,11 @@ import { CommandBus, CommandHandler, ICommandHandler } from '@nestjs/cqrs'; import { Controller, Delete, - HttpStatus, Inject, NotFoundException, Query, - Res, UseGuards } from '@nestjs/common'; -import { Response } from 'express'; import { IUserRepository } from '../../../../data/repositories/user.repository'; import { User } from '../../../entities/user.entity'; import { JwtGuard } from 'building-blocks/passport/jwt.guard'; @@ -49,7 +46,7 @@ export class DeleteUserByIdController { @ApiResponse({ status: 401, description: 'UNAUTHORIZED' }) @ApiResponse({ status: 400, description: 'BAD_REQUEST' }) @ApiResponse({ status: 403, description: 'FORBIDDEN' }) - public async deleteUserById(@Query('id') id: number, @Res() res: Response): Promise { + public async deleteUserById(@Query('id') id: number): Promise { const user = await this.commandBus.execute( new DeleteUserById({ id: id diff --git a/src/identity/src/user/features/v1/get-user-by-id/get-user-by-id.ts b/src/identity/src/user/features/v1/get-user-by-id/get-user-by-id.ts index 936c9fc..aca3935 100644 --- a/src/identity/src/user/features/v1/get-user-by-id/get-user-by-id.ts +++ b/src/identity/src/user/features/v1/get-user-by-id/get-user-by-id.ts @@ -6,7 +6,6 @@ import { Get, Inject, NotFoundException, - Param, Query, UseGuards } from '@nestjs/common'; diff --git a/src/identity/src/user/features/v1/get-users/get-users.ts b/src/identity/src/user/features/v1/get-users/get-users.ts index b387fcd..3c76a03 100644 --- a/src/identity/src/user/features/v1/get-users/get-users.ts +++ b/src/identity/src/user/features/v1/get-users/get-users.ts @@ -1,7 +1,7 @@ import { UserDto } from '../../../dtos/user.dto'; import Joi from 'joi'; import { ApiBearerAuth, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { Controller, Get, Inject, ParseBoolPipe, Query, UseGuards } from '@nestjs/common'; +import { Controller, Get, Inject, Query, UseGuards } from '@nestjs/common'; import { IQueryHandler, QueryBus, QueryHandler } from '@nestjs/cqrs'; import { IUserRepository } from '../../../../data/repositories/user.repository'; import { User } from '../../../entities/user.entity'; diff --git a/src/identity/src/user/user.module.ts b/src/identity/src/user/user.module.ts index 4c061de..8c775ac 100644 --- a/src/identity/src/user/user.module.ts +++ b/src/identity/src/user/user.module.ts @@ -17,8 +17,6 @@ import { import { Token } from '../auth/entities/token.entity'; import { AuthRepository } from '../data/repositories/auth.repository'; import { RabbitmqModule } from 'building-blocks/rabbitmq/rabbitmq.module'; -import { RabbitmqOptions } from 'building-blocks/rabbitmq/rabbitmq-connection'; - @Module({ imports: [CqrsModule, RabbitmqModule.forRoot(), TypeOrmModule.forFeature([User, Token])], controllers: [ diff --git a/src/identity/test/end-to-end-test/user/features/create-user.test.ts b/src/identity/test/end-to-end-test/user/features/create-user.test.ts index f4c9f5e..d997add 100644 --- a/src/identity/test/end-to-end-test/user/features/create-user.test.ts +++ b/src/identity/test/end-to-end-test/user/features/create-user.test.ts @@ -2,7 +2,7 @@ import 'reflect-metadata'; import { EndToEndTestFixture } from '../../../shared/fixtures/end-to-end.fixture'; import { Fixture } from '../../../shared/fixtures/integration-test.fixture'; import { FakeCreateUserRequestDto } from '../../../shared/fakes/user/fake-create-user-request.dto'; -const request = require('supertest'); +import request from "supertest"; describe('end-to-end test for create user', () => { const endToEndFixture = new EndToEndTestFixture(); @@ -17,7 +17,7 @@ describe('end-to-end test for create user', () => { }); it('should create user and retrieve 201 status code', async () => { - const createUserResponse = await request(fixture.app.getHttpServer()) + await request(fixture.app.getHttpServer()) .post('/api/v1/user/create') .send(FakeCreateUserRequestDto.generate()) .expect(201); diff --git a/src/identity/test/shared/fixtures/integration-test.fixture.ts b/src/identity/test/shared/fixtures/integration-test.fixture.ts index 3adfd55..7cb6433 100644 --- a/src/identity/test/shared/fixtures/integration-test.fixture.ts +++ b/src/identity/test/shared/fixtures/integration-test.fixture.ts @@ -41,7 +41,7 @@ export class IntegrationTestFixture { const [postgresContainer, postgresOptions] = await new PostgresContainer().start(); this.fixture.postgresContainer = postgresContainer; - const [rabbitmqContainer, rabbitmqOptions] = await new RabbitmqContainer().start(); + const rabbitmqContainer = await new RabbitmqContainer().start(); this.fixture.rabbitmqContainer = rabbitmqContainer; const module: TestingModule = await Test.createTestingModule({ diff --git a/src/identity/test/unit-test/user/features/create-user.test.ts b/src/identity/test/unit-test/user/features/create-user.test.ts index 99ed140..64dd75d 100644 --- a/src/identity/test/unit-test/user/features/create-user.test.ts +++ b/src/identity/test/unit-test/user/features/create-user.test.ts @@ -1,5 +1,4 @@ import { UserCreated } from 'building-blocks/contracts/identity.contract'; -import { faker } from '@faker-js/faker'; import * as TypeMoq from 'typemoq'; import { FakeUser } from '../../../shared/fakes/user/fake-user.entity'; import { User } from '../../../../src/user/entities/user.entity'; @@ -23,8 +22,6 @@ describe('unit test for create user', () => { }); it('should create a user and retrieve a valid data', async () => { - const email = faker.internet.email(); - mockUserRepository .setup((x) => x.findUserByEmail(TypeMoq.It.isAnyString())) .returns(() => null); diff --git a/src/passenger/eslint.config.js b/src/passenger/eslint.config.js deleted file mode 100644 index 70f0b27..0000000 --- a/src/passenger/eslint.config.js +++ /dev/null @@ -1,12 +0,0 @@ -// https://denar90.github.io/eslint.github.io/docs/rules/ -export default [ - { - rules: { - semi: "error", - "prefer-const": "warn", - "no-unused-vars": "warn", - "no-debugger": "warn", - "no-console": "warn" - } - } -]; diff --git a/src/passenger/eslint.config.mjs b/src/passenger/eslint.config.mjs new file mode 100644 index 0000000..ee41fb3 --- /dev/null +++ b/src/passenger/eslint.config.mjs @@ -0,0 +1,11 @@ +import globals from "globals"; +import tseslint from "typescript-eslint"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {files: ["**/*.{js,mjs,cjs,ts}"]}, + {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, + {languageOptions: { globals: globals.browser }}, + ...tseslint.configs.recommended, +]; \ No newline at end of file diff --git a/src/passenger/package.json b/src/passenger/package.json index 734f816..073663b 100644 --- a/src/passenger/package.json +++ b/src/passenger/package.json @@ -9,7 +9,7 @@ "build": "nest build", "dev": "nest start --watch", "format": "prettier --write \"**/*.{ts,js}\"", - "lint": "eslint . --fix", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "typeorm": "npm run build && npx typeorm -d ./dist/data/data-source.js", "migration:generate": "npm run typeorm -- migration:generate", "migration:run": "npm run typeorm -- migration:run", @@ -42,16 +42,19 @@ "ts-mapper": "^1.2.4" }, "devDependencies": { + "@eslint/js": "^9.17.0", "@faker-js/faker": "^9.3.0", "@types/express": "^5.0.0", "@types/jest": "29.5.14", "@types/supertest": "6.0.2", + "eslint": "^9.17.0", + "globals": "^15.14.0", "jest": "29.7.0", "jest-serial-runner": "^1.2.1", + "prettier": "3.4.2", "supertest": "7.0.0", "ts-jest": "29.2.5", "typemoq": "^2.1.0", - "prettier": "3.4.2", - "eslint": "9.17.0" + "typescript-eslint": "^8.18.2" } } diff --git a/src/passenger/src/main.ts b/src/passenger/src/main.ts index c971ca1..d6dd725 100644 --- a/src/passenger/src/main.ts +++ b/src/passenger/src/main.ts @@ -5,7 +5,6 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import {PrometheusMetrics} from "building-blocks/monitoring/prometheus.metrics"; import {ErrorHandlersFilter} from "building-blocks/filters/error-handlers.filter"; import configs from "building-blocks/configs/configs"; -import {Request, Response} from "express"; async function bootstrap() { const app = await NestFactory.create(AppModule); @@ -31,7 +30,7 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe({ transform: true })); - app.use((req: Request, res: Response, next: any) => { + app.use((req, res, next) => { if (req.originalUrl == '/' || req.originalUrl.includes('favicon.ico')) { return res.send(configs.serviceName); }