Skip to main content

File

Server Source code Package

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 so no further transformers or destinations run for the request.

Installation

Loading...
Loading...

Configuration

This transformer uses the standard transformer config wrapper (consent, data, env, id, ...). For the shared fields see transformer configuration. Package-specific fields live under config.settings and are listed below.

Settings

PropertyTypeDescriptionMore
prefixstringURL prefix to strip before store lookup. E.g., "/static" → /static/walker.js looks up "walker.js"
headersRecord<string, string>Default response headers (e.g., Cache-Control, X-Frame-Options)
mimeTypesRecord<string, string>Extension → Content-Type overrides. Keys include dot: { ".wasm": "application/wasm" }

Mapping

This package does not define custom rule-level settings. For the standard rule fields (consent, condition, data, batch, name, policy) see mapping.

Examples

serve static file

Event
Out

How it works

  1. Reads ingest.path from the request context
  2. Strips the configured prefix (if set), e.g. /static/image.png becomes image.png
  3. Looks up the remaining path in the store via store.get(key)
  4. If found, derives the Content-Type from the file extension and responds with the content
  5. Returns false to stop the chain. No further transformers or destinations run.
  6. If the file is not found or the path doesn't match the prefix, the event passes through unchanged

Environment

KeyTypeRequiredDescription
storeStore.InstanceYesStore providing file content. Without one, the transformer warns and passes through.

Cache and file chain

Use native cache on the file transformer to serve cached files 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 prefix is 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

💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)