···11+22+Default to using Bun instead of Node.js.
33+44+- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
55+- Use `bun test` instead of `jest` or `vitest`
66+- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
77+- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
88+- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
99+- Use `bunx <package> <command>` instead of `npx <package> <command>`
1010+- Bun automatically loads .env, so don't use dotenv.
1111+1212+## APIs
1313+1414+- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
1515+- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
1616+- `Bun.redis` for Redis. Don't use `ioredis`.
1717+- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
1818+- `WebSocket` is built-in. Don't use `ws`.
1919+- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
2020+- Bun.$`ls` instead of execa.
2121+2222+## Testing
2323+2424+Use `bun test` to run tests.
2525+2626+```ts#index.test.ts
2727+import { test, expect } from "bun:test";
2828+2929+test("hello world", () => {
3030+ expect(1).toBe(1);
3131+});
3232+```
3333+3434+## Frontend
3535+3636+Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
3737+3838+Server:
3939+4040+```ts#index.ts
4141+import index from "./index.html"
4242+4343+Bun.serve({
4444+ routes: {
4545+ "/": index,
4646+ "/api/users/:id": {
4747+ GET: (req) => {
4848+ return new Response(JSON.stringify({ id: req.params.id }));
4949+ },
5050+ },
5151+ },
5252+ // optional websocket support
5353+ websocket: {
5454+ open: (ws) => {
5555+ ws.send("Hello, world!");
5656+ },
5757+ message: (ws, message) => {
5858+ ws.send(message);
5959+ },
6060+ close: (ws) => {
6161+ // handle close
6262+ }
6363+ },
6464+ development: {
6565+ hmr: true,
6666+ console: true,
6767+ }
6868+})
6969+```
7070+7171+HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
7272+7373+```html#index.html
7474+<html>
7575+ <body>
7676+ <h1>Hello, world!</h1>
7777+ <script type="module" src="./frontend.tsx"></script>
7878+ </body>
7979+</html>
8080+```
8181+8282+With the following `frontend.tsx`:
8383+8484+```tsx#frontend.tsx
8585+import React from "react";
8686+import { createRoot } from "react-dom/client";
8787+8888+// import .css files directly and it works
8989+import './index.css';
9090+9191+const root = createRoot(document.body);
9292+9393+export default function Frontend() {
9494+ return <h1>Hello, world!</h1>;
9595+}
9696+9797+root.render(<Frontend />);
9898+```
9999+100100+Then, run index.ts
101101+102102+```sh
103103+bun --hot ./index.ts
104104+```
105105+106106+For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`.
···11+# jetstream-consumer
22+33+To install dependencies:
44+55+```bash
66+bun install
77+```
88+99+To run:
1010+1111+```bash
1212+bun run src/index.ts
1313+```
1414+1515+This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.