Skip to content

Commit

Permalink
Merge pull request #12 from meysamhadeli/refactor/refactor-eslint-to-…
Browse files Browse the repository at this point in the history
…last-version

chore: update .gitignore
  • Loading branch information
meysamhadeli authored Dec 26, 2024
2 parents 8023f1c + a462f73 commit a084c55
Show file tree
Hide file tree
Showing 39 changed files with 109 additions and 118 deletions.
12 changes: 0 additions & 12 deletions src/booking/eslint.config.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/booking/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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,
];
9 changes: 6 additions & 3 deletions src/booking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion src/booking/src/booking/entities/booking.entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Booking {
Expand Down
3 changes: 1 addition & 2 deletions src/booking/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
12 changes: 0 additions & 12 deletions src/building-blocks/eslint.config.js

This file was deleted.

12 changes: 12 additions & 0 deletions src/building-blocks/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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,

];
10 changes: 7 additions & 3 deletions src/building-blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface PostgresContainerOptions {
username: string;
password: string;
synchronize: boolean;
entities: MixedList<Function | string | EntitySchema>;
entities: MixedList<string | EntitySchema>;
migrationsRun: boolean;
}
export declare class PostgresContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface PostgresContainerOptions {
username: string;
password: string;
synchronize: boolean;
entities: MixedList<Function | string | EntitySchema>;
entities: MixedList<string | EntitySchema>;
migrationsRun: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,7 +12,7 @@ export interface RabbitmqContainerOptions {
}

export class RabbitmqContainer {
public async start(): Promise<[StartedTestContainer, RabbitmqOptions]> {
public async start(): Promise<StartedTestContainer> {
const defaultRabbitmqOptions = await this.getDefaultRabbitmqTestContainers();

const rabbitmqContainerStarted = await this.getContainerStarted(defaultRabbitmqOptions);
Expand All @@ -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(
Expand Down
12 changes: 0 additions & 12 deletions src/flight/eslint.config.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/flight/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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,
];
9 changes: 6 additions & 3 deletions src/flight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion src/flight/src/aircraft/entities/aircraft.entity.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/flight/src/airport/entities/airport.entity.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/flight/src/flight/entities/flight.entity.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 1 addition & 2 deletions src/flight/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/flight/src/seat/entities/seat.entity.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
12 changes: 0 additions & 12 deletions src/identity/eslint.config.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/identity/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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,
];
9 changes: 6 additions & 3 deletions src/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion src/identity/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion src/identity/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])],
Expand Down
2 changes: 1 addition & 1 deletion src/identity/src/auth/features/v1/login/login.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 0 additions & 2 deletions src/identity/src/auth/features/v1/logout/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import {
HttpStatus,
Inject,
NotFoundException,
Param,
Post,
Query,
Res
} from '@nestjs/common';
import { CommandBus, CommandHandler, ICommandHandler } from '@nestjs/cqrs';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -69,7 +69,7 @@ export class RefreshTokenHandler implements ICommandHandler<RefreshToken> {
const result = await this.commandBus.execute(new GenerateToken({ userId: userId }));

return result;
} catch (error) {
} catch {
throw new UnauthorizedException('Please authenticate');
}
}
Expand Down
Loading

0 comments on commit a084c55

Please sign in to comment.