mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
feat: add createSearchSpace endpoint to API service
This commit is contained in:
parent
c43cd16dab
commit
f983d1f7ff
1 changed files with 21 additions and 0 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
import {
|
import {
|
||||||
|
type CreateSearchSpaceRequest,
|
||||||
type GetSearchSpacesRequest,
|
type GetSearchSpacesRequest,
|
||||||
|
createSearchSpaceRequest,
|
||||||
|
createSearchSpaceResponse,
|
||||||
getSearchSpacesRequest,
|
getSearchSpacesRequest,
|
||||||
getSearchSpacesResponse,
|
getSearchSpacesResponse,
|
||||||
} from "@/contracts/types/search-space.types";
|
} from "@/contracts/types/search-space.types";
|
||||||
|
|
@ -35,6 +38,24 @@ class SearchSpacesApiService {
|
||||||
|
|
||||||
return baseApiService.get(`/api/v1/searchspaces?${queryParams}`, getSearchSpacesResponse);
|
return baseApiService.get(`/api/v1/searchspaces?${queryParams}`, getSearchSpacesResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new search space
|
||||||
|
*/
|
||||||
|
createSearchSpace = async (request: CreateSearchSpaceRequest) => {
|
||||||
|
const parsedRequest = createSearchSpaceRequest.safeParse(request);
|
||||||
|
|
||||||
|
if (!parsedRequest.success) {
|
||||||
|
console.error("Invalid request:", parsedRequest.error);
|
||||||
|
|
||||||
|
const errorMessage = parsedRequest.error.errors.map((err) => err.message).join(", ");
|
||||||
|
throw new ValidationError(`Invalid request: ${errorMessage}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseApiService.post(`/api/v1/searchspaces`, createSearchSpaceResponse, {
|
||||||
|
body: parsedRequest.data,
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const searchSpacesApiService = new SearchSpacesApiService();
|
export const searchSpacesApiService = new SearchSpacesApiService();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue