Compare commits

..

4 Commits

Author SHA1 Message Date
d5800f58b4 v7.11.1
Some checks failed
Default (tags) / security (push) Failing after 17s
Default (tags) / test (push) Failing after 13s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-12-08 17:00:16 +00:00
49949b6776 fix(dependencies): Upgrade dependencies: bump @design.estate/dees-catalog to v3.1.1 and @push.rocks/smartwatch to v6.0.0; update migration notes in readme.hints.md 2025-12-08 17:00:16 +00:00
623e40c5b7 v7.11.0
Some checks failed
Default (tags) / security (push) Failing after 15s
Default (tags) / test (push) Failing after 12s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-12-08 12:19:01 +00:00
94532c3c68 feat(typedserver): Add configurable response compression (Brotli + Gzip) with defaults enabled and documentation 2025-12-08 12:19:01 +00:00
9 changed files with 143 additions and 19 deletions

View File

@@ -1,5 +1,21 @@
# Changelog
## 2025-12-08 - 7.11.1 - fix(dependencies)
Upgrade dependencies: bump @design.estate/dees-catalog to v3.1.1 and @push.rocks/smartwatch to v6.0.0; update migration notes in readme.hints.md
- package.json: @design.estate/dees-catalog updated from ^2.0.3 to ^3.1.1 (includes new icons, components and DeesIcon unified icon property; legacy iconFA deprecated)
- package.json: @push.rocks/smartwatch updated from ^5.0.0 to ^6.0.0 (cross-runtime support, native fs.watch, API compatibility maintained: new Smartwatch class methods and events documented)
- readme.hints.md: added migration notes for smartwatch v6 and dees-catalog v3, plus other dependency update summaries
## 2025-12-08 - 7.11.0 - feat(typedserver)
Add configurable response compression (Brotli + Gzip) with defaults enabled and documentation
- Expose a new compression option on IServerOptions (plugins.smartserve.ICompressionConfig | boolean).
- Pass the compression setting through to SmartServe (smartServeOptions.compression = this.options.compression).
- Add compression option to UtilityWebsiteServer and forward it when creating SmartServe options.
- Update README: new Compression section with global config examples, per-route decorator usage, and options reference.
- Add a small readme.todo.md with service worker wake/reload TODO notes.
## 2025-12-05 - 7.10.2 - fix(docs)
Update README with routing examples and utility server config; bump @cloudflare/workers-types and @push.rocks/smartserve versions

View File

