Skip to content

Commit

Permalink
Merge pull request #260 from HSLdevcom/DT-6436
Browse files Browse the repository at this point in the history
DT-6436 Add new GTFS graphql endpoint, health check endpoint and limit usage of other routing APIs
  • Loading branch information
vesameskanen authored Sep 26, 2024
2 parents 9495b10 + 6fb69f5 commit 1bc98a6
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 34 deletions.
114 changes: 108 additions & 6 deletions common.conf
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ location /routing/v1/routers/waltti/profile {
deny all;
}

location /routing/v2/routers/finland {
location = /routing/v2/routers/finland/index/graphql {
rewrite /routing/v2/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-finland-v2:8080/;
proxy_redirect off;
Expand All @@ -246,7 +246,24 @@ location /routing/v2/routers/finland {
proxy_read_timeout 29500ms;
}

location /routing/v2/routers/waltti {
location = /routing/v2/finland/gtfs/v1 {
rewrite /routing/v2/finland/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-finland-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 29500ms;
}

location = /routing/v2/finland/health {
rewrite /routing/v2/finland/(.*) /otp/actuators/$1 break;
proxy_pass http://opentripplanner-finland-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location = /routing/v2/routers/waltti/index/graphql {
rewrite /routing/v2/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-waltti-v2:8080/;
proxy_redirect off;
Expand All @@ -256,7 +273,24 @@ location /routing/v2/routers/waltti {
proxy_read_timeout 11500ms;
}

location /routing/v2/routers/waltti-alt {
location = /routing/v2/waltti/gtfs/v1 {
rewrite /routing/v2/waltti/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-waltti-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 11500ms;
}

location = /routing/v2/waltti/health {
rewrite /routing/v2/waltti/(.*) /otp/actuators/$1 break;
proxy_pass http://opentripplanner-waltti-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location = /routing/v2/routers/waltti-alt/index/graphql {
rewrite /routing/v2/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-waltti-alt-v2:8080/;
proxy_redirect off;
Expand All @@ -266,7 +300,24 @@ location /routing/v2/routers/waltti-alt {
proxy_read_timeout 11500ms;
}

location /routing/v2/routers/varely {
location = /routing/v2/waltti-alt/gtfs/v1 {
rewrite /routing/v2/waltti-alt/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-waltti-alt-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 11500ms;
}

location = /routing/v2/waltti-alt/health {
rewrite /routing/v2/waltti-alt/(.*) /otp/actuators/$1 break;
proxy_pass http://opentripplanner-waltti-alt-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location = /routing/v2/routers/varely/index/graphql {
rewrite /routing/v2/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-varely-v2:8080/;
proxy_redirect off;
Expand All @@ -276,7 +327,24 @@ location /routing/v2/routers/varely {
proxy_read_timeout 11500ms;
}

location /routing/v2-kela/routers/kela {
location = /routing/v2/varely/gtfs/v1 {
rewrite /routing/v2/varely/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-varely-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 11500ms;
}

location = /routing/v2/varely/health {
rewrite /routing/v2/varely/(.*) /otp/actuators/$1 break;
proxy_pass http://opentripplanner-varely-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location = /routing/v2-kela/routers/kela/index/graphql {
rewrite /routing/v2-kela/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-kela-v2:8080/;
proxy_redirect off;
Expand All @@ -286,7 +354,24 @@ location /routing/v2-kela/routers/kela {
proxy_read_timeout 29500ms;
}

location /routing/v2/routers/hsl {
location = /routing/v2-kela/kela/gtfs/v1 {
rewrite /routing/v2-kela/kela/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-kela-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 29500ms;
}

location = /routing/v2-kela/kela/health {
rewrite /routing/v2-kela/kela/(.*) /otp/actuators/$1 break;
proxy_pass http://opentripplanner-kela-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location = /routing/v2/routers/hsl/index/graphql {
rewrite /routing/v2/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-hsl-v2:8080/;
proxy_redirect off;
Expand All @@ -296,6 +381,23 @@ location /routing/v2/routers/hsl {
proxy_read_timeout 11500ms;
}

location = /routing/v2/hsl/gtfs/v1 {
rewrite /routing/v2/hsl/(.*) /otp/$1 break;
proxy_pass http://opentripplanner-hsl-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 11500ms;
}

location = /routing/v2/hsl/health {
rewrite /routing/v2/hsl/(.*) /otp/actuators/$1 break;
proxy_pass http://opentripplanner-hsl-v2:8080/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /routing-data/v2/hsl {
rewrite /routing-data/v2/hsl/(.*) /$1 break;
proxy_pass http://opentripplanner-data-server-hsl:8080/;
Expand Down
48 changes: 20 additions & 28 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ describe('api.digitransit.fi', function() {
});
});

const v1routers = ['finland', 'hsl', 'waltti'];

v1routers.forEach(function(router) {
testProxying('api.digitransit.fi',`/routing/v1/routers/${router}/index/graphql`, `opentripplanner-${router}:8080`);
testResponseHeader('api.digitransit.fi',`/routing-data/v2/${router}/router-config.json`, 'access-control-allow-origin', '*');
testProxying('api.digitransit.fi',`/routing-data/v2/${router}/router-config.json`,`opentripplanner-data-server-${router}:8080`);
});

const v2routers = ['finland', 'hsl', 'waltti', 'waltti-alt', 'varely'];

v2routers.forEach(function(router) {
testProxying('api.digitransit.fi',`/routing/v2/routers/${router}/index/graphql`, `opentripplanner-${router}-v2:8080`);
testProxying('api.digitransit.fi',`/routing/v2/${router}/gtfs/v1`, `opentripplanner-${router}-v2:8080`);
testProxying('api.digitransit.fi',`/routing/v2/${router}/health`, `opentripplanner-${router}-v2:8080`);
testResponseHeader('api.digitransit.fi',`/routing-data/v3/${router}/router-config.json`, 'access-control-allow-origin', '*');
testProxying('api.digitransit.fi',`/routing-data/v3/${router}/router-config.json`,`opentripplanner-data-server-${router}-v3:8080`);
testProxying('api.digitransit.fi',`/map/v3/${router}/en/rental-stations/`, `opentripplanner-${router}-v2:8080`);
});

testProxying('api.digitransit.fi','/geocoding/v1/','pelias-api:8080');
testCaching('api.digitransit.fi','/geocoding/v1/search?digitransit-subscription-key=1234567890&text=porin%20tori', true);
testCaching('api.digitransit.fi', '/geocoding/v1/reverse?digitransit-subscription-key=1234567890&point.lat=60.199284&point.lon=24.940540&size=1', true)
Expand All @@ -154,35 +173,8 @@ describe('api.digitransit.fi', function() {
testProxying('api.digitransit.fi','/map/v2/','hsl-map-server:8080');
testProxying('api.digitransit.fi','/map/v3/hsl-map/','hsl-map-server:8080');
testProxying('api.digitransit.fi','/map/v3/hsl/ticket-sales-map/','hsl-map-server:8080');
testProxying('api.digitransit.fi','/map/v3/hsl/en/rental-stations/','opentripplanner-hsl-v2:8080');
testProxying('api.digitransit.fi','/map/v3/waltti/en/rental-stations/','opentripplanner-waltti-v2:8080');
testProxying('api.digitransit.fi','/map/v3/hsl/fi/stops,stations/tilejson.json','opentripplanner-hsl-v2:8080');
testProxying('api.digitransit.fi','/map/v3/finland/en/rental-stations/','opentripplanner-finland-v2:8080');
testProxying('api.digitransit.fi','/map/v3/varely/en/stops,stations/','opentripplanner-varely-v2:8080');
testProxying('api.digitransit.fi','/map/v3/waltti-alt/en/rental-stations/','opentripplanner-waltti-alt-v2:8080');
testProxying('api.digitransit.fi','/map/v3-kela/kela/en/rental-stations/','opentripplanner-kela-v2:8080');
testProxying('api.digitransit.fi','/routing/v1/routers/finland','opentripplanner-finland:8080');
testProxying('api.digitransit.fi','/routing/v1/routers/hsl','opentripplanner-hsl:8080');
testProxying('api.digitransit.fi','/routing/v1/routers/waltti','opentripplanner-waltti:8080');
testProxying('dev-api.digitransit.fi','/routing/v2/routers/finland','opentripplanner-finland-v2:8080');
testProxying('dev-api.digitransit.fi','/routing/v2/routers/hsl','opentripplanner-hsl-v2:8080');
testProxying('dev-api.digitransit.fi','/routing/v2/routers/waltti','opentripplanner-waltti-v2:8080');
testProxying('dev-api.digitransit.fi','/routing/v2/routers/waltti-alt','opentripplanner-waltti-alt-v2:8080');
testProxying('dev-api.digitransit.fi','/routing/v2-kela/routers/kela','opentripplanner-kela-v2:8080');
testProxying('api.digitransit.fi','/routing-data/v2/hsl/router-hsl.zip','opentripplanner-data-server-hsl:8080');
testResponseHeader('api.digitransit.fi','/routing-data/v2/hsl/router-config.json', 'access-control-allow-origin', '*');
testProxying('api.digitransit.fi','/routing-data/v2/waltti/router-waltti.zip','opentripplanner-data-server-waltti:8080');
testResponseHeader('api.digitransit.fi','/routing-data/v2/waltti/router-config.json', 'access-control-allow-origin', '*');
testProxying('api.digitransit.fi','/routing-data/v2/finland/router-finland.zip','opentripplanner-data-server-finland:8080');
testResponseHeader('api.digitransit.fi','/routing-data/v2/finland/router-config.json', 'access-control-allow-origin', '*');
testProxying('dev-api.digitransit.fi','/routing-data/v3/hsl/router-hsl.zip','opentripplanner-data-server-hsl-v3:8080');
testResponseHeader('dev-api.digitransit.fi','/routing-data/v3/hsl/router-config.json', 'access-control-allow-origin', '*');
testProxying('dev-api.digitransit.fi','/routing-data/v3/waltti/router-waltti.zip','opentripplanner-data-server-waltti-v3:8080');
testResponseHeader('dev-api.digitransit.fi','/routing-data/v3/waltti/router-config.json', 'access-control-allow-origin', '*');
testProxying('dev-api.digitransit.fi','/routing-data/v3/waltti-alt/router-waltti.zip','opentripplanner-data-server-waltti-alt-v3:8080');
testResponseHeader('dev-api.digitransit.fi','/routing-data/v3/waltti-alt/router-config.json', 'access-control-allow-origin', '*');
testProxying('dev-api.digitransit.fi','/routing-data/v3/finland/router-finland.zip','opentripplanner-data-server-finland-v3:8080');
testResponseHeader('dev-api.digitransit.fi','/routing-data/v3/finland/router-config.json', 'access-control-allow-origin', '*');
testProxying('dev-api.digitransit.fi','/routing/v2-kela/routers/kela/index/graphql','opentripplanner-kela-v2:8080');
testProxying('api.digitransit.fi','/ui/v3/matka/sw.js','digitransit-ui-matka-v3:8080');
testProxying('api.digitransit.fi','/ui/v3/hsl/sw.js','digitransit-ui-hsl-v3:8080');
testProxying('api.digitransit.fi','/ui/v3/waltti/sw.js','digitransit-ui-waltti-v3:8080');
Expand Down

0 comments on commit 1bc98a6

Please sign in to comment.