Web UI setup
This commit is contained in:
parent
3d823dedd8
commit
682ca6bb20
19 changed files with 6026 additions and 2 deletions
13
web/src/app.d.ts
vendored
Normal file
13
web/src/app.d.ts
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
11
web/src/app.html
Normal file
11
web/src/app.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
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