bro-framework 2.4.5 → 3.0.1
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/README.md +44 -0
- package/bin/bro.js +279 -292
- package/package.json +138 -103
- package/src/dashboard.js +81 -0
- package/src/database.js +105 -0
- package/src/edge.js +244 -0
- package/src/engine.js +251 -0
- package/src/index.d.ts +46 -9
- package/src/index.js +10 -0
- package/src/logger.js +47 -0
- package/src/next.d.ts +51 -10
- package/src/next.js +82 -156
- package/src/observability.js +81 -0
- package/src/plugins.js +135 -0
- package/src/policy-auth.js +88 -0
- package/src/router.js +1 -1
- package/src/sdk.js +229 -169
- package/src/server.js +181 -170
- package/src/studio.js +162 -0
- package/src/task-engine.js +88 -0
- package/src/testing.js +142 -0
- package/src/uploads.js +129 -0
package/README.md
CHANGED
|
@@ -84,6 +84,8 @@ export default defineConfig({
|
|
|
84
84
|
|
|
85
85
|
`cors: false` disables HTTP CORS middleware. Helmet is enabled by default and can be disabled with `helmet: false`. Redis is optional; when configured it powers distributed rate limiting, route caching, and Socket.IO scaling. In `NODE_ENV=test`, bro.js can inject `ioredis-mock`; install it in the consuming project's development dependencies.
|
|
86
86
|
|
|
87
|
+
> **Production Security Note**: When deploying behind a reverse proxy (Nginx, AWS ALB, Vercel, Render), ensure your load balancer properly sets `X-Forwarded-For`. Rate limiting and trusted IP functionality relies on this proxy configuration.
|
|
88
|
+
|
|
87
89
|
---
|
|
88
90
|
|
|
89
91
|
## The Core Experience
|
|
@@ -243,6 +245,40 @@ Handlers receive:
|
|
|
243
245
|
|
|
244
246
|
For Redis-backed integration tests without an external Redis server, install `ioredis-mock` in the consuming project and run with `NODE_ENV=test`. bro.js injects a mock Redis client and exercises cache, rate-limit, Socket.IO adapter, and shutdown paths.
|
|
245
247
|
|
|
248
|
+
### Supertest + Vitest Recipe
|
|
249
|
+
|
|
250
|
+
You can programmatically bootstrap `bro.js` using `createServer` for blazing fast integration tests. Here's a complete `vitest` recipe:
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
254
|
+
import request from 'supertest';
|
|
255
|
+
import path from 'path';
|
|
256
|
+
import { createServer } from 'bro-framework';
|
|
257
|
+
import config from '../bro.config.js';
|
|
258
|
+
|
|
259
|
+
describe('API Tests', () => {
|
|
260
|
+
let app, shutdown;
|
|
261
|
+
|
|
262
|
+
beforeAll(async () => {
|
|
263
|
+
// 1. Initialize the server programmatically
|
|
264
|
+
const instance = await createServer(config, path.resolve('./routes'), null);
|
|
265
|
+
app = instance.app;
|
|
266
|
+
shutdown = instance.shutdown;
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
afterAll(async () => {
|
|
270
|
+
// 2. Cleanly teardown tasks, redis, and sockets
|
|
271
|
+
if (shutdown) await shutdown();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('should return a 200 from the healthcheck', async () => {
|
|
275
|
+
const res = await request(app).get('/health/live');
|
|
276
|
+
expect(res.status).toBe(200);
|
|
277
|
+
expect(res.body.status).toBe('ok');
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
246
282
|
---
|
|
247
283
|
|
|
248
284
|
## Architecture & Request Lifecycle
|
|
@@ -339,6 +375,14 @@ export const POST = defineRoute({
|
|
|
339
375
|
|
|
340
376
|
---
|
|
341
377
|
|
|
378
|
+
## Compatibility Table
|
|
379
|
+
|
|
380
|
+
| bro.js Version | Node.js | Next.js App Router | Express | Zod |
|
|
381
|
+
| :------------- | :-------- | :----------------- | :------ | :------ |
|
|
382
|
+
| `>= 2.0.0` | `>= 18.x` | `>= 13.4.x` | `4.x` | `3.x` |
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
342
386
|
## Author & License
|
|
343
387
|
|
|
344
388
|
- **Author**: Yass1n (@medyass1ne)
|