File
Serves static files from a store backend. Reads the file by ingest.path, derives the Content-Type from the file extension, and responds directly. Returns false to stop the transformer chain.
Setup
- Integrated
- Bundled
Install the package:
Loading...
Configure in your code:
Loading...
How it works
- Reads
ingest.pathfrom the request context - Strips the configured
prefix(if set) — e.g./static/image.pngbecomesimage.png - Looks up the remaining path in the store via
store.get(key) - If found, derives the Content-Type from the file extension and responds with the content
- Returns
falseto stop the chain — no further transformers or destinations run - If the file is not found or the path doesn't match the prefix, the event passes through unchanged
Settings
| Option | Type | Default | Description |
|---|---|---|---|
prefix | string | — | URL prefix to strip (e.g., /static) |
headers | Record<string, string> | — | Default response headers (e.g., Cache-Control) |
mimeTypes | Record<string, string> | — | Extension overrides (e.g., { ".wasm": "application/wasm" }) |
Environment
| Key | Type | Required | Description |
|---|---|---|---|
store | Store.Instance | Yes | Store providing file content. Without one, the transformer warns and passes through. |
Examples
Cache + file chain
Place the cache transformer before the file transformer. Cached files are served from memory, avoiding repeated store reads:
Loading...
Custom MIME types
Loading...
Behavior notes
- Requires a store — without
env.store, every request logs a warning and passes through - Prefix matching — if
prefixis set and the path doesn't start with it, the event passes through (not an error) - Returns
false— a served file stops the chain; no destinations receive the event - Content-Length — automatically set for string and Buffer content
Next steps
- Cache - Add response caching before file serving
- Router - Route requests to the file chain
- Stores - Configure store backends
- Docker — Including files - Bake files into Docker images
💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)