??? I have a basic idea of the functionality that I need and the topics that I still need to learn about 21-03-2022 Learning about context driven patterns in Go
useTheme.ts
import { ref, watchEffect } from 'vue'
type Theme = 'light' | 'dark' | 'system'
const theme = ref<Theme>('system')
export function useTheme() {
const setTheme = (value: Theme) => {
theme.value = value
localStorage.setItem('theme', value)
}
watchEffect(() => {
const root = document.documentElement
root.classList.toggle('dark', theme.value === 'dark')
})
return { theme, setTheme }
}
package main
import (
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/health", healthCheck)
log.Println("listening on :8080")
if err := http.ListenAndServe(":8080", mux); err != nil {
log.Fatal(err)
}
}
use axum::{extract::State, Json};
/// Liveness probe for the load balancer.
pub async fn health(State(db): State<PgPool>) -> Json<Status> {
let ok = db.ping().await.is_ok();
Json(Status { db: ok, uptime: uptime() })
}
{
"name": "acme-api",
"port": 8080,
"features": ["health", "metrics"],
"debug": false
}
Terminal
$ acme deploy --env production
> built 42 modules
> deployed to https://api.acme.dev