MaCH repo

This commit is contained in:
2025-07-24 12:46:01 -05:00
committed by Nick Ricketts
commit db42820cfb
78 changed files with 4726 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
#include <mach.h>
#include <htmx.h>
#include <sqlite.h>
#include <tailwind.h>
mach(){
sqlite_database(
.name = "pokemon_db",
.connect = "file::memory:?cache=shared",
.migrations = {"create_pokemons_table"}
);
resource("home", "/",
.get = {
sqlite_query({"pokemon_db", "get_challengers", "challengers"}),
exec(^(){
auto const t = get("challengers");
auto const p0 = table_get(t, 0);
auto const p1 = table_get(t, 1);
record_set(p0, "opponent_id", record_get(p1, "id"));
record_set(p1, "opponent_id", record_get(p0, "id"));
}),
mustache("home")
},
.post = {
input(
{"winner", m_positive},
{"loser", m_positive}
),
sqlite_query({"pokemon_db", "vote"}),
reroute("home")
}
);
resource("result", "/results",
.get = {
sqlite_query({"pokemon_db", "get_results", "results"}),
mustache("results")
}
);
}