some change

This commit is contained in:
john 2025-05-16 16:09:35 +02:00
parent d4a1492d56
commit 313f1def49
38 changed files with 475 additions and 401 deletions

18
src/app/api/client.ts Normal file
View file

@ -0,0 +1,18 @@
import { paths } from './schema.ts'
import createClient, { Middleware } from 'openapi-fetch'
import { dispatchMessage } from '../messageBus/messageBus.ts'
const client = createClient<paths>({ baseUrl: `${location.protocol}//${location.hostname}:5181` })
const UnauthorizedHandlerMiddleware: Middleware = {
async onResponse({ response }) {
if (response.status === 401) {
dispatchMessage('auth:unauthorized', null)
}
},
}
client.use(UnauthorizedHandlerMiddleware)
// todo inject this if necessary
export default client