Merge pull request #212 from meysamhadeli/refactor/refactor-yarp-api-gateway

Refactor/refactor yarp api gateway
This commit is contained in:
Meysam Hadeli 2023-02-26 17:00:15 +03:30 committed by GitHub
commit e914b68220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 290 deletions

View File

@ -8,6 +8,17 @@
image: image:
file: .gitpod.Dockerfile file: .gitpod.Dockerfile
vscode:
extensions:
- muhammad-sammy.csharp
- editorconfig.editorconfig
- vivaxy.vscode-conventional-commits
- humao.rest-client
- ms-azuretools.vscode-docker
- donjayamanne.githistory
- pkief.material-icon-theme
- emmanuelbeziat.vscode-great-icons
# https://www.gitpod.io/docs/configure/workspaces/tasks#execution-order # https://www.gitpod.io/docs/configure/workspaces/tasks#execution-order
# https://www.gitpod.io/docs/configure/projects/prebuilds # https://www.gitpod.io/docs/configure/projects/prebuilds
tasks: tasks:
@ -23,8 +34,4 @@ tasks:
init: | init: |
dotnet dev-certs https dotnet dev-certs https
dotnet restore dotnet restore
dotnet build dotnet build
vscode:
extensions:
- muhammad-sammy.csharp

View File

@ -1,256 +0,0 @@
# https://github.com/Huachao/vscode-restclient
@api-gateway=https://booking-microservices.com
@identity-api=https://booking-microservices.com/identity
@flight-api=https://booking-microservices.com/flight
@passenger-api=https://booking-microservices.com/passenger
@booking-api=https://booking-microservices.com/booking
@contentType = application/json
@flightid = 1
@passengerId = 1
################################# Identity API #################################
###
# @name ApiRoot_Identity
GET {{identity-api}}
###
###
# @name Authenticate
POST {{api-gateway}}/identity/connect/token
Content-Type: application/x-www-form-urlencoded
grant_type=password
&client_id=client
&client_secret=secret
&username=samh
&password=Admin@123456
&scope=flight-api
###
###
# @name Register_New_User
POST {{api-gateway}}/identity/api/v1/identity/register-user
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"firstName": "John",
"lastName": "Do",
"username": "admin",
"passportNumber": "412900000000",
"email": "admin@admin.com",
"password": "Admin@12345",
"confirmPassword": "Admin@12345"
}
###
################################# Flight API #################################
###
# @name ApiRoot_Flight
GET {{flight-api}}
###
###
# @name Create_Seat
Post {{api-gateway}}/flight/api/v1/flight/seat
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"seatNumber": "1255",
"type": 1,
"class": 1,
"flightId": 1
}
###
###
# @name Reserve_Seat
Post {{api-gateway}}/flight/api/v1/flight/reserve-seat
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"flightId": 1,
"seatNumber": "1255"
}
###
###
# @name Get_Available_Seats
GET {{api-gateway}}/flight/api/v1/flight/get-available-seats/{{flightid}}
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
###
###
# @name Get_Flight_By_Id
GET {{api-gateway}}/flight/api/v1/flight/{{flightid}}
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
###
###
# @name Get_Available_Flights
GET {{api-gateway}}/flight/api/v1/flight/get-available-flights
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
###
###
# @name Create_Flights
POST {{api-gateway}}/flight/api/v1/flight
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"flightNumber": "12BB",
"aircraftId": 1,
"departureAirportId": 1,
"departureDate": "2022-03-01T14:55:41.255Z",
"arriveDate": "2022-03-01T14:55:41.255Z",
"arriveAirportId": 2,
"durationMinutes": 120,
"flightDate": "2022-03-01T14:55:41.255Z",
"status": 1,
"price": 8000
}
###
###
# @name Update_Flights
PUT {{api-gateway}}/flight/api/v1/flight
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"id": 1,
"flightNumber": "BD467",
"aircraftId": 1,
"departureAirportId": 1,
"departureDate": "2022-04-23T12:17:45.140Z",
"arriveDate": "2022-04-23T12:17:45.140Z",
"arriveAirportId": 2,
"durationMinutes": 120,
"flightDate": "2022-04-23T12:17:45.140Z",
"status": 4,
"isDeleted": false,
"price": 99000
}
###
###
# @name Delete_Flights
DELETE {{api-gateway}}/flight/api/v1/flight/{{flightid}}
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
###
###
# @name Create_Airport
POST {{api-gateway}}/flight/api/v1/flight/airport
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"name": "mehrabad",
"address": "tehran",
"code": "12YD"
}
###
###
# @name Create_Aircraft
POST {{api-gateway}}/flight/api/v1/flight/aircraft
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"name": "airbus2",
"model": "322",
"manufacturingYear": 2012
}
###
################################# Passenger API #################################
###
# @name ApiRoot_Passenger
GET {{passenger-api}}
###
###
# @name Complete_Registration_Passenger
POST {{api-gateway}}/passenger/api/v1/passenger/complete-registration
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"passportNumber": "412900000000",
"passengerType": 1,
"age": 30
}
###
###
# @name Get_Passenger_By_Id
GET {{api-gateway}}/passenger/api/v1/passenger/{{passengerId}}
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
###
################################# Booking API #################################
###
# @name ApiRoot_Booking
GET {{booking-api}}
###
###
# @name Create_Booking
POST {{api-gateway}}/booking/api/v1/booking
accept: application/json
Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
"passengerId": 8765596234940416,
"flightId": 1,
"description": "I want to fly to iran"
}
###