@@ -1,6 +1,6 @@
{
"name": "@api.global/typedserver",
"version": "7.10.2",
"version": "7.11.1",
"description": "A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.",
"type": "module",
"exports": {
@@ -62,7 +62,7 @@
"@api.global/typedrequest-interfaces": "^3.0.19",
"@api.global/typedsocket": "^4.1.0",
"@cloudflare/workers-types": "^4.20251205.0",
"@design.estate/dees-catalog": "^2.0.3",
"@design.estate/dees-catalog": "^3.1.1",
"@design.estate/dees-comms": "^1.0.30",
"@push.rocks/lik": "^6.2.2",
"@push.rocks/smartdelay": "^3.0.5",
@@ -87,7 +87,7 @@
"@push.rocks/smartsitemap": "^2.0.4",
"@push.rocks/smartstream": "^3.2.5",
"@push.rocks/smarttime": "^4.1.1",
"@push.rocks/smartwatch": "^5.0.0",
"@push.rocks/smartwatch": "^6.0.0",
"@push.rocks/taskbuffer": "^3.5.0",
"@push.rocks/webrequest": "^4.0.1",
"@push.rocks/webstore": "^2.0.20",

20
pnpm-lock.yaml generated
View File

@@ -21,8 +21,8 @@ importers:
specifier: ^4.20251205.0
version: 4.20251205.0
'@design.estate/dees-catalog':
specifier: ^2.0.3
version: 2.0.3(@tiptap/pm@2.27.1)
specifier: ^3.1.1
version: 3.1.1(@tiptap/pm@2.27.1)
'@design.estate/dees-comms':
specifier: ^1.0.30
version: 1.0.30
@@ -96,8 +96,8 @@ importers:
specifier: ^4.1.1
version: 4.1.1
'@push.rocks/smartwatch':
specifier: ^5.0.0
version: 5.0.0
specifier: ^6.0.0
version: 6.0.0
'@push.rocks/taskbuffer':
specifier: ^3.5.0
version: 3.5.0
@@ -549,8 +549,8 @@ packages:
'@configvault.io/interfaces@1.0.17':
resolution: {integrity: sha512-bEcCUR2VBDJsTin8HQh8Uw/mlYl2v8A3jMIaQ+MTB9Hrqd6CZL2dL7iJdWyFl/3EIX+LDxWFR+Oq7liIq7w+1Q==}
'@design.estate/dees-catalog@2.0.3':
resolution: {integrity: sha512-+LoCZd2sHlp+8WRTJkDqBg9Ui1tlLcg+K3mYGkqVn+P2JLUCWUM8+LsYxgWEpgGGA8C6n1I7d+y2a63RjXwZ+Q==}
'@design.estate/dees-catalog@3.1.1':
resolution: {integrity: sha512-w7GMX5L3uF+w1q0oCAA1489HabgwBubbdt48/3FTOhklOZkXZF0Dfbs/hu4LDTjv0IkNPFxWY+4AXUErD+wh2Q==}
'@design.estate/dees-comms@1.0.30':
resolution: {integrity: sha512-KchMlklJfKAjQiJiR0xmofXtQ27VgZtBIxcMwPE9d+h3jJRv+lPZxzBQVOM0eyM0uS44S5vJMZ11IeV4uDXSHg==}
@@ -1339,8 +1339,8 @@ packages:
'@push.rocks/smartversion@3.0.5':
resolution: {integrity: sha512-8MZSo1yqyaKxKq0Q5N188l4un++9GFWVbhCAX5mXJwewZHn97ujffTeL+eOQYpWFTEpUhaq1QhL4NhqObBCt1Q==}
'@push.rocks/smartwatch@5.0.0':
resolution: {integrity: sha512-uuWUlTo0l5LWOWoOuTMG7zzxpUNKBcyqoB+zyQ24NHTtSYNcaUJtaQzTO2gxMXr5sqiZDkohlThS0KvsBc3g7w==}
'@push.rocks/smartwatch@6.0.0':
resolution: {integrity: sha512-RVUpIP7rg+C3WFilFQ1W00oO93wA+ht9+Of2795rjFNc68skpSuQ93/1npGBliEHfFFLak2eO9vXBdngQM1N2A==}
engines: {node: '>=20.0.0'}
'@push.rocks/smartxml@2.0.0':
@@ -5645,7 +5645,7 @@ snapshots:
dependencies:
'@api.global/typedrequest-interfaces': 3.0.19
'@design.estate/dees-catalog@2.0.3(@tiptap/pm@2.27.1)':
'@design.estate/dees-catalog@3.1.1(@tiptap/pm@2.27.1)':
dependencies:
'@design.estate/dees-domtools': 2.3.6
'@design.estate/dees-element': 2.1.3
@@ -7002,7 +7002,7 @@ snapshots:
'@types/semver': 7.7.1
semver: 7.7.3
'@push.rocks/smartwatch@5.0.0':
'@push.rocks/smartwatch@6.0.0':
dependencies:
'@push.rocks/lik': 6.2.2
'@push.rocks/smartenv': 6.0.0

View File

@@ -3,7 +3,9 @@
## Recent Changes (December 2025)
### Dependency Updates
- `@push.rocks/smartchok` replaced with `@push.rocks/smartwatch` (renamed package, same API)
- `@push.rocks/smartwatch` upgraded to v6.0.0 (cross-runtime, native fs.watch)
- `@design.estate/dees-catalog` upgraded to v3.1.1 (new icons, components)
- `@push.rocks/smartchok` replaced with `@push.rocks/smartwatch` (renamed package)
- `@push.rocks/smartfile` upgraded from v11 to v13 (major API change - `fs` module removed)
- `@push.rocks/smartfs` added for filesystem operations (v1.2.0+)
- `@push.rocks/smartenv` upgraded to v6.0.0
@@ -14,6 +16,26 @@
### Code Migration Notes
#### smartwatch v6.0.0
- Cross-runtime support: Node.js 20+, Deno, Bun
- Uses native `fs.watch({ recursive: true })` for performance
- Minimal dependencies (no chokidar, no FSEvents bindings)
- API unchanged: `new Smartwatch([patterns])`, `.start()`, `.stop()`, `.getObservableFor(event)`
- Events: `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `error`, `ready`
- Dynamic watching: `.add(patterns)`, `.remove(pattern)`
- Status property: `'idle' | 'starting' | 'watching'`
#### dees-catalog v3.0.0+ Migration
- **DeesIcon**: New unified `icon` property with library prefixes:
- FontAwesome: `icon="fa:check"` (prefix `fa:`)
- Lucide: `icon="lucide:menu"` (prefix `lucide:`)
- Legacy `iconFA` property deprecated but still supported
- **DeesToast**: New convenience methods and positioning:
- `DeesToast.info()`, `.success()`, `.warning()`, `.error()`
- Position options: `top-right`, `top-left`, `bottom-right`, `bottom-left`, `top-center`, `bottom-center`
- New components: DeesInputTags, DeesInputDatepicker, DeesStatsGrid, DeesPagination, DeesAppuiBase
- DeesAppuiAppbar: Hierarchical menus with keyboard navigation
#### smartfile v13 Migration
- Old: `plugins.smartfile.fs.toStringSync(path)` / `plugins.smartfile.fs.toBufferSync(path)`
- New: Use `plugins.fsInstance` (SmartFs instance with Node provider)
@@ -24,10 +46,6 @@
- Old: `plugins.smartfile.fs.fileTreeToHash(dir, pattern)`
- New: `await plugins.fsInstance.directory(dir).recursive().treeHash()`
#### smartwatch (formerly smartchok)
- Class renamed: `Smartchok``Smartwatch`
- API remains the same: `new Smartwatch([paths])`, `.start()`, `.stop()`, `.getObservableFor(event)`
#### webrequest v4
- Class renamed: `WebRequest``WebrequestClient`

View File

@@ -341,6 +341,75 @@ await server.start();
| `Cross-Origin-Embedder-Policy` | `crossOriginEmbedderPolicy` | Controls cross-origin embedding |
| `Cross-Origin-Resource-Policy` | `crossOriginResourcePolicy` | Controls cross-origin resource sharing |
## 🗜️ Compression
TypedServer supports automatic response compression using Brotli and Gzip. Compression is powered by smartserve and enabled by default.
### Global Configuration
```typescript
import { TypedServer } from '@api.global/typedserver';
const server = new TypedServer({
serveDir: './dist',
cors: true,
// Enable with defaults (brotli + gzip, threshold: 1024 bytes)
compression: true,
// Or disable completely
compression: false,
// Or configure in detail
compression: {
enabled: true,
algorithms: ['br', 'gzip'], // Preferred order
threshold: 1024, // Min size to compress (bytes)
level: 4, // Compression level (1-11 for brotli, 1-9 for gzip)
exclude: ['/api/stream/*'], // Skip these paths
},
});
```
### Per-Route Control with Decorators
Use `@Compress` and `@NoCompress` decorators for fine-grained control:
```typescript
import * as smartserve from '@push.rocks/smartserve';
@smartserve.Route('/api')
class ApiController {
// Force maximum compression for this endpoint
@smartserve.Get('/large-data')
@smartserve.Compress({ level: 11 })
async getLargeData(ctx: smartserve.IRequestContext): Promise<Response> {
return new Response(JSON.stringify(largeDataset));
}
// Disable compression for streaming endpoint
@smartserve.Get('/events')
@smartserve.NoCompress()
async streamEvents(ctx: smartserve.IRequestContext): Promise<Response> {
// Server-Sent Events shouldn't be compressed
return new Response(eventStream, {
headers: { 'Content-Type': 'text/event-stream' },
});
}
}
```
### Compression Options Reference
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `enabled` | `boolean` | `true` | Enable/disable compression |
| `algorithms` | `string[]` | `['br', 'gzip']` | Preferred algorithms in order |
| `threshold` | `number` | `1024` | Minimum response size (bytes) to compress |
| `level` | `number` | `4` | Compression level (1-11 for brotli, 1-9 for gzip) |
| `compressibleTypes` | `string[]` | auto | MIME types to compress |
| `exclude` | `string[]` | `[]` | Path patterns to skip |
## 📋 Configuration Reference
### IServerOptions
@@ -366,6 +435,7 @@ await server.start();
| `feedMetadata` | `object` | - | RSS feed metadata options |
| `blockWaybackMachine` | `boolean` | `false` | Block Wayback Machine archiving |
| `securityHeaders` | `ISecurityHeaders` | - | Security headers configuration |
| `compression` | `ICompressionConfig \| boolean` | `true` | Response compression configuration |
## 🏗️ Package Exports
@@ -408,6 +478,9 @@ const websiteServer = new utilityservers.UtilityWebsiteServer({
xContentTypeOptions: true,
},
// Compression (enabled by default)
compression: true, // or { level: 6, threshold: 512 }
// Other options
cors: true, // default: true
forceSsl: false, // default: false

5
readme.todo.md Normal file
View File

@@ -0,0 +1,5 @@
- Wake up the service worker before sending stuff.
Handle reload properly. Make sure service worker is up.
Pill handling of service worker status.

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedserver',
version: '7.10.2',
version: '7.11.1',
description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.'
}

View File

@@ -137,6 +137,12 @@ export interface IServerOptions {
* Security headers configuration (CSP, HSTS, X-Frame-Options, etc.)
*/
securityHeaders?: ISecurityHeaders;
/**
* Response compression configuration
* Set to true for defaults (brotli + gzip), false to disable, or provide detailed config
*/
compression?: plugins.smartserve.ICompressionConfig | boolean;
}
export type THttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'ALL';
@@ -281,6 +287,7 @@ export class TypedServer {
const smartServeOptions: plugins.smartserve.ISmartServeOptions = {
port,
hostname: '0.0.0.0',
compression: this.options.compression,
tls:
this.options.privateKey && this.options.publicKey
? {

View File

@@ -25,6 +25,8 @@ export interface IUtilityWebsiteServerConstructorOptions {
port?: number;
/** ads.txt entries (only served if configured) */
adsTxt?: string[];
/** Response compression configuration (default: enabled with brotli + gzip) */
compression?: plugins.smartserve.ICompressionConfig | boolean;
}
/**
@@ -67,6 +69,9 @@ export class UtilityWebsiteServer {
forceSsl: this.options.forceSsl ?? false,
securityHeaders: this.options.securityHeaders,
// Compression
compression: this.options.compression,
// PWA manifest
manifest: {
name: this.options.domain,