feat: refactor all dashboard routes
This commit is contained in:
parent
50e43bc0c3
commit
6cf343d623
39 changed files with 48 additions and 66 deletions
23
app/routes/util/healthz.ts
Normal file
23
app/routes/util/healthz.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { loadContext } from '~/utils/config/headplane'
|
||||
import { HeadscaleError, pull } from '~/utils/headscale'
|
||||
import { data } from '@remix-run/node'
|
||||
import log from '~/utils/log'
|
||||
|
||||
export async function loader() {
|
||||
const context = await loadContext()
|
||||
|
||||
try {
|
||||
// Doesn't matter, we just need a 401
|
||||
await pull('v1/', 'wrongkey')
|
||||
} catch (e) {
|
||||
if (!(e instanceof HeadscaleError)) {
|
||||
log.debug('Healthz', 'Headscale is not reachable')
|
||||
return data({
|
||||
status: 'NOT OK',
|
||||
error: e.message
|
||||
}, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
return { status: 'OK' }
|
||||
}
|
||||
5
app/routes/util/redirect.ts
Normal file
5
app/routes/util/redirect.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { redirect } from '@remix-run/node'
|
||||
|
||||
export async function loader() {
|
||||
return redirect('/machines')
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue