glb-compressor-server

HTTP server for compressing GLB/glTF 3D models via REST API and SSE streaming. Use when building web integrations, setting up a compression microservice, or adding real-time compression progress to a frontend.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "glb-compressor-server" with this command: npx skills add kjanat/glb-compressor/kjanat-glb-compressor-glb-compressor-server

glb-compressor Server

HTTP compression server built on Bun.serve(). Provides synchronous and streaming (SSE) compression endpoints with full CORS support.

Starting the Server

# Production (from installed package)
glb-server

# Development (hot reload)
bun run dev

# Custom port
PORT=3000 bun run start

Default port: 8080 (override via PORT env var).

Endpoints

GET /healthz

Health check. Returns 200 ok.

POST /compress

Synchronous compression. Returns compressed GLB binary.

Accepts: multipart/form-data (field: file) or raw application/octet-stream.

Query params / form fields:

  • preset - Compression preset: default, balanced, aggressive, max
  • simplify - Mesh simplification ratio (0, 1), e.g. 0.5

Form fields override query params when both are provided.

Response headers:

HeaderDescription
X-Request-IDUUID tracking this request
X-Original-SizeInput file size in bytes
X-Compressed-SizeOutput file size in bytes
X-Compression-Methodgltfpack or meshopt
X-Compression-RatioPercentage reduction (e.g. 84.1)
Content-DispositionSuggested download filename

Example:

# Multipart upload
curl -X POST -F "file=@model.glb" \
  "http://localhost:8080/compress?preset=aggressive" \
  -o compressed.glb

# Raw binary upload
curl -X POST --data-binary @model.glb \
  -H "Content-Type: application/octet-stream" \
  "http://localhost:8080/compress?preset=balanced" \
  -o compressed.glb

POST /compress-stream

SSE streaming compression with real-time progress. Multipart only.

Content-Type: text/event-stream

SSE events:

EventData shape
log{ message: string }
result{ requestId, filename, data (base64), originalSize, compressedSize, ratio, method }
error{ message, requestId, code }

Stream closes after result or error event.

Example (JavaScript):

const form = new FormData();
form.append('file', glbFile);

const response = await fetch(
	'http://localhost:8080/compress-stream?preset=aggressive',
	{ method: 'POST', body: form },
);

const reader = response.body.getReader();
const decoder = new TextDecoder();

// Parse SSE events from the stream
while (true) {
	const { done, value } = await reader.read();
	if (done) break;
	const text = decoder.decode(value);
	// Parse "event: <type>\ndata: <json>\n\n" format
	console.log(text);
}

Error Responses

All errors return structured JSON:

{
	"error": { "code": "ERROR_CODE", "message": "Human-readable message" },
	"requestId": "uuid"
}

Error codes:

CodeHTTPDescription
NO_FILE_PROVIDED400No file in form data
INVALID_GLB400Failed GLB magic byte validation
FILE_TOO_LARGE413Exceeds 100 MB limit
INVALID_CONTENT_TYPE415Non-multipart on streaming endpoint
COMPRESSION_FAILED500Pipeline error during compression

CORS

Full CORS enabled on all endpoints. Exposed headers: X-Request-ID, X-Original-Size, X-Compressed-Size, X-Compression-Method, X-Compression-Ratio.

Limits

  • Max file size: 100 MB
  • gltfpack timeout: 60 seconds per file

Architecture Notes

  • import.meta.main guard: safe to import server/main.ts as a library without starting the server.
  • Request ID (X-Request-ID) is generated per request and logged server-side.
  • The /compress-stream endpoint sends the compressed GLB as base64 in the result SSE event (~33% larger than binary). For large files near the 100 MB limit, prefer /compress.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

glb-compressor-library

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

glb-compressor-cli

No summary provided by upstream source.

Repository SourceNeeds Review
General

changelog-writing

No summary provided by upstream source.

Repository SourceNeeds Review
General

uv-versioning

No summary provided by upstream source.

Repository SourceNeeds Review