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
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:
parent
006ae81c3b
commit
a48aad974a
6 changed files with 50 additions and 9 deletions
|
|
@ -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) }),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue