Skip to content

Commit

Permalink
Use v2 API route for GET services by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Leland Garofalo authored and Leland Garofalo committed Mar 14, 2024
1 parent 5fcffc8 commit bf66bf2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const shouldServiceInheritScheduleFromOrg = (service: Service) =>
* into a nicer-to-use data model of RecurringSchedules.
*/
export const fetchService = (id: string): Promise<Service> =>
get(`/api/services/${id}`).then(({ service }: { service: Service }) => {
get(`/api/v2/services/${id}`).then(({ service }: { service: Service }) => {
const recurringSchedule = shouldServiceInheritScheduleFromOrg(service)
? parseAPISchedule(service.schedule)
: parseAPISchedule(service.resource.schedule);
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,25 @@ services:
# ALGOLIA_API_KEY:
# ALGOLIA_INDEX_PREFIX:

api-go:
image: sheltertechsf/sheltertech-go:latest
networks: [askdarcel]
ports: ["3001:3001"]
depends_on: [db]
environment:
DB_HOST: db
DB_PORT: 5432
DB_NAME: askdarcel_development
DB_USER: postgres

frontend:
image: nginx:stable
networks: [askdarcel]
ports: ["8080:8080"]
depends_on: [api]
environment:
NGINX_API_URL: http://api:3000
NGINX_API_GO_URL: http://api-go:3001
NGINX_PORT: 8080
NGINX_SERVER_NAME: frontend
volumes:
Expand Down
19 changes: 19 additions & 0 deletions docker/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ server {

root /app/askdarcel;

location ~ ^/api/v2/(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

# See https://forum.nginx.org/read.php?2,215830,215832#msg-215832
# nginx only resolves DNS for statically-configured domain names
# once on startup. Since the API is behind an ELB whose IPs may
# change, we must configure nginx to resolve DNS dynamically.
# To do this, we configure a DNS resolver here and use a variable
# rather than a literal URL when configuring the proxy below.
resolver 127.0.0.11;
resolver_timeout 5s;

set $api_url ${NGINX_GO_API_URL};
proxy_pass $api_url/api/$1$is_args$args;
proxy_redirect off;
}

location ~ ^/api/(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down

0 comments on commit bf66bf2

Please sign in to comment.