Skip to content

Commit 2f71a6c

Browse files
authored
fix(env): added getters (#425)
1 parent 7834591 commit 2f71a6c

56 files changed

Lines changed: 297 additions & 89 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/core/components/osf-banners/services/maintenance.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export class MaintenanceService {
1919
/** Injected Angular `HttpClient` for making API requests. */
2020
private readonly http = inject(HttpClient);
2121
private readonly environment = inject(ENVIRONMENT);
22-
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;
22+
23+
get apiUrl() {
24+
return `${this.environment.apiDomainUrl}/v2`;
25+
}
2326

2427
/**
2528
* Fetches the maintenance status from the API and transforms the response.

src/app/core/services/auth.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@ export class AuthService {
1919
private readonly cookieService = inject(CookieService);
2020
private readonly loaderService = inject(LoaderService);
2121
private readonly environment = inject(ENVIRONMENT);
22-
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2/users/`;
23-
private readonly webUrl = this.environment.webUrl;
24-
private readonly casUrl = this.environment.casUrl;
2522
private readonly actions = createDispatchMap({ clearCurrentUser: ClearCurrentUser });
2623

24+
get apiUrl() {
25+
return `${this.environment.apiDomainUrl}/v2/users/`;
26+
}
27+
28+
get webUrl() {
29+
return this.environment.webUrl;
30+
}
31+
32+
get casUrl() {
33+
return this.environment.casUrl;
34+
}
35+
2736
navigateToSignIn(): void {
2837
this.loaderService.show();
2938
const loginUrl = `${this.casUrl}/login?${urlParam({ service: `${this.webUrl}/login` })}`;

src/app/core/services/request-access.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import { JsonApiService } from '@osf/shared/services';
1111
export class RequestAccessService {
1212
private readonly jsonApiService = inject(JsonApiService);
1313
private readonly environment = inject(ENVIRONMENT);
14-
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;
14+
15+
get apiUrl() {
16+
return `${this.environment.apiDomainUrl}/v2`;
17+
}
1518

1619
requestAccessToProject(projectId: string, comment = ''): Observable<void> {
1720
const payload = {

src/app/core/services/user-emails.service.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { JsonApiService } from '@osf/shared/services';
1313
export class UserEmailsService {
1414
private readonly jsonApiService = inject(JsonApiService);
1515
private readonly environment = inject(ENVIRONMENT);
16-
private readonly baseUrl = `${this.environment.apiDomainUrl}/v2/users`;
16+
17+
get apiUrl() {
18+
return `${this.environment.apiDomainUrl}/v2/users`;
19+
}
1720

1821
getEmails(): Observable<AccountEmailModel[]> {
1922
const params: Record<string, string> = {
@@ -22,7 +25,7 @@ export class UserEmailsService {
2225
};
2326

2427
return this.jsonApiService
25-
.get<EmailsResponseJsonApi>(`${this.baseUrl}/me/settings/emails/`, params)
28+
.get<EmailsResponseJsonApi>(`${this.apiUrl}/me/settings/emails/`, params)
2629
.pipe(map((response) => MapEmails(response.data)));
2730
}
2831

@@ -32,7 +35,7 @@ export class UserEmailsService {
3235
};
3336

3437
return this.jsonApiService
35-
.get<EmailResponseJsonApi>(`${this.baseUrl}/me/settings/emails/${emailId}/`, params)
38+
.get<EmailResponseJsonApi>(`${this.apiUrl}/me/settings/emails/${emailId}/`, params)
3639
.pipe(map((response) => MapEmail(response.data)));
3740
}
3841

@@ -55,7 +58,7 @@ export class UserEmailsService {
5558
};
5659

5760
return this.jsonApiService
58-
.post<EmailResponseJsonApi>(`${this.baseUrl}/${userId}/settings/emails/`, body)
61+
.post<EmailResponseJsonApi>(`${this.apiUrl}/${userId}/settings/emails/`, body)
5962
.pipe(map((response) => MapEmail(response.data)));
6063
}
6164

@@ -71,7 +74,7 @@ export class UserEmailsService {
7174
};
7275

7376
return this.jsonApiService
74-
.patch<EmailsDataJsonApi>(`${this.baseUrl}/me/settings/emails/${emailId}/`, body)
77+
.patch<EmailsDataJsonApi>(`${this.apiUrl}/me/settings/emails/${emailId}/`, body)
7578
.pipe(map((response) => MapEmail(response)));
7679
}
7780

@@ -87,11 +90,11 @@ export class UserEmailsService {
8790
};
8891

8992
return this.jsonApiService
90-
.patch<EmailsDataJsonApi>(`${this.baseUrl}/me/settings/emails/${emailId}/`, body)
93+
.patch<EmailsDataJsonApi>(`${this.apiUrl}/me/settings/emails/${emailId}/`, body)
9194
.pipe(map((response) => MapEmail(response)));
9295
}
9396

9497
deleteEmail(emailId: string): Observable<void> {
95-
return this.jsonApiService.delete(`${this.baseUrl}/me/settings/emails/${emailId}/`);
98+
return this.jsonApiService.delete(`${this.apiUrl}/me/settings/emails/${emailId}/`);
9699
}
97100
}

src/app/core/services/user.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import { JsonApiService } from '@shared/services';
2525
export class UserService {
2626
private readonly jsonApiService = inject(JsonApiService);
2727
private readonly environment = inject(ENVIRONMENT);
28-
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;
28+
29+
get apiUrl() {
30+
return `${this.environment.apiDomainUrl}/v2`;
31+
}
2932

3033
getUserById(userId: string): Observable<User> {
3134
return this.jsonApiService

src/app/features/admin-institutions/services/institutions-admin.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ import {
3434
export class InstitutionsAdminService {
3535
private readonly jsonApiService = inject(JsonApiService);
3636
private readonly environment = inject(ENVIRONMENT);
37-
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;
38-
private readonly shareTroveUrl = this.environment.shareTroveUrl;
37+
38+
get apiUrl() {
39+
return `${this.environment.apiDomainUrl}/v2`;
40+
}
41+
42+
get shareTroveUrl() {
43+
return this.environment.shareTroveUrl;
44+
}
3945

4046
fetchDepartments(institutionId: string): Observable<InstitutionDepartment[]> {
4147
return this.jsonApiService

src/app/features/analytics/services/analytics.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import { AnalyticsMetricsGetResponse, AnalyticsMetricsModel, RelatedCountsGetRes
1616
export class AnalyticsService {
1717
private readonly jsonApiService = inject(JsonApiService);
1818
private readonly environment = inject(ENVIRONMENT);
19-
private readonly apiDomainUrl = this.environment.apiDomainUrl;
19+
20+
get apiDomainUrl() {
21+
return this.environment.apiDomainUrl;
22+
}
2023

2124
private readonly urlMap = new Map<ResourceType, string>([
2225
[ResourceType.Project, 'nodes'],

src/app/features/collections/services/add-to-collection.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { JsonApiService } from '@shared/services';
1313
export class AddToCollectionService {
1414
private readonly jsonApiService = inject(JsonApiService);
1515
private readonly environment = inject(ENVIRONMENT);
16-
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;
16+
17+
get apiUrl() {
18+
return `${this.environment.apiDomainUrl}/v2`;
19+
}
1720

1821
fetchCollectionLicenses(providerId: string): Observable<LicenseModel[]> {
1922
return this.jsonApiService

src/app/features/meetings/services/meetings.service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import {
2222
export class MeetingsService {
2323
private readonly jsonApiService = inject(JsonApiService);
2424
private readonly environment = inject(ENVIRONMENT);
25-
private readonly baseUrl = `${this.environment.apiDomainUrl}/_/meetings/`;
25+
26+
get apiUrl() {
27+
return `${this.environment.apiDomainUrl}/_/meetings/`;
28+
}
2629

2730
getAllMeetings(pageNumber: number, pageSize: number, filters: SearchFilters): Observable<MeetingsWithPaging> {
2831
const params: Record<string, unknown> = searchPreferencesToJsonApiQueryParams(
@@ -34,7 +37,7 @@ export class MeetingsService {
3437
);
3538

3639
return this.jsonApiService
37-
.get<ResponseJsonApi<MeetingGetResponseJsonApi[]>>(this.baseUrl, params)
40+
.get<ResponseJsonApi<MeetingGetResponseJsonApi[]>>(this.apiUrl, params)
3841
.pipe(map((response) => MeetingsMapper.fromMeetingsGetResponse(response)));
3942
}
4043

@@ -53,13 +56,13 @@ export class MeetingsService {
5356
);
5457

5558
return this.jsonApiService
56-
.get<ResponseJsonApi<MeetingSubmissionGetResponseJsonApi[]>>(`${this.baseUrl}${meetingId}/submissions/`, params)
59+
.get<ResponseJsonApi<MeetingSubmissionGetResponseJsonApi[]>>(`${this.apiUrl}${meetingId}/submissions/`, params)
5760
.pipe(map((response) => MeetingsMapper.fromMeetingSubmissionGetResponse(response)));
5861
}
5962

6063
getMeetingById(meetingId: string) {
6164
return this.jsonApiService
62-
.get<JsonApiResponse<MeetingGetResponseJsonApi, null>>(this.baseUrl + meetingId)
65+
.get<JsonApiResponse<MeetingGetResponseJsonApi, null>>(this.apiUrl + meetingId)
6366
.pipe(map((response) => MeetingsMapper.fromMeetingGetResponse(response.data)));
6467
}
6568
}

src/app/features/metadata/services/metadata.service.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,19 @@ import { CrossRefFundersResponse, CustomItemMetadataRecord, Metadata } from '../
2727
export class MetadataService {
2828
private readonly jsonApiService = inject(JsonApiService);
2929
private readonly environment = inject(ENVIRONMENT);
30-
private readonly apiDomainUrl = this.environment.apiDomainUrl;
31-
private readonly funderApiUrl = this.environment.funderApiUrl;
32-
private readonly apiUrl = `${this.apiDomainUrl}/v2`;
30+
31+
get apiUrl() {
32+
return `${this.environment.apiDomainUrl}/v2`;
33+
}
34+
35+
get apiDomainUrl() {
36+
return this.environment.apiDomainUrl;
37+
}
38+
39+
get funderApiUrl() {
40+
return this.environment.funderApiUrl;
41+
}
42+
3343
private readonly urlMap = new Map<ResourceType, string>([
3444
[ResourceType.Project, 'nodes'],
3545
[ResourceType.Registration, 'registrations'],

0 commit comments

Comments
 (0)