7bed571ffa
api: WS gateway with token auth (Postgres-backed servers table, seeded via `bun run seed`), column-granularity chunk store (hand-written SQL migrations, no drizzle-kit CLI — its config loader needs esbuild, which doesn't install cleanly here), dirty-chunk Redis stream producer with per-flush dedup, and a tile-serving route. worker: consumes the dirty-chunk stream via a proper consumer group, rasterizes each chunk's columns into a single-resolution top-down PNG (static pre-Flattening block-id palette), uploads to MinIO, and upserts the tile pointer. frontend: barebones Leaflet 2D viewer (CRS.Simple, one native zoom level) wired to /api/servers and /api/tiles. Object storage: tiles live in a dedicated `mcmapper-tiles` bucket on the existing shared MinIO instance (devstack-minio on octo-winsrv) instead of a per-stack container, via a scoped access key limited to that one bucket — see README's "Object storage" section. MINIO_SECRET_KEY is real and is deliberately not committed; docker-compose layers an untracked .env over .env.example for it. Full pipeline verified end-to-end against live containers: WS auth -> Postgres upsert -> deduped Redis dirty-chunk event -> worker rasterize -> MinIO upload -> tile fetch through the api route, including from the actual mod-side WS client (see MCMapper-Mod's matching commit).
31 lines
1019 B
TypeScript
31 lines
1019 B
TypeScript
import { db } from "../src/db/client";
|
|
import { servers } from "../src/db/schema";
|
|
import { sql } from "../src/db/client";
|
|
|
|
// Phase 6 will add a real admin registration API/UI. Until then, Phase 1 needs at least one
|
|
// server row to hand a token to the mod — run with MCMAPPER_SEED_SERVER_NAME/_TOKEN set.
|
|
async function main() {
|
|
const name = process.env.MCMAPPER_SEED_SERVER_NAME;
|
|
const token = process.env.MCMAPPER_SEED_SERVER_TOKEN;
|
|
const authMode = process.env.MCMAPPER_SEED_SERVER_AUTH_MODE ?? "offline";
|
|
|
|
if (!name || !token) {
|
|
console.error("[seed] set MCMAPPER_SEED_SERVER_NAME and MCMAPPER_SEED_SERVER_TOKEN");
|
|
process.exit(1);
|
|
}
|
|
|
|
const [row] = await db
|
|
.insert(servers)
|
|
.values({ name, token, authMode })
|
|
.onConflictDoUpdate({ target: servers.token, set: { name, authMode } })
|
|
.returning();
|
|
|
|
console.log(`[seed] server ready: id=${row.id} name=${row.name}`);
|
|
await sql.end();
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error("[seed] failed:", err);
|
|
process.exit(1);
|
|
});
|