1.5 KiB
1.5 KiB
Default to using Bun instead of Node.js.
- Use
bun <file>instead ofnode <file>orts-node <file> - Use
bun testinstead ofjestorvitest - Use
bun build <file.html|file.ts|file.css>instead ofwebpackoresbuild - Use
bun installinstead ofnpm installoryarn installorpnpm install - Use
bun run <script>instead ofnpm run <script>oryarn run <script>orpnpm run <script> - Bun automatically loads .env, so don't use dotenv.
APIs
Bun.serve()supports WebSockets, HTTPS, and routes. Don't useexpress.bun:sqlitefor SQLite. Don't usebetter-sqlite3.memjsfor Memcached. Memcached has no built-in Bun client.Bun.sqlfor Postgres. Don't usepgorpostgres.js.WebSocketis built-in. Don't usews.- Prefer
Bun.fileovernode:fs's readFile/writeFile - Bun.$
lsinstead 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 Objektplayer:{id}:weapon/:armor/:talisman-> JSON Array mit item_idsitem:{id},enemy:{id},region:{id}-> JSON Objektregion:{id}:items/:enemies,enemy:{id}:items-> JSON Array mit idsweapon:{id},armor:{id},shield:{id},talisman:{id},item_effect:{id},item_type:{id}-> JSON Objekt
Coding Style Preferences
- Write everything WITHOUT comments.