View File

@ -1,10 +1,11 @@
# https://github.com/Huachao/vscode-restclient
## uncommnet this line for use kubernetes ingress controller instead of Yarp
//@api-gateway=https://booking-microservices.com
@api-gateway=https://localhost:5000 @api-gateway=https://localhost:5000
@identity-api=http://localhost:6005 @identity-api=http://localhost:6005
@flight-api=https://localhost:5003 @flight-api=http://localhost:5004
@passenger-api=https://localhost:5012 @passenger-api=http://localhost:6012
@booking-api=https://localhost:5010 @booking-api=http://localhost:6010
@contentType = application/json @contentType = application/json
@flightid = 1 @flightid = 1
@ -20,7 +21,7 @@ GET {{identity-api}}
### ###
# @name Authenticate # @name Authenticate
POST {{api-gateway}}/connect/token POST {{api-gateway}}/identity/connect/token
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
grant_type=password grant_type=password
@ -35,7 +36,7 @@ grant_type=password
### ###
# @name Register_New_User # @name Register_New_User
POST {{api-gateway}}/api/v1/identity/register-user POST {{api-gateway}}/identity/api/v1/identity/register-user
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -60,7 +61,7 @@ GET {{flight-api}}
### ###
# @name Create_Seat # @name Create_Seat
Post {{api-gateway}}/api/v1/flight/seat Post {{api-gateway}}/flight/api/v1/flight/seat
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -76,7 +77,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Reserve_Seat # @name Reserve_Seat
Post {{api-gateway}}/api/v1/flight/reserve-seat Post {{api-gateway}}/flight/api/v1/flight/reserve-seat
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -90,7 +91,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Get_Available_Seats # @name Get_Available_Seats
GET {{api-gateway}}/api/v1/flight/get-available-seats/{{flightid}} GET {{api-gateway}}/flight/api/v1/flight/get-available-seats/{{flightid}}
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -99,7 +100,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Get_Flight_By_Id # @name Get_Flight_By_Id
GET {{api-gateway}}/api/v1/flight/{{flightid}} GET {{api-gateway}}/flight/api/v1/flight/{{flightid}}
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -108,7 +109,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Get_Available_Flights # @name Get_Available_Flights
GET {{api-gateway}}/api/v1/flight/get-available-flights GET {{api-gateway}}/flight/api/v1/flight/get-available-flights
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -117,7 +118,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Create_Flights # @name Create_Flights
POST {{api-gateway}}/api/v1/flight POST {{api-gateway}}/flight/api/v1/flight
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -139,7 +140,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Update_Flights # @name Update_Flights
PUT {{api-gateway}}/api/v1/flight PUT {{api-gateway}}/flight/api/v1/flight
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -163,7 +164,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Delete_Flights # @name Delete_Flights
DELETE {{api-gateway}}/api/v1/flight/{{flightid}} DELETE {{api-gateway}}/flight/api/v1/flight/{{flightid}}
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -172,7 +173,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Create_Airport # @name Create_Airport
POST {{api-gateway}}/api/v1/flight/airport POST {{api-gateway}}/flight/api/v1/flight/airport
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -188,7 +189,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Create_Aircraft # @name Create_Aircraft
POST {{api-gateway}}/api/v1/flight/aircraft POST {{api-gateway}}/flight/api/v1/flight/aircraft
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -211,7 +212,7 @@ GET {{passenger-api}}
### ###
# @name Complete_Registration_Passenger # @name Complete_Registration_Passenger
POST {{api-gateway}}/api/v1/passenger/complete-registration POST {{api-gateway}}/passenger/api/v1/passenger/complete-registration
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -226,7 +227,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
### ###
# @name Get_Passenger_By_Id # @name Get_Passenger_By_Id
GET {{api-gateway}}/api/v1/passenger/{{passengerId}} GET {{api-gateway}}/passenger/api/v1/passenger/{{passengerId}}
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}
@ -243,7 +244,7 @@ GET {{booking-api}}
### ###
# @name Create_Booking # @name Create_Booking
POST {{api-gateway}}/api/v1/booking POST {{api-gateway}}/booking/api/v1/booking
accept: application/json accept: application/json
Content-Type: application/json Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}} authorization: bearer {{Authenticate.response.body.access_token}}

