Skip to content

Commit 3ba8136

Browse files
Merge pull request #12 from zeixcom/next
Proper cleanup of on(), pass(), provideContexts() restored
2 parents 4f88f43 + 1b4aedf commit 3ba8136

File tree

248 files changed

+1831
-1328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+1831
-1328
lines changed

.ai-context.md

Lines changed: 0 additions & 235 deletions
This file was deleted.

.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc

Lines changed: 8 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -7,105 +7,13 @@ alwaysApply: false
77
Default to using Bun instead of Node.js.
88

99
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10-
- Use `bun test` instead of `jest` or `vitest`
11-
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12-
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13-
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14-
- Bun automatically loads .env, so don't use dotenv.
10+
- Use `bun run <script>` instead of `npm run` / `yarn run` / `pnpm run`
11+
- Use `bun install` instead of `npm install` / `yarn` / `pnpm install`
12+
- Use `bun test` instead of `jest` or `vitest` (server tests only; integration tests use `bunx playwright`)
13+
- Bun automatically loads `.env` — don't add `dotenv`
1514

16-
## APIs
15+
## Server-side APIs
1716

18-
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19-
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20-
- `Bun.redis` for Redis. Don't use `ioredis`.
21-
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22-
- `WebSocket` is built-in. Don't use `ws`.
23-
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
24-
- Bun.$`ls` instead of execa.
25-
26-
## Testing
27-
28-
Use `bun test` to run tests.
29-
30-
```ts#index.test.ts
31-
import { test, expect } from "bun:test";
32-
33-
test("hello world", () => {
34-
expect(1).toBe(1);
35-
});
36-
```
37-
38-
## Frontend
39-
40-
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
41-
42-
Server:
43-
44-
```ts#index.ts
45-
import index from "./index.html"
46-
47-
Bun.serve({
48-
routes: {
49-
"/": index,
50-
"/api/users/:id": {
51-
GET: (req) => {
52-
return new Response(JSON.stringify({ id: req.params.id }));
53-
},
54-
},
55-
},
56-
// optional websocket support
57-
websocket: {
58-
open: (ws) => {
59-
ws.send("Hello, world!");
60-
},
61-
message: (ws, message) => {
62-
ws.send(message);
63-
},
64-
close: (ws) => {
65-
// handle close
66-
}
67-
},
68-
development: {
69-
hmr: true,
70-
console: true,
71-
}
72-
})
73-
```
74-
75-
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.
76-
77-
```html#index.html
78-
<html>
79-
<body>
80-
<h1>Hello, world!</h1>
81-
<script type="module" src="./frontend.tsx"></script>
82-
</body>
83-
</html>
84-
```
85-
86-
With the following `frontend.tsx`:
87-
88-
```tsx#frontend.tsx
89-
import React from "react";
90-
91-
// import .css files directly and it works
92-
import './index.css';
93-
94-
import { createRoot } from "react-dom/client";
95-
96-
const root = createRoot(document.body);
97-
98-
export default function Frontend() {
99-
return <h1>Hello, world!</h1>;
100-
}
101-
102-
root.render(<Frontend />);
103-
```
104-
105-
Then, run index.ts
106-
107-
```sh
108-
bun --hot ./index.ts
109-
```
110-
111-
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
17+
- `Bun.serve()` for HTTP — don't use `express`
18+
- `Bun.file()` for file I/O — don't use `node:fs` readFile/writeFile
19+
- `Bun.$\`cmd\`` for shell commands — don't use `execa`

0 commit comments

Comments
 (0)