2026-07-07 16:59:54 +02:00

1.5 KiB

Default to using Bun instead of Node.js.

  • Use bun <file> instead of node <file> or ts-node <file>
  • Use bun test instead of jest or vitest
  • Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild
  • Use bun install instead of npm install or yarn install or pnpm install
  • Use bun run <script> instead of npm run <script> or yarn run <script> or pnpm run <script>
  • Bun automatically loads .env, so don't use dotenv.

APIs

  • Bun.serve() supports WebSockets, HTTPS, and routes. Don't use express.
  • bun:sqlite for SQLite. Don't use better-sqlite3.
  • memjs for Memcached. Memcached has no built-in Bun client.
  • Bun.sql for Postgres. Don't use pg or postgres.js.
  • WebSocket is built-in. Don't use ws.
  • Prefer Bun.file over node:fs's readFile/writeFile
  • Bun.$ls instead of execa.

Datenmodell (Memcached)

Memcached kennt keine Hashes oder Sets, nur reine Key-Value-Paare. Jedes Objekt wird deshalb unter einem flachen Key als JSON-String abgelegt. Listen (z.B. die Items einer Region) landen als JSON-Array im Value unter einem eigenen Key.

  • player:{id} -> JSON Objekt
  • player:{id}:weapon / :armor / :talisman -> JSON Array mit item_ids
  • item:{id}, enemy:{id}, region:{id} -> JSON Objekt
  • region:{id}:items / :enemies, enemy:{id}:items -> JSON Array mit ids
  • weapon:{id}, armor:{id}, shield:{id}, talisman:{id}, item_effect:{id}, item_type:{id} -> JSON Objekt

Coding Style Preferences

  • Write everything WITHOUT comments.