Skip to content

Commit

Permalink
chore: some change in routing params
Browse files Browse the repository at this point in the history
  • Loading branch information
meysamhadeli committed Dec 13, 2023
1 parent 8855f4f commit bfa4ce0
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 44 deletions.
18 changes: 13 additions & 5 deletions booking.rest
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,27 @@ Content-Type: application/json

###
# @name Logout
POST {{identity-api}}/api/v1/identity/logout?accessToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTcwMjMzMzM1NiwiZXhwIjoxNzAyMzM1MTU2LCJ0eXBlIjowfQ.A2uF3tg2Y0ZK7sK53Y7r-JWTs8s66A_2Jf8DY_qchDA
POST {{identity-api}}/api/v1/identity/logout
accept: application/json
Content-Type: application/json

{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTcwMjMzMzMzNSwiZXhwIjoxNzAyNDE5NzM1LCJ0eXBlIjoxfQ.T0z6lAQ4pxrKS6L6MutrwVbBGe96rq2wbIy0mCNs488"
}

###


###
# @name Refresh_Token
POST {{identity-api}}/api/v1/identity/refresh-token?refreshToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTcwMjMzMzMzNSwiZXhwIjoxNzAyNDE5NzM1LCJ0eXBlIjoxfQ.T0z6lAQ4pxrKS6L6MutrwVbBGe96rq2wbIy0mCNs488
POST {{identity-api}}/api/v1/identity/refresh-token
accept: application/json
Content-Type: application/json

{
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTcwMjMzMzMzNSwiZXhwIjoxNzAyNDE5NzM1LCJ0eXBlIjoxfQ.T0z6lAQ4pxrKS6L6MutrwVbBGe96rq2wbIy0mCNs488"
}

###

###
Expand All @@ -60,7 +68,7 @@ authorization: bearer {{Login.response.body.access.token}}

###
# @name Update_User
PUT {{identity-api}}/api/v1/user/update?id=3
PUT {{identity-api}}/api/v1/user/update/2
accept: application/json
Content-Type: application/json
authorization: bearer {{Login.response.body.access.token}}
Expand All @@ -70,7 +78,7 @@ authorization: bearer {{Login.response.body.access.token}}
"password": "Admin@12345",
"name": "John",
"role": 0,
"passportNumber": "12345678"
"passportNumber": "12345000"
}
###

Expand Down Expand Up @@ -110,7 +118,7 @@ GET {{flight-api}}

###
# @name Create_Airport
POST {{flight-api}}/api/v1/airport/airport
POST {{flight-api}}/api/v1/airport/create
accept: application/json
Content-Type: application/json
authorization: bearer {{Login.response.body.access.token}}
Expand Down
4 changes: 2 additions & 2 deletions src/booking/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {JwtStrategy} from "building-blocks/passport/jwt.strategy";
import {BookingModule} from "./booking/booking.module";
import configs from "building-blocks/configs/configs";
import {MiddlewareConsumer, Module, NestModule} from "@nestjs/common";
import {ContextMiddleware} from "building-blocks/context/context";
import {HttpContextMiddleware} from "building-blocks/context/context";

