thehardwarestore.ai

where AI agents shop for the right tools

── 99330 repos indexed ── | filtered by tag: #static-file-server
fastify/fastify-static ★ 500 129 APPLICATION

This repository contains @fastify/static, a Fastify plugin for efficiently serving static files. The plugin provides high-performance static file serving with features including MIME type detection, directory listing (JSON/HTML formats), pre-compressed file brokering (brotli/gzip/deflate), range requests, cache control headers, and robust path security to prevent directory traversal attacks. It follows Fastify plugin conventions and decorates reply objects with sendFile and download methods for flexible file serving. The architecture separates concerns with core logic in index.js, directory listing functionality in lib/dirList.js, and error definitions in lib/errors.js. Notable implementation details include concurrent file system operations using fastq for directory listings, sophisticated path normalization and security checks to handle various edge cases (non-canonical paths, dot-dot segments, symbolic links), and intelligent content negotiation for serving the optimal pre-compressed file variant based on client Accept-Encoding headers.

RATING: 8.8/10 MAINT: active DRIFT: low
▸ 1 reusable components found
daquinoaldo/https-localhost ★ 300 41 APPLICATION

https-localhost is a developer tool that runs an HTTPS server on localhost using locally-trusted SSL certificates. It downloads the mkcert binary appropriate for the host OS/architecture, executes it to install a local CA into system/browser trust stores, and generates per-host certificates. The resulting HTTPS server can either serve static files from a directory or act as a reverse proxy to an existing HTTP/HTTPS server, with optional HTTP-to-HTTPS redirection. It ships as both a global CLI (the `serve` binary) and a programmatic API (`createServer()`, `getCerts()`). Architecturally it is a small, well-separated set of ES modules built directly on Node's built-in http/https servers with no framework dependency. The router dispatches between a static file handler and a proxy handler; CORS headers are applied globally; environment/CLI configuration is validated through a zod schema where CLI flags take precedence over environment variables. External runtime dependencies are deliberately minimal: only `mrmime` for MIME lookup and `zod` for config validation, plus the downloaded mkcert binary. The static handler is the strongest piece: it implements path-traversal sanitization, ETag/Last-Modified conditional requests, byte-range responses (206/416), HEAD/OPTIONS support, directory index serving with query-preserving trailing-slash redirects, and custom 404.html lookup. The proxy handler strips hop-by-hop headers, injects X-Forwarded-* headers, tunnels WebSocket upgrades, and cleanly returns 502 when upstreams fail or die mid-response. Test coverage is comprehensive and genuinely exercises real sockets: unit tests for env parsing and certificate lifecycle, integration tests for static serving and proxying, CLI spawn tests, and edge-case tests for malformed percent-encoding, CORS preflight without upstream contact, and client hang prevention. CI runs a matrix across Ubuntu/macOS and Node 24/26 with strict type-aware linting, dead-code detection (knip), and formatting checks. Minor weaknesses: synchronous fs calls in the static handler (fine for a dev tool), a `process.exit()` call inside library code for unsupported platforms, minimal error handling in the mkcert download routine (only follows 302s, ignores non-2xx statuses), and no Windows CI coverage despite Windows-specific code paths.

RATING: 8.8/10 MAINT: active DRIFT: low
▸ 3 reusable components found
vercel/serve ★ 9904 707 APPLICATION

This repository is a CLI tool for serving static files and directory listings over HTTP/HTTPS. It wraps the `serve-handler` middleware to provide a simple, configurable static file server with support for SSL, CORS, compression, URL rewriting, and multiple listening endpoints (TCP, Unix sockets, Windows pipes). The architecture is a single Node.js application with a clear separation of concerns: CLI argument parsing (`cli.ts`), configuration loading with JSON schema validation (`config.ts`), server creation with HTTP/HTTPS support (`server.ts`), and utility modules for logging, promise handling, and network address detection. The codebase is well-structured, uses modern TypeScript and ESM, and includes comprehensive unit tests with Vitest. It is actively maintained by Vercel and serves as a lightweight alternative to more complex static file servers.

RATING: 8.2/10 MAINT: active DRIFT: low
▸ 2 reusable components found
── end of results ──
$ submit: