style: eslint changes

This commit is contained in:
Aarnav Tale 2024-05-15 21:54:40 -04:00
parent 37a31e30c7
commit 2f02ccc362
No known key found for this signature in database
2 changed files with 114 additions and 117 deletions

View File

@ -1,122 +1,121 @@
import { type Document, parse, parseDocument } from 'yaml'
import { type FSWatcher, watch } from 'node:fs' import { type FSWatcher, watch } from 'node:fs'
import { access, constants, readFile, writeFile } from 'node:fs/promises' import { access, constants, readFile, writeFile } from 'node:fs/promises'
import { resolve } from 'node:path' import { resolve } from 'node:path'
import { type Document, parse, parseDocument } from 'yaml'
type Duration = `${string}s` | `${string}h` | `${string}m` | `${string}d` | `${string}y` type Duration = `${string}s` | `${string}h` | `${string}m` | `${string}d` | `${string}y`
type Config = { interface Config {
server_url: string; server_url: string
listen_addr: string; listen_addr: string
metrics_listen_addr: string; metrics_listen_addr: string
grpc_listen_addr: string; grpc_listen_addr: string
grpc_allow_insecure: boolean; grpc_allow_insecure: boolean
private_key_path: string; private_key_path: string
noise: { noise: {
private_key_path: string; private_key_path: string
}; }
prefixes: { prefixes: {
v4: string; v4: string
v6: string; v6: string
}; }
derp: { derp: {
server: { server: {
enabled: boolean; enabled: boolean
region_id: number; region_id: number
region_code: string; region_code: string
region_name: string; region_name: string
stun_listen_addr: string; stun_listen_addr: string
}; }
urls: string[]; urls: string[]
paths: string[]; paths: string[]
auto_update_enabled: boolean; auto_update_enabled: boolean
update_frequency: Duration; update_frequency: Duration
}; }
disable_check_updates: boolean; disable_check_updates: boolean
epheremal_node_inactivity_timeout: Duration; epheremal_node_inactivity_timeout: Duration
node_update_check_interval: Duration; node_update_check_interval: Duration
// Database is probably dangerous // Database is probably dangerous
database: { database: {
type: 'sqlite3' | 'sqlite' | 'postgres'; type: 'sqlite3' | 'sqlite' | 'postgres'
sqlite?: { sqlite?: {
path: string; path: string
}; }
postgres?: { postgres?: {
host: string; host: string
port: number; port: number
name: string; name: string
user: string; user: string
pass: string; pass: string
max_open_conns: number; max_open_conns: number
max_idle_conns: number; max_idle_conns: number
conn_max_idle_time_secs: number; conn_max_idle_time_secs: number
ssl: boolean; ssl: boolean
}; }
}; }
acme_url: string; acme_url: string
acme_email: string; acme_email: string
tls_letsencrypt_hostname: string; tls_letsencrypt_hostname: string
tls_letsencrypt_cache_dir: string; tls_letsencrypt_cache_dir: string
tls_letsencrypt_challenge_type: string; tls_letsencrypt_challenge_type: string
tls_letsencrypt_listen: string; tls_letsencrypt_listen: string
tls_cert_path: string; tls_cert_path: string
tls_key_path: string; tls_key_path: string
log: { log: {
format: 'text' | 'json'; format: 'text' | 'json'
level: string; level: string
}; }
acl_policy_path: string; acl_policy_path: string
dns_config: { dns_config: {
override_local_dns: boolean; override_local_dns: boolean
nameservers: string[]; nameservers: string[]
restricted_nameservers: Record<string, string[]>; // Split DNS restricted_nameservers: Record<string, string[]> // Split DNS
domains: string[]; domains: string[]
extra_records: Array<{ extra_records: {
name: string; name: string
type: 'A'; type: 'A'
value: string; value: string
}>; }[]
magic_dns: boolean; magic_dns: boolean
base_domain: string; base_domain: string
}; }
unix_socket: string; unix_socket: string
unix_socket_permission: string; unix_socket_permission: string
oidc: { oidc: {
only_start_if_oidc_is_available: boolean; only_start_if_oidc_is_available: boolean
issuer: string; issuer: string
client_id: string; client_id: string
client_secret: string; client_secret: string
expiry: Duration; expiry: Duration
use_expiry_from_token: boolean; use_expiry_from_token: boolean
scope: string[]; scope: string[]
extra_params: Record<string, string>; extra_params: Record<string, string>
allowed_domains: string[]; allowed_domains: string[]
allowed_groups: string[]; allowed_groups: string[]
allowed_users: string[]; allowed_users: string[]
strip_email_domain: boolean; strip_email_domain: boolean
}; }
logtail: { logtail: {
enabled: boolean; enabled: boolean
}; }
randomize_client_port: boolean; randomize_client_port: boolean
} }
let config: Document let config: Document
@ -196,18 +195,18 @@ export function registerConfigWatcher() {
}) })
} }
export type Context = { export interface Context {
hasDockerSock: boolean; hasDockerSock: boolean
hasConfig: boolean; hasConfig: boolean
hasConfigWrite: boolean; hasConfigWrite: boolean
hasAcl: boolean; hasAcl: boolean
hasAclWrite: boolean; hasAclWrite: boolean
headscaleUrl: string; headscaleUrl: string
oidcConfig?: { oidcConfig?: {
issuer: string; issuer: string
client: string; client: string
secret: string; secret: string
}; }
} }
export let context: Context export let context: Context
@ -221,7 +220,7 @@ export async function getContext() {
hasAcl: await hasAcl(), hasAcl: await hasAcl(),
hasAclWrite: await hasAclW(), hasAclWrite: await hasAclW(),
headscaleUrl: await getHeadscaleUrl(), headscaleUrl: await getHeadscaleUrl(),
oidcConfig: await getOidcConfig() oidcConfig: await getOidcConfig(),
} }
} }
@ -237,9 +236,9 @@ async function getOidcConfig() {
if (!issuer || !client || !secret) { if (!issuer || !client || !secret) {
const config = await getConfig() const config = await getConfig()
issuer = config.oidc?.issuer issuer = config.oidc.issuer
client = config.oidc?.client_id client = config.oidc.client_id
secret = config.oidc?.client_secret secret = config.oidc.client_secret
} }
// If atleast one is defined but not all 3, throw an error // If atleast one is defined but not all 3, throw an error
@ -352,4 +351,3 @@ async function hasAclW() {
return false return false
} }

View File

@ -10,36 +10,35 @@ export default {
container: { container: {
center: true, center: true,
padding: { padding: {
DEFAULT: '1rem', 'DEFAULT': '1rem',
sm: '2rem', 'sm': '2rem',
lg: '4rem', 'lg': '4rem',
xl: '5rem', 'xl': '5rem',
'2xl': '6rem' '2xl': '6rem',
} },
}, },
extend: { extend: {
height: { height: {
editor: 'calc(100vh - 20rem)' editor: 'calc(100vh - 20rem)',
}, },
colors: { colors: {
main: colors.slate, main: colors.slate,
ui: colors.neutral ui: colors.neutral,
}, },
keyframes: { keyframes: {
loader: { loader: {
from: { from: {
transform: 'translateX(-100%)' transform: 'translateX(-100%)',
}, },
to: { to: {
transform: 'translateX(100%)' transform: 'translateX(100%)',
} },
} },
}, },
animation: { animation: {
loading: 'loader 0.8s infinite ease-in-out' loading: 'loader 0.8s infinite ease-in-out',
} },
} },
}, },
plugins: [animate, aria] plugins: [animate, aria],
} satisfies Config } satisfies Config