mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-11 02:20:20 +08:00
refactor: Refactor Yarp api gateway
This commit is contained in:
parent
a46d838591
commit
37fac813d4
17
.gitpod.yml
17
.gitpod.yml
@ -8,6 +8,17 @@
|
||||
image:
|
||||
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/projects/prebuilds
|
||||
tasks:
|
||||
@ -23,8 +34,4 @@ tasks:
|
||||
init: |
|
||||
dotnet dev-certs https
|
||||
dotnet restore
|
||||
dotnet build
|
||||
|
||||
vscode:
|
||||
extensions:
|
||||
- muhammad-sammy.csharp
|
||||
dotnet build
|
||||
|
||||
256
booking.k8s.rest
256
booking.k8s.rest
@ -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"
|
||||
}
|
||||
###
|
||||
39
booking.rest
39
booking.rest
@ -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
|
||||
@identity-api=http://localhost:6005
|
||||
@flight-api=https://localhost:5003
|
||||
@passenger-api=https://localhost:5012
|
||||
@booking-api=https://localhost:5010
|
||||
@flight-api=http://localhost:5004
|
||||
@passenger-api=http://localhost:6012
|
||||
@booking-api=http://localhost:6010
|
||||
|
||||
@contentType = application/json
|
||||
@flightid = 1
|
||||
@ -20,7 +21,7 @@ GET {{identity-api}}
|
||||
|
||||
###
|
||||
# @name Authenticate
|
||||
POST {{api-gateway}}/connect/token
|
||||
POST {{api-gateway}}/identity/connect/token
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
grant_type=password
|
||||
@ -35,7 +36,7 @@ grant_type=password
|
||||
|
||||
###
|
||||
# @name Register_New_User
|
||||
POST {{api-gateway}}/api/v1/identity/register-user
|
||||
POST {{api-gateway}}/identity/api/v1/identity/register-user
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -60,7 +61,7 @@ GET {{flight-api}}
|
||||
|
||||
###
|
||||
# @name Create_Seat
|
||||
Post {{api-gateway}}/api/v1/flight/seat
|
||||
Post {{api-gateway}}/flight/api/v1/flight/seat
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -76,7 +77,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Reserve_Seat
|
||||
Post {{api-gateway}}/api/v1/flight/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}}
|
||||
@ -90,7 +91,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @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
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -99,7 +100,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Get_Flight_By_Id
|
||||
GET {{api-gateway}}/api/v1/flight/{{flightid}}
|
||||
GET {{api-gateway}}/flight/api/v1/flight/{{flightid}}
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -108,7 +109,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @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
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -117,7 +118,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Create_Flights
|
||||
POST {{api-gateway}}/api/v1/flight
|
||||
POST {{api-gateway}}/flight/api/v1/flight
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -139,7 +140,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Update_Flights
|
||||
PUT {{api-gateway}}/api/v1/flight
|
||||
PUT {{api-gateway}}/flight/api/v1/flight
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -163,7 +164,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Delete_Flights
|
||||
DELETE {{api-gateway}}/api/v1/flight/{{flightid}}
|
||||
DELETE {{api-gateway}}/flight/api/v1/flight/{{flightid}}
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -172,7 +173,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Create_Airport
|
||||
POST {{api-gateway}}/api/v1/flight/airport
|
||||
POST {{api-gateway}}/flight/api/v1/flight/airport
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -188,7 +189,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Create_Aircraft
|
||||
POST {{api-gateway}}/api/v1/flight/aircraft
|
||||
POST {{api-gateway}}/flight/api/v1/flight/aircraft
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -211,7 +212,7 @@ GET {{passenger-api}}
|
||||
|
||||
###
|
||||
# @name Complete_Registration_Passenger
|
||||
POST {{api-gateway}}/api/v1/passenger/complete-registration
|
||||
POST {{api-gateway}}/passenger/api/v1/passenger/complete-registration
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -226,7 +227,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
###
|
||||
# @name Get_Passenger_By_Id
|
||||
GET {{api-gateway}}/api/v1/passenger/{{passengerId}}
|
||||
GET {{api-gateway}}/passenger/api/v1/passenger/{{passengerId}}
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
@ -243,7 +244,7 @@ GET {{booking-api}}
|
||||
|
||||
###
|
||||
# @name Create_Booking
|
||||
POST {{api-gateway}}/api/v1/booking
|
||||
POST {{api-gateway}}/booking/api/v1/booking
|
||||
accept: application/json
|
||||
Content-Type: application/json
|
||||
authorization: bearer {{Authenticate.response.body.access_token}}
|
||||
|
||||
@ -15,33 +15,53 @@
|
||||
"identity": {
|
||||
"clusterId": "identity",
|
||||
"match": {
|
||||
"path": "/{**catch-all}"
|
||||
"path": "identity/{**catch-all}"
|
||||
},
|
||||
"Transforms": [
|
||||
{
|
||||
"PathRemovePrefix": "identity"
|
||||
}
|
||||
]
|
||||
},
|
||||
"flight": {
|
||||
"clusterId": "flight",
|
||||
"match": {
|
||||
"path": "api/{version}/flight/{**catch-all}"
|
||||
}
|
||||
"path": "flight/{**catch-all}"
|
||||
},
|
||||
"Transforms": [
|
||||
{
|
||||
"PathRemovePrefix": "flight"
|
||||
}
|
||||
]
|
||||
},
|
||||
"passenger": {
|
||||
"clusterId": "passenger",
|
||||
"match": {
|
||||
"path": "api/{version}/passenger/{**catch-all}"
|
||||
}
|
||||
"path": "passenger/{**catch-all}"
|
||||
},
|
||||
"Transforms": [
|
||||
{
|
||||
"PathRemovePrefix": "passenger"
|
||||
}
|
||||
]
|
||||
},
|
||||
"booking": {
|
||||
"clusterId": "booking",
|
||||
"match": {
|
||||
"path": "api/{version}/booking/{**catch-all}"
|
||||
}
|
||||
"path": "booking/{**catch-all}"
|
||||
},
|
||||
"Transforms": [
|
||||
{
|
||||
"PathRemovePrefix": "booking"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"clusters": {
|
||||
"flight": {
|
||||
"destinations": {
|
||||
"destination1": {
|
||||
"address": "https://localhost:5003"
|
||||
"address": "http://localhost:5004"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -55,14 +75,14 @@
|
||||
"passenger": {
|
||||
"destinations": {
|
||||
"destination1": {
|
||||
"address": "https://localhost:5012"
|
||||
"address": "http://localhost:6012"
|
||||
}
|
||||
}
|
||||
},
|
||||
"booking": {
|
||||
"destinations": {
|
||||
"destination1": {
|
||||
"address": "https://localhost:5010"
|
||||
"address": "http://localhost:6010"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user