Skip to content

Commit 64f861b

Browse files
Improve API endpoint config
1 parent c70efec commit 64f861b

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

browser/src/app/config/api.config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ export const API_CONFIG = {
77

88
endpoints: {
99
// Search Engine Results Page
10-
serps: '/api/serps',
11-
serp: (serpId: string) => `/api/serps/${serpId}`,
12-
serpsPreview: '/api/serps/preview',
10+
serps: '/serps',
11+
serp: (serpId: string) => `/serps/${serpId}`,
12+
serpsPreview: '/serps/preview',
1313
// Providers
14-
providers: '/api/providers',
15-
provider: (providerId: string) => `/api/providers/${providerId}`,
16-
providerStatistics: (providerId: string) => `/api/providers/${providerId}/statistics`,
14+
providers: '/providers',
15+
provider: (providerId: string) => `/providers/${providerId}`,
16+
providerStatistics: (providerId: string) => `/providers/${providerId}/statistics`,
1717
// Archives
18-
archives: '/api/archives',
19-
archive: (archiveId: string) => `/api/archives/${archiveId}`,
20-
archiveStatistics: (archiveId: string) => `/api/archives/${archiveId}/statistics`,
18+
archives: '/archives',
19+
archive: (archiveId: string) => `/archives/${archiveId}`,
20+
archiveStatistics: (archiveId: string) => `/archives/${archiveId}/statistics`,
2121
},
2222
} as const;

browser/src/app/pages/compare-page/compare-page.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class ComparePageComponent {
6363

6464
const idsParam = ids.join(',');
6565
return this.http
66-
.get<CompareApiResponse>(`${environment.apiUrl}/api/serps/compare`, {
66+
.get<CompareApiResponse>(`${environment.apiUrl}/serps/compare`, {
6767
params: { ids: idsParam },
6868
})
6969
.pipe(

browser/src/app/services/provider.service.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('ProviderService', () => {
4444
done();
4545
});
4646

47-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers`);
47+
const req = httpMock.expectOne(`${environment.apiUrl}/providers`);
4848
expect(req.request.method).toBe('GET');
4949
req.flush(mockApiResponse);
5050
});
@@ -57,7 +57,7 @@ describe('ProviderService', () => {
5757
done();
5858
});
5959

60-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers`);
60+
const req = httpMock.expectOne(`${environment.apiUrl}/providers`);
6161
req.flush(mockApiResponse);
6262
});
6363

@@ -72,7 +72,7 @@ describe('ProviderService', () => {
7272
});
7373

7474
// Only one request should be made
75-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers`);
75+
const req = httpMock.expectOne(`${environment.apiUrl}/providers`);
7676
req.flush(mockApiResponse);
7777
});
7878

@@ -82,7 +82,7 @@ describe('ProviderService', () => {
8282
done();
8383
});
8484

85-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers`);
85+
const req = httpMock.expectOne(`${environment.apiUrl}/providers`);
8686
req.error(new ErrorEvent('Network error'));
8787
});
8888

@@ -97,11 +97,11 @@ describe('ProviderService', () => {
9797
done();
9898
});
9999

100-
const req2 = httpMock.expectOne(`${environment.apiUrl}/api/providers`);
100+
const req2 = httpMock.expectOne(`${environment.apiUrl}/providers`);
101101
req2.flush(mockApiResponse);
102102
});
103103

104-
const req1 = httpMock.expectOne(`${environment.apiUrl}/api/providers`);
104+
const req1 = httpMock.expectOne(`${environment.apiUrl}/providers`);
105105
req1.flush(mockApiResponse);
106106
});
107107

@@ -118,7 +118,7 @@ describe('ProviderService', () => {
118118
done();
119119
});
120120

121-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers`);
121+
const req = httpMock.expectOne(`${environment.apiUrl}/providers`);
122122
req.flush(mockApiResponse);
123123
});
124124

@@ -147,7 +147,7 @@ describe('ProviderService', () => {
147147
done();
148148
});
149149

150-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers/google`);
150+
const req = httpMock.expectOne(`${environment.apiUrl}/providers/google`);
151151
expect(req.request.method).toBe('GET');
152152
req.flush(mockProviderDetailResponse);
153153
});
@@ -158,7 +158,7 @@ describe('ProviderService', () => {
158158
done();
159159
});
160160

161-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers/unknown`);
161+
const req = httpMock.expectOne(`${environment.apiUrl}/providers/unknown`);
162162
req.error(new ErrorEvent('Network error'));
163163
});
164164

@@ -183,7 +183,7 @@ describe('ProviderService', () => {
183183
done();
184184
});
185185

186-
const req = httpMock.expectOne(`${environment.apiUrl}/api/providers/minimal`);
186+
const req = httpMock.expectOne(`${environment.apiUrl}/providers/minimal`);
187187
req.flush(minimalResponse);
188188
});
189189
});

browser/src/app/services/suggestions.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('SuggestionsService', () => {
183183

184184
// We should only call the search API once for the input
185185
expect(mockApiService.get).toHaveBeenCalledTimes(1);
186-
expect(mockApiService.get).toHaveBeenCalledWith('/api/serps', {
186+
expect(mockApiService.get).toHaveBeenCalledWith('/serps', {
187187
query: 'test3',
188188
size: 5,
189189
});
@@ -351,7 +351,7 @@ describe('SuggestionsService', () => {
351351
tick(service.DEBOUNCE_TIME_MS);
352352
flushMicrotasks();
353353

354-
expect(mockApiService.get).toHaveBeenCalledWith('/api/serps', {
354+
expect(mockApiService.get).toHaveBeenCalledWith('/serps', {
355355
query: 'search term',
356356
size: 5,
357357
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const environment = {
22
production: true,
33
// Assume that both the API and web app are routed on the same hostname.
4-
apiUrl: '',
4+
apiUrl: '/api',
55
apiTimeout: 60000,
66
};

0 commit comments

Comments
 (0)