Skip to content

Commit d69f7d6

Browse files
committed
Merge branch 'main' into profile-and-hostory-pages
2 parents 1f4562d + 33e19d8 commit d69f7d6

39 files changed

+440
-244
lines changed

compose.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ services:
2424
networks:
2525
- gateway-network
2626
restart: always
27+
28+
broker:
29+
container_name: broker
30+
hostname: broker
31+
image: rabbitmq:4.0.2
32+
user: rabbitmq
33+
networks:
34+
- gateway-network
35+
healthcheck:
36+
test: rabbitmq-diagnostics check_port_connectivity
37+
interval: 30s
38+
timeout: 30s
39+
retries: 10
40+
start_period: 30s
41+
restart: always
2742

2843
question:
2944
container_name: question
@@ -123,21 +138,6 @@ services:
123138
- match-db-network
124139
restart: always
125140

126-
broker:
127-
container_name: broker
128-
hostname: broker
129-
image: rabbitmq:4.0.2
130-
user: rabbitmq
131-
networks:
132-
- gateway-network
133-
healthcheck:
134-
test: rabbitmq-diagnostics check_port_connectivity
135-
interval: 30s
136-
timeout: 30s
137-
retries: 10
138-
start_period: 30s
139-
restart: always
140-
141141
collaboration:
142142
container_name: collaboration
143143
image: collaboration

frontend/angular.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@
5151
"development": {
5252
"optimization": false,
5353
"extractLicenses": false,
54-
"sourceMap": true
54+
"sourceMap": true,
55+
"fileReplacements": [
56+
{
57+
"replace": "src/environments/environment.ts",
58+
"with": "src/environments/environment.development.ts"
59+
}
60+
]
5561
}
5662
},
5763
"defaultConfiguration": "production"

frontend/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"codemirror": "^6.0.1",
2626
"primeflex": "^3.3.1",
2727
"primeicons": "^7.0.0",
28-
"primeng": "^17.18.10",
28+
"primeng": "^17.18.11",
2929
"rxjs": "~7.8.0",
3030
"tslib": "^2.3.0",
3131
"typeface-poppins": "^1.1.13",

frontend/src/_interceptors/error.interceptor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export class ErrorInterceptor implements HttpInterceptor {
99
return next.handle(request).pipe(
1010
catchError(err => {
1111
console.error(err);
12-
1312
const errorMessage = err.error.message;
1413
return throwError(() => new Error(errorMessage, { cause: err }));
1514
}),

frontend/src/_interceptors/jwt.interceptor.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HttpTestingController, provideHttpClientTesting } from '@angular/common
33
import { HTTP_INTERCEPTORS, HttpClient } from '@angular/common/http';
44
import { JwtInterceptor } from './jwt.interceptor';
55
import { AuthenticationService } from '../_services/authentication.service';
6-
import { API_CONFIG } from '../app/api.config';
6+
import { environment } from '../environments/environment.development';
77

88
describe('JwtInterceptor', () => {
99
let httpMock: HttpTestingController;
@@ -34,9 +34,9 @@ describe('JwtInterceptor', () => {
3434
});
3535

3636
it('should add an Authorization header', () => {
37-
httpClient.get(`${API_CONFIG.baseUrl}/user/test`).subscribe();
37+
httpClient.get(`${environment.apiUrl}/user/test`).subscribe();
3838

39-
const httpRequest = httpMock.expectOne(`${API_CONFIG.baseUrl}/user/test`);
39+
const httpRequest = httpMock.expectOne(`${environment.apiUrl}/user/test`);
4040

4141
expect(httpRequest.request.headers.has('Authorization')).toBeTruthy();
4242
expect(httpRequest.request.headers.get('Authorization')).toBe('Bearer fake-jwt-token');
@@ -47,9 +47,9 @@ describe('JwtInterceptor', () => {
4747
userValue: {},
4848
});
4949

50-
httpClient.get(`${API_CONFIG.baseUrl}/user/test`).subscribe();
50+
httpClient.get(`${environment.apiUrl}/user/test`).subscribe();
5151

52-
const httpRequest = httpMock.expectOne(`${API_CONFIG.baseUrl}/user/test`);
52+
const httpRequest = httpMock.expectOne(`${environment.apiUrl}/user/test`);
5353

5454
expect(httpRequest.request.headers.has('Authorization')).toBeFalsy();
5555
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface UServRes {
2+
message: string;
3+
data: {
4+
id: string;
5+
username: string;
6+
email: string;
7+
accessToken: string;
8+
isAdmin: boolean;
9+
createdAt: string;
10+
};
11+
}

frontend/src/_services/api.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { API_CONFIG } from '../app/api.config';
1+
import { environment } from '../environments/environment';
22

33
/**
44
* Abstract class that serves as a base for API services.
@@ -16,6 +16,6 @@ export abstract class ApiService {
1616
* the specified apiPath.
1717
*/
1818
get apiUrl(): string {
19-
return API_CONFIG.baseUrl + this.apiPath;
19+
return environment.apiUrl + this.apiPath;
2020
}
2121
}

frontend/src/_services/authentication.service.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,29 @@ export class AuthenticationService extends ApiService {
8484
this.userSubject.next(null);
8585
this.router.navigate(['/account/login']);
8686
}
87+
88+
// get user details from user service for authentication
89+
getUserDetails() {
90+
return this.http.get<UServRes>(`${this.apiUrl}/users/${this.userValue?.id}`, { observe: 'response' }).pipe(
91+
map(response => {
92+
if (response.status === 200) {
93+
let user: User = {} as User;
94+
if (response.body) {
95+
const body: UServRes = response.body;
96+
const data = body.data;
97+
user = {
98+
id: data.id,
99+
username: data.username,
100+
email: data.email,
101+
accessToken: data.accessToken,
102+
isAdmin: data.isAdmin,
103+
createdAt: data.createdAt,
104+
};
105+
}
106+
return user;
107+
}
108+
return null;
109+
}),
110+
);
111+
}
87112
}

frontend/src/app/api.config.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)