@Module({
imports: [
Expand All @@ -32,7 +32,7 @@ import {ContextMiddleware} from "building-blocks/context/context";
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(ContextMiddleware)
.apply(HttpContextMiddleware)
.forRoutes('*');
}
}
2 changes: 1 addition & 1 deletion src/building-blocks/context/context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export declare class HttpContext {
static response: Response;
static headers: IncomingHttpHeaders;
}
export declare class ContextMiddleware implements NestMiddleware {
export declare class HttpContextMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction): void;
}
25 changes: 6 additions & 19 deletions src/building-blocks/context/context.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/building-blocks/context/context.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/building-blocks/context/context.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Injectable, NestMiddleware } from '@nestjs/common';
import { NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
import {IncomingHttpHeaders} from "http";

@Injectable()
export class HttpContext {
static request: Request;
static response: Response;
static headers: IncomingHttpHeaders;
}


@Injectable()
export class ContextMiddleware implements NestMiddleware {
export class HttpContextMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {

HttpContext.request = req;
Expand Down
2 changes: 1 addition & 1 deletion src/building-blocks/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/flight/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {DataSeeder} from "./data/seeds/data-seeder";
import {OpenTelemetryModule} from "building-blocks/openTelemetry/open-telemetry.module";
import {JwtStrategy} from "building-blocks/passport/jwt.strategy";
import configs from "building-blocks/configs/configs";
import {ContextMiddleware} from "building-blocks/context/context";
import {HttpContextMiddleware} from "building-blocks/context/context";

@Module({
imports: [
Expand Down Expand Up @@ -56,7 +56,7 @@ export class AppModule implements OnApplicationBootstrap, NestModule {

configure(consumer: MiddlewareConsumer) {
consumer
.apply(ContextMiddleware)
.apply(HttpContextMiddleware)
.forRoutes('*');
}

Expand Down
4 changes: 2 additions & 2 deletions src/identity/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {JwtStrategy} from "building-blocks/passport/jwt.strategy";
import configs from "building-blocks/configs/configs";
import {postgresOptions} from "./data/data-source";
import {DataSeeder} from "./data/seeds/data-seeder";
import {ContextMiddleware} from "building-blocks/context/context";
import {HttpContextMiddleware} from "building-blocks/context/context";

@Module({
imports: [
Expand Down Expand Up @@ -44,7 +44,7 @@ export class AppModule implements OnApplicationBootstrap, NestModule {

configure(consumer: MiddlewareConsumer) {
consumer
.apply(ContextMiddleware)
.apply(HttpContextMiddleware)
.forRoutes('*');
}

Expand Down
2 changes: 1 addition & 1 deletion src/identity/src/auth/features/v1/logout/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class LogoutController {
@ApiResponse({status: 400, description: 'BAD_REQUEST'})
@ApiResponse({status: 403, description: 'FORBIDDEN'})
@ApiResponse({status: 204, description: 'NO_CONTENT'})
public async logout(@Query('accessToken') accessToken: string, @Res() res: Response): Promise<void> {
public async logout(@Body('accessToken') accessToken: string, @Res() res: Response): Promise<void> {

await this.commandBus.execute(new Logout({accessToken: accessToken}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Joi from 'joi';
import {GenerateToken} from '../generateToken/generate-token';
import {ApiBearerAuth, ApiResponse, ApiTags} from "@nestjs/swagger";
import {Controller, Inject, Post, Query, UnauthorizedException} from "@nestjs/common";
import {Body, Controller, Inject, Post, Query, 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 @@ -39,7 +39,7 @@ export class RefreshTokenController {
@ApiResponse({status: 400, description: 'BAD_REQUEST'})
@ApiResponse({status: 403, description: 'FORBIDDEN'})
@ApiResponse({status: 200, description: 'OK'})
public async refreshToken(@Query('refreshToken') refreshToken: string): Promise<AuthDto> {
public async refreshToken(@Body('refreshToken') refreshToken: string): Promise<AuthDto> {
const result = await this.commandBus.execute(new RefreshToken({refreshToken: refreshToken}));

return result;
Expand Down
3 changes: 3 additions & 0 deletions src/identity/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ 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 {NextFunction, Request, Response} from "express";
import {HttpContext} from "building-blocks/context/context";
import * as Prometheus from "prom-client";


async function bootstrap() {
Expand Down
4 changes: 2 additions & 2 deletions src/identity/src/user/features/v1/updateUser/update-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ export class UpdateUserController {
constructor(private readonly commandBus: CommandBus,) {
}

@Put('update')
@Put('update/:id')
@UseGuards(JwtGuard)
@ApiResponse({status: 204, description: 'NO_CONTENT'})
@ApiResponse({status: 401, description: 'UNAUTHORIZED'})
@ApiResponse({status: 400, description: 'BAD_REQUEST'})
@ApiResponse({status: 403, description: 'FORBIDDEN'})
public async updateUser(
@Query('id') id: number,
@Param('id') id: number,
@Body() request: UpdateUserRequestDto,
@Res() res: Response
): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/passenger/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import configs from "building-blocks/configs/configs";
import {OpenTelemetryModule} from "building-blocks/openTelemetry/open-telemetry.module";
import {JwtStrategy} from "building-blocks/passport/jwt.strategy";
import {PassengerModule} from "./passenger/passenger.module";
import {ContextMiddleware} from "building-blocks/context/context";
import {HttpContextMiddleware} from "building-blocks/context/context";

@Module({
imports: [
Expand All @@ -32,7 +32,7 @@ import {ContextMiddleware} from "building-blocks/context/context";
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(ContextMiddleware)
.apply(HttpContextMiddleware)
.forRoutes('*');
}
}

0 comments on commit bfa4ce0

Please sign in to comment.