fix: 🚚 remove alias and cleanup
This commit is contained in:
parent
c629b1b682
commit
83fbc483f0
@ -42,20 +42,6 @@ async def check_auth(
|
||||
return credentials
|
||||
|
||||
|
||||
class AuthStaticFiles(StaticFiles):
|
||||
async def __call__(
|
||||
self, scope: types.Scope, receive: types.Receive, send: types.Send
|
||||
) -> None:
|
||||
request = Request(scope, receive)
|
||||
credentials = await security(request)
|
||||
|
||||
if not credentials:
|
||||
raise http_401()
|
||||
|
||||
await check_auth(credentials)
|
||||
await super().__call__(scope, receive, send)
|
||||
|
||||
|
||||
app = FastAPI(dependencies=[Depends(check_auth)])
|
||||
|
||||
|
||||
@ -66,7 +52,6 @@ class SerializedContainer(BaseModel):
|
||||
labels: dict[str, str]
|
||||
status: str
|
||||
health: str
|
||||
ports: dict[str, str]
|
||||
owner: str | None
|
||||
environment: list[str]
|
||||
|
||||
@ -79,7 +64,6 @@ def serialize_container(container: Container) -> SerializedContainer:
|
||||
labels=container.labels,
|
||||
status=container.status,
|
||||
health=container.health,
|
||||
ports=container.ports,
|
||||
owner=container.labels.get("owner"),
|
||||
environment=container.attrs["Config"]["Env"],
|
||||
)
|
||||
@ -182,6 +166,20 @@ def update_container(
|
||||
)
|
||||
|
||||
|
||||
class AuthStaticFiles(StaticFiles):
|
||||
async def __call__(
|
||||
self, scope: types.Scope, receive: types.Receive, send: types.Send
|
||||
) -> None:
|
||||
request = Request(scope, receive)
|
||||
credentials = await security(request)
|
||||
|
||||
if not credentials:
|
||||
raise http_401()
|
||||
|
||||
await check_auth(credentials)
|
||||
await super().__call__(scope, receive, send)
|
||||
|
||||
|
||||
app.mount(
|
||||
"/",
|
||||
AuthStaticFiles(
|
||||
|
@ -6,7 +6,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Message from '@/components/Message.vue'
|
||||
import Message from './Message.vue'
|
||||
|
||||
export default {
|
||||
name: 'Loading',
|
||||
|
@ -2,7 +2,7 @@ import 'bulma/css/bulma.min.css'
|
||||
import 'font-awesome/css/font-awesome.min.css'
|
||||
import App from './App.vue'
|
||||
import { createApp } from 'vue'
|
||||
import router from './router.ts'
|
||||
import router from './router'
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(router)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import Container from './views/Container.vue'
|
||||
import Home from './views/Home.vue'
|
||||
import Container from '../views/Container.vue'
|
||||
import Home from '../views/Home.vue'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
10
frontend/types.ts
Normal file
10
frontend/types.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export interface Container {
|
||||
id: number
|
||||
name: string | null
|
||||
image: string | null
|
||||
labels: Record<string, string>
|
||||
status: string
|
||||
health: string
|
||||
owner: string
|
||||
environment: string[]
|
||||
}
|
@ -19,8 +19,9 @@
|
||||
|
||||
<script lang="ts">
|
||||
import axios, { AxiosError } from 'axios'
|
||||
import Icon from '@/components/Icon.vue'
|
||||
import Loading from '@/components/Loading.vue'
|
||||
import type { Container } from '../types'
|
||||
import Icon from '../components/Icon.vue'
|
||||
import Loading from '../components/Loading.vue'
|
||||
|
||||
export default {
|
||||
name: 'Home',
|
||||
@ -30,14 +31,14 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
containers: [],
|
||||
containers: [] as Container[],
|
||||
error: '',
|
||||
loading: true,
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
const response = await axios.get('/api/containers')
|
||||
const response = await axios.get<Container[]>('/api/containers')
|
||||
this.containers = response.data
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
@ -5,9 +5,5 @@
|
||||
"composite": true,
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["frontend/*"]
|
||||
},
|
||||
"allowImportingTsExtensions": true,
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,8 @@
|
||||
import { URL, fileURLToPath } from 'node:url'
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./frontend', import.meta.url)),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: 'backend/dist',
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user