brakit 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/dist/bin/brakit.d.ts +2 -0
- package/dist/bin/brakit.js +5679 -0
- package/dist/index.d.ts +203 -0
- package/dist/index.js +1603 -0
- package/dist/instrument/preload.d.ts +2 -0
- package/dist/instrument/preload.js +739 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brakit Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Brakit
|
|
2
|
+
|
|
3
|
+
**Your API is leaking data. Your queries are slow. Brakit shows you.**
|
|
4
|
+
|
|
5
|
+
AI writes your API. Nobody checks what it does — missing auth, leaked data, N+1 queries, slow endpoints. Brakit watches your app run and shows you everything. One command. Zero setup.
|
|
6
|
+
|
|
7
|
+
Open source · Local only · Zero config · 2 dependencies
|
|
8
|
+
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://nodejs.org)
|
|
11
|
+
[](https://typescriptlang.org)
|
|
12
|
+
|
|
13
|
+
<!-- TODO: Add demo gif showing: npx brakit dev → use app → dashboard shows issues -->
|
|
14
|
+
<!--  -->
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx brakit dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
That's it. Brakit auto-detects your framework, starts your dev server behind a transparent proxy, and serves a live dashboard at `/__brakit`.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx brakit dev --port 8080 # Custom proxy port
|
|
28
|
+
npx brakit dev --show-static # Include static assets in output
|
|
29
|
+
npx brakit dev ./my-app # Specify project directory
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> **Requirements:** Node.js >= 18 and a project with `package.json`.
|
|
33
|
+
|
|
34
|
+
[Documentation](https://brakit.ai/docs) · [Website](https://brakit.ai)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## What You Get
|
|
39
|
+
|
|
40
|
+
- **7 security rules** scanned against live traffic — leaked secrets, missing auth, N+1 queries flagged automatically
|
|
41
|
+
- **Action-level visibility** — see "Sign Up" and "Load Dashboard", not 47 raw HTTP requests
|
|
42
|
+
- **Duplicate detection** — same API called twice? Flagged with redundancy percentage
|
|
43
|
+
- **N+1 query detection** — same query pattern repeated 5+ times in a single request? That's an N+1
|
|
44
|
+
- **Full server tracing** — fetch calls, DB queries, console logs, errors — zero code changes
|
|
45
|
+
- **Live dashboard** at `/__brakit` — 9 tabs updating in real-time
|
|
46
|
+
- **Performance tracking** — health grades and p95 trends across dev sessions
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## You Don't Know What Your API Is Doing
|
|
51
|
+
|
|
52
|
+
You ship a signup flow. It works. But behind the scenes — 3 duplicate fetches, an N+1 query hitting the DB 12 times, and your user's email sitting in the response body unmasked. You'd never know without digging through network tabs and server logs for an hour.
|
|
53
|
+
|
|
54
|
+
Brakit watches every action your app takes — not raw HTTP noise, but what actually happened: "Sign Up" took 847ms, fired 4 queries (one is an N+1), called Clerk twice (one failed), and leaked a secret in the response. One glance. No `console.log`. No guessing.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Security Scanner
|
|
59
|
+
|
|
60
|
+
7 high-confidence rules that scan your live traffic and flag real issues — not theoretical ones:
|
|
61
|
+
|
|
62
|
+
| | Rule | What it catches |
|
|
63
|
+
| ------------ | ---------------- | ------------------------------------------------------------------------------- |
|
|
64
|
+
| **Critical** | Exposed Secret | Response contains `password`, `api_key`, `client_secret` fields with real values |
|
|
65
|
+
| **Critical** | Token in URL | Auth tokens in query parameters instead of headers |
|
|
66
|
+
| **Critical** | Stack Trace Leak | Internal stack traces sent to the client |
|
|
67
|
+
| **Critical** | Error Info Leak | DB connection strings, SQL queries, or secret values in error responses |
|
|
68
|
+
| Warning | Insecure Cookie | Missing `HttpOnly` or `SameSite` flags |
|
|
69
|
+
| Warning | Sensitive Logs | Passwords, secrets, or token values in console output |
|
|
70
|
+
| Warning | CORS + Credentials | `credentials: true` with wildcard origin |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Who Is This For
|
|
75
|
+
|
|
76
|
+
Developers using AI tools (Cursor, Copilot, Claude Code) to generate API code they don't fully review. Developers who debug with `console.log` and wish they could just see every action their API is executing. Anyone building Node.js APIs who wants to catch security and performance issues before production.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## How It Works
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
Browser --> Brakit (proxy) --> Your dev server
|
|
84
|
+
|
|
|
85
|
+
+-- Dashboard UI (/__brakit)
|
|
86
|
+
+-- Live SSE stream (real-time updates)
|
|
87
|
+
+-- Telemetry (from instrumented process)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Brakit is a transparent HTTP reverse proxy. Every request passes through unchanged — your app works exactly the same. Brakit captures request/response pairs, groups them into actions, and streams everything to the dashboard.
|
|
91
|
+
|
|
92
|
+
The instrumentation layer runs inside your dev server process (injected via `--import`) and sends telemetry back to Brakit over a local HTTP connection. That's how fetch calls, queries, and console output get captured without any code changes.
|
|
93
|
+
|
|
94
|
+
### Supported Frameworks
|
|
95
|
+
|
|
96
|
+
| Framework | Status |
|
|
97
|
+
| ----------- | -------------------------- |
|
|
98
|
+
| Next.js | Full support (auto-detect) |
|
|
99
|
+
| Remix | Auto-detect |
|
|
100
|
+
| Nuxt | Auto-detect |
|
|
101
|
+
| Vite | Auto-detect |
|
|
102
|
+
| Astro | Auto-detect |
|
|
103
|
+
| Any backend | Via `--command` flag |
|
|
104
|
+
|
|
105
|
+
### Supported Databases
|
|
106
|
+
|
|
107
|
+
| Driver | Status |
|
|
108
|
+
| ------- | --------- |
|
|
109
|
+
| pg | Supported |
|
|
110
|
+
| mysql2 | Supported |
|
|
111
|
+
| Prisma | Supported |
|
|
112
|
+
| SQLite | Planned |
|
|
113
|
+
| MongoDB | Planned |
|
|
114
|
+
| Drizzle | Planned |
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## CLI Options
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npx brakit dev # Auto-detect and start
|
|
122
|
+
npx brakit dev --port 3000 # Custom proxy port (default: 3000)
|
|
123
|
+
npx brakit dev --show-static # Show static asset requests
|
|
124
|
+
npx brakit dev ./my-app # Specify project directory
|
|
125
|
+
npx brakit dev --command "python manage.py" # Any backend, any language
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
git clone https://github.com/brakit-ai/brakit.git
|
|
134
|
+
cd brakit
|
|
135
|
+
|
|
136
|
+
npm install
|
|
137
|
+
npm run build # Build with tsup
|
|
138
|
+
npm run dev # Watch mode
|
|
139
|
+
npm run typecheck # Type-check without emitting
|
|
140
|
+
npm test # Run tests with vitest
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Only 2 production dependencies: `citty` (CLI) and `picocolors` (terminal colors). Everything else is Node.js built-ins.
|
|
144
|
+
|
|
145
|
+
### Architecture
|
|
146
|
+
|
|
147
|
+
For a full walkthrough of how brakit works — the two-process model, adapter
|
|
148
|
+
system, analysis engine, and SDK protocol — see
|
|
149
|
+
[How Brakit Works](docs/design/architecture.md).
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
src/
|
|
153
|
+
analysis/ Security scanning, N+1 detection, insights engine
|
|
154
|
+
rules/ SecurityRule implementations (one file per rule)
|
|
155
|
+
cli/ CLI entry point (citty)
|
|
156
|
+
dashboard/
|
|
157
|
+
api/ REST handlers — requests, flows, telemetry, metrics, ingest
|
|
158
|
+
client/ Browser JS generated as template strings
|
|
159
|
+
views/ Tab renderers (overview, flows, graph, etc.)
|
|
160
|
+
styles/ CSS modules
|
|
161
|
+
detect/ Framework auto-detection
|
|
162
|
+
instrument/ Node.js --import instrumentation
|
|
163
|
+
adapters/ BrakitAdapter implementations (one file per library)
|
|
164
|
+
hooks/ Core runtime hooks (fetch, console, errors, context)
|
|
165
|
+
proxy/ HTTP reverse proxy, request capture, WebSocket forwarding
|
|
166
|
+
store/ In-memory telemetry stores + persistent metrics
|
|
167
|
+
types/ TypeScript definitions by domain
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Contributing
|
|
173
|
+
|
|
174
|
+
Brakit is early and moving fast. The most common contributions — adding a new
|
|
175
|
+
database adapter or a new security rule — each require exactly one file and one
|
|
176
|
+
interface. See [CONTRIBUTING.md](CONTRIBUTING.md) for step-by-step guides.
|
|
177
|
+
|
|
178
|
+
Some areas where help would be great:
|
|
179
|
+
|
|
180
|
+
- **Database adapters** — Drizzle, Mongoose, SQLite, MongoDB
|
|
181
|
+
- **Security rules** — More patterns, configurable severity
|
|
182
|
+
- **Language SDKs** — Python, Go, Ruby (uses the [ingest protocol](docs/design/architecture.md#supporting-other-languages))
|
|
183
|
+
- **Dashboard** — Request diff, timeline view, HAR export
|
|
184
|
+
|
|
185
|
+
Please open an issue first for larger changes so we can discuss the approach.
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
[MIT](LICENSE)
|