jsgui3-server 0.0.150 → 0.0.151

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.
@@ -176,5 +176,6 @@ model.count++; // Triggers change event
176
176
  | Comprehensive API | `docs/comprehensive-documentation.md` |
177
177
  | Control development | `docs/controls-development.md` |
178
178
  | Publisher system | `docs/publishers-guide.md` |
179
+ | Middleware & compression | `docs/middleware-guide.md` |
179
180
  | Troubleshooting | `docs/troubleshooting.md` |
180
181
  | **Broken stuff** | `docs/agent-development-guide.md` |
package/AGENTS.md CHANGED
@@ -19,6 +19,7 @@
19
19
  - **[docs/controls-development.md](docs/controls-development.md)** - Guide for developing custom JSGUI3 controls
20
20
  - **[docs/publishers-guide.md](docs/publishers-guide.md)** - Guide for publishers and content serving
21
21
  - **[docs/resources-guide.md](docs/resources-guide.md)** - Guide for resources and data abstraction
22
+ - **[docs/middleware-guide.md](docs/middleware-guide.md)** - Middleware pipeline and built-in compression middleware
22
23
 
23
24
  ### Specialized Documentation
24
25
  - **[docs/GUIDE_TO_AGENTIC_WORKFLOWS_BY_GROK.md](docs/GUIDE_TO_AGENTIC_WORKFLOWS_BY_GROK.md)** - Comprehensive guide to agentic workflows and autonomous task execution
@@ -61,6 +62,7 @@
61
62
  - **Custom control development** → `docs/controls-development.md`
62
63
  - **Publisher system** → `docs/publishers-guide.md`
63
64
  - **Resource management** → `docs/resources-guide.md`
65
+ - **Middleware and compression** → `docs/middleware-guide.md`
64
66
  - **Admin UI extensions** → `docs/admin-extension-guide.md`
65
67
 
66
68
  ### Agent Development
package/README.md CHANGED
@@ -170,9 +170,9 @@ sse_publisher.broadcast('resource_update', { running: 3, total: 5 });
170
170
 
171
171
  ## Admin UI Dashboard
172
172
 
173
- Every jsgui3-server instance includes a built-in admin dashboard at `/admin/v1` with live stats, resource inspection, route listing, and SSE-driven heartbeat updates. The dashboard is session-authenticated (default dev credentials: `admin` / `admin`).
174
-
175
- The admin shell is implemented with jsgui controls for navigation and dynamic panel rendering (control-first composition), and is covered by the interaction regression suite in `tests/admin-ui-jsgui-controls.test.js`.
173
+ Every jsgui3-server instance includes a built-in admin dashboard at `/admin/v1` with live stats, resource inspection, route listing, and SSE-driven heartbeat updates. The dashboard is session-authenticated (default dev credentials: `admin` / `admin`).
174
+
175
+ The admin shell is implemented with jsgui controls for navigation and dynamic panel rendering (control-first composition), and is covered by the interaction regression suite in `tests/admin-ui-jsgui-controls.test.js`.
176
176
 
177
177
  ### Disabling the Admin UI
178
178
 
@@ -219,10 +219,10 @@ server.admin_v1.add_endpoint({
219
219
  });
220
220
  ```
221
221
 
222
- ### Plugin Pattern
222
+ ### Plugin Pattern
223
223
 
224
224
  ```javascript
225
- server.admin_v1.use((admin) => {
225
+ server.admin_v1.use((admin) => {
226
226
  admin.add_section({
227
227
  id: 'logs',
228
228
  label: 'Logs',
@@ -233,14 +233,14 @@ server.admin_v1.use((admin) => {
233
233
  res.end(JSON.stringify({ recent: ['log1', 'log2'] }));
234
234
  }
235
235
  });
236
- });
237
- ```
238
-
239
- ### Admin UI Regression Test
240
-
241
- ```bash
242
- node tests/test-runner.js --test=admin-ui-jsgui-controls.test.js
243
- ```
236
+ });
237
+ ```
238
+
239
+ ### Admin UI Regression Test
240
+
241
+ ```bash
242
+ node tests/test-runner.js --test=admin-ui-jsgui-controls.test.js
243
+ ```
244
244
 
245
245
  ### Declarative Configuration via `Server.serve()`
246
246
 
@@ -298,6 +298,61 @@ jsgui.Admin_User_Store
298
298
 
299
299
  See [Admin Extension Guide](docs/admin-extension-guide.md) for detailed API reference.
300
300
 
301
+ ## Middleware
302
+
303
+ jsgui3-server includes an Express-style `server.use()` middleware pipeline. Middleware runs before every request reaches the router.
304
+
305
+ ### Built-in Compression
306
+
307
+ Enable gzip/deflate/brotli compression for JSON, HTML, CSS, and JS responses:
308
+
309
+ ```javascript
310
+ const { compression } = require('jsgui3-server/middleware');
311
+
312
+ const server = new Server({ Ctrl: MyControl, src_path_client_js: __dirname + '/client.js' });
313
+ server.use(compression());
314
+ server.on('ready', () => server.start(8080));
315
+ ```
316
+
317
+ Or via `Server.serve()`:
318
+
319
+ ```javascript
320
+ Server.serve({
321
+ Ctrl: MyControl,
322
+ compression: true, // enable with defaults
323
+ port: 8080
324
+ });
325
+
326
+ // With options:
327
+ Server.serve({
328
+ Ctrl: MyControl,
329
+ compression: { threshold: 512 },
330
+ port: 8080
331
+ });
332
+ ```
333
+
334
+ ### Custom Middleware
335
+
336
+ ```javascript
337
+ // Request logger
338
+ server.use((req, res, next) => {
339
+ console.log(`${req.method} ${req.url}`);
340
+ next();
341
+ });
342
+
343
+ // Multiple middleware via Server.serve()
344
+ Server.serve({
345
+ Ctrl: MyControl,
346
+ middleware: [
347
+ (req, res, next) => { console.log(req.url); next(); },
348
+ compression({ threshold: 512 })
349
+ ],
350
+ port: 8080
351
+ });
352
+ ```
353
+
354
+ See [Middleware Guide](docs/middleware-guide.md) for the full API reference and response-wrapping patterns.
355
+
301
356
  ## Architecture Overview
302
357
 
303
358
  The server operates as a bridge between server-side JavaScript applications and browser clients, offering: