Support subpath
All checks were successful
CI / Backend tests (push) Successful in 30s
CI / Frontend lint (push) Successful in 33s
CI / Frontend build (push) Successful in 25s
CI / Frontend unit tests (push) Successful in 1m6s
CI / Playwright e2e (push) Successful in 1m43s
Docker / build-and-push (push) Successful in 2m30s

This commit is contained in:
Andras Schmelczer 2026-05-31 20:27:41 +01:00
commit a48aad974a
6 changed files with 50 additions and 9 deletions

View file

@ -8,24 +8,24 @@ export class ApiService {
private readonly http = inject(HttpClient);
health(): Promise<{ status: string }> {
return firstValueFrom(this.http.get<{ status: string }>('/api/v1/health'));
return firstValueFrom(this.http.get<{ status: string }>('api/v1/health'));
}
register(token: string): Promise<{ user_id: string }> {
return firstValueFrom(
this.http.post<{ user_id: string }>('/api/v1/register', { token }),
this.http.post<{ user_id: string }>('api/v1/register', { token }),
);
}
getData(token: string): Promise<TreeDto> {
return firstValueFrom(
this.http.get<TreeDto>('/api/v1/data', { headers: this.authHeaders(token) }),
this.http.get<TreeDto>('api/v1/data', { headers: this.authHeaders(token) }),
);
}
async putData(token: string, tree: TreeDto): Promise<void> {
await firstValueFrom(
this.http.put('/api/v1/data', tree, { headers: this.authHeaders(token) }),
this.http.put('api/v1/data', tree, { headers: this.authHeaders(token) }),
);
}

View file

@ -24,7 +24,7 @@ describe('ApiService', () => {
it('gets data with a bearer token', async () => {
const tree: TreeDto = { pages: [] };
const promise = service.getData('token-1');
const req = http.expectOne('/api/v1/data');
const req = http.expectOne('api/v1/data');
expect(req.request.method).toBe('GET');
expect(req.request.headers.get('Authorization')).toBe('Bearer token-1');
req.flush(tree);
@ -34,7 +34,7 @@ describe('ApiService', () => {
it('puts data with a bearer token', async () => {
const tree: TreeDto = { pages: [] };
const promise = service.putData('token-1', tree);
const req = http.expectOne('/api/v1/data');
const req = http.expectOne('api/v1/data');
expect(req.request.method).toBe('PUT');
expect(req.request.headers.get('Authorization')).toBe('Bearer token-1');
expect(req.request.body).toBe(tree);