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> - Use
bunx <package> <command>instead ofnpx <package> <command> - Bun automatically loads .env, so don't use dotenv.
Bun.serve()supports WebSockets, HTTPS, and routes. Don't useexpress.bun:sqlitefor SQLite. Don't usebetter-sqlite3.Bun.redisfor Redis. Don't useioredis.Bun.sqlfor Postgres. Don't usepgorpostgres.js.WebSocketis built-in. Don't usews.- Prefer
Bun.fileovernode:fs's readFile/writeFile - Bun.$
lsinstead of execa.
Use bun test to run tests.
import { test, expect } from "bun:test";
test("hello world", () => {
expect(1).toBe(1);
});This app will use a modular architecture setup:
/project-root
├── /src
│ ├── /core <-- INTERNAL ONLY. The engine room.
│ │ ├── client.ts # The actual HTTP wrapper / Context holder
│ │ ├── config.ts # Validation logic for SDK init
│ │ ├── auth.ts # Token refresh / headers logic
│ │ └── errors.ts # Custom error classes
│ │
│ ├── /modules <-- PUBLIC DOMAINS. Standalone feature sets.
│ │ ├── /users
│ │ │ ├── index.ts # Barrel file for 'users'
│ │ │ ├── list.ts # Functional export: getUsers()
│ │ │ ├── get.ts # Functional export: getUser()
│ │ │ └── types.ts # Types specific to users
│ │ │
│ │ ├── /analytics
│ │ │ ├── index.ts
│ │ │ └── track.ts
│ │
│ ├── /types <-- SHARED TYPES.
│ │ └── index.ts # Common interfaces (ClientOptions, Pagination)
│ │
│ └── index.ts <-- MAIN ENTRY. Exports createClient and types.
│
├── package.json <-- CRITICAL. Defines subpath exports.
├── tsconfig.json
└── tsup.config.ts # (Or rollup/vite) Build configuration
For more information, read the Bun API docs in node_modules/bun-types/docs/**.mdx.