View File

@ -15,33 +15,53 @@
"identity": { "identity": {
"clusterId": "identity", "clusterId": "identity",
"match": { "match": {
"path": "/{**catch-all}" "path": "identity/{**catch-all}"
},
"Transforms": [
{
"PathRemovePrefix": "identity"
} }
]
}, },
"flight": { "flight": {
"clusterId": "flight", "clusterId": "flight",
"match": { "match": {
"path": "api/{version}/flight/{**catch-all}" "path": "flight/{**catch-all}"
} },
"Transforms": [
{
"PathRemovePrefix": "flight"
}
]
}, },
"passenger": { "passenger": {
"clusterId": "passenger", "clusterId": "passenger",
"match": { "match": {
"path": "api/{version}/passenger/{**catch-all}" "path": "passenger/{**catch-all}"
} },
"Transforms": [
{
"PathRemovePrefix": "passenger"
}
]
}, },
"booking": { "booking": {
"clusterId": "booking", "clusterId": "booking",
"match": { "match": {
"path": "api/{version}/booking/{**catch-all}" "path": "booking/{**catch-all}"
} },
"Transforms": [
{
"PathRemovePrefix": "booking"
}
]
} }
}, },
"clusters": { "clusters": {
"flight": { "flight": {
"destinations": { "destinations": {
"destination1": { "destination1": {
"address": "https://localhost:5003" "address": "http://localhost:5004"
} }
} }
}, },
@ -55,14 +75,14 @@
"passenger": { "passenger": {
"destinations": { "destinations": {
"destination1": { "destination1": {
"address": "https://localhost:5012" "address": "http://localhost:6012"
} }
} }
}, },
"booking": { "booking": {
"destinations": { "destinations": {
"destination1": { "destination1": {
"address": "https://localhost:5010" "address": "http://localhost:6010"
} }
} }
} }