Web UI setup
This commit is contained in:
parent
c56fc2e6d5
commit
0889dce85b
19 changed files with 6026 additions and 2 deletions
30
web/src/lib/hey-api.ts
Normal file
30
web/src/lib/hey-api.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import type { CreateClientConfig } from "./api/client.gen";
|
||||
|
||||
export class NotAuthorizedError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = "NotAuthorizedError";
|
||||
}
|
||||
}
|
||||
|
||||
async function customFetch(url: string, init: RequestInit): Promise<Response> {
|
||||
const response = await fetch(url, init);
|
||||
|
||||
if (response.status === 400) {
|
||||
const json = await response.json();
|
||||
if (
|
||||
json.error ==
|
||||
"error in openapi3filter.SecurityRequirementsError: security requirements failed: invalid session"
|
||||
) {
|
||||
throw new NotAuthorizedError(json.error.substring(80));
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export const createClientConfig: CreateClientConfig = (config) => ({
|
||||
...config,
|
||||
baseUrl: "/api/",
|
||||
fetch: customFetch,
|
||||
});
|
||||
1
web/src/lib/index.ts
Normal file
1
web/src/lib/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
// place files you want to import through the `$lib` alias in this folder.
|
||||
Loading…
Add table
Add a link
Reference in a new issue