chore: Cleanup

This commit is contained in:
Tibo De Peuter 2025-04-20 20:48:06 +02:00
parent 2d5988552f
commit b24f577975
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
6 changed files with 30 additions and 16 deletions

View file

@ -12,7 +12,7 @@
"format": "prettier --write src/",
"format-check": "prettier --check src/",
"lint": "eslint . --fix",
"test:unit": "vitest --run",
"test:unit": "VITE_API_BASE_URL='http://localhost:9876/api' vitest --run",
"test:e2e": "playwright test"
},
"dependencies": {

View file

@ -1,6 +1,7 @@
import apiClient from "@/services/api-client/api-client.ts";
import type { AxiosResponse, ResponseType } from "axios";
import { HttpErrorResponseException } from "@/exception/http-error-response-exception.ts";
import { apiConfig } from '@/config.ts';
export abstract class BaseController {
protected basePath: string;
@ -16,9 +17,16 @@ export abstract class BaseController {
}
protected async get<T>(path: string, queryParams?: QueryParams, responseType?: ResponseType): Promise<T> {
const response = await apiClient.get<T>(this.absolutePathFor(path), { params: queryParams, responseType });
BaseController.assertSuccessResponse(response);
return response.data;
try {
const response = await apiClient.get<T>(this.absolutePathFor(path), { params: queryParams, responseType });
BaseController.assertSuccessResponse(response);
return response.data;
} catch (error) {
if (error instanceof HttpErrorResponseException) {
throw error;
}
throw new Error(`An unexpected error occurred while fetching data from ${apiConfig.baseUrl}${this.absolutePathFor(path)}: ${error}`);
}
}
protected async post<T>(path: string, body: unknown, queryParams?: QueryParams): Promise<T> {

View file

@ -22,7 +22,7 @@ export async function setup(): Promise<void> {
});
// Spin up the backend
backendProcess = spawn("tsx", ["--env-file=.env.development.example", "tool/startTestApp.ts"], {
backendProcess = spawn("tsx", ["--env-file=.env.test", "tool/startTestApp.ts"], {
cwd: "../backend",
stdio: "inherit",
env: {