some change
This commit is contained in:
parent
d4a1492d56
commit
313f1def49
38 changed files with 475 additions and 401 deletions
18
src/app/api/client.ts
Normal file
18
src/app/api/client.ts
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue