faas.yaml Configuration Specification
Background
faas.yaml is the runtime configuration entry used by FaasJS config loading, local dev server resolution, and type generation.
This spec defines the current public baseline that matches FaasJS runtime behavior.
Related references:
packages/node-utils/src/load_config.tspackages/node-utils/src/parse_yaml/index.tspackages/dev/src/server_config.tspackages/dev/src/typegen.ts@faasjs/node-utilsparseYaml()
Goals
- Keep config discovery and merge order deterministic.
- Keep staging-level validation predictable.
- Define the supported YAML subset explicitly.
- Give custom Node.js tooling a supported parser entrypoint for the same YAML subset.
Normative Rules
1. File naming and placement
- Configuration file name MUST be
faas.yaml. - Project-level configuration SHOULD be placed at
<projectRoot>/src/faas.yaml. - Additional
faas.yamlfiles MAY be placed in nested directories undersrc/for local overrides.
2. Discovery and merge order
- For an API file under
<srcRoot>/<path>/<file>.api.ts, the loader MUST discover files from shallow to deep:<srcRoot>/faas.yaml<srcRoot>/<path-segment-1>/faas.yaml- ...
<srcRoot>/<path>/faas.yaml
- Effective config MUST be merged in discovered order where deeper config overrides shallower config.
- For each staging key
S != defaults, effective staging config MUST bedeepMerge(defaults, S)after file-level merge is done. - If requested staging does not exist, runtime MUST fall back to
defaults, then to an empty object.
3. Root object and staging keys
- The parsed root value MUST be an object when provided.
- Each top-level staging value MUST be an object when provided.
defaultsSHOULD exist and SHOULD contain shared baseline settings.
4. server node contract
<staging>.server, when present, MUST be an object.<staging>.server.root, when present, MUST be a string.<staging>.server.base, when present, MUST be a string.- In
@faasjs/dev,server.rootMUST be resolved relative to project root and represent project root. - In
@faasjs/dev, source root MUST be<server.root>/src. - In type generation, output path MUST be
<server.root>/src/.faasjs/types.d.ts.
5. plugins node authoring
<staging>.pluginsMAY be omitted.- Recommended authoring shape is a mapping from plugin key to plugin config object.
- Plugin key SHOULD be stable within the same staging because
loadConfig()derives runtimenamefrom that key. nameis a loader-generated runtime field and SHOULD NOT be authored manually infaas.yaml.- A plugin config object MAY contain
type,config, and other plugin-specific fields. - Plugin
typeMAY be authored as a built-in plugin type, bare package type, scoped package name, relative path, absolute path, orfile://local file URL. - Plugin-specific inner fields are outside the scope of this spec and are preserved during merge.
6. Supported YAML subset
- The parser MUST support indentation-based mappings and sequences.
- The parser MUST support plain, single-quoted, and double-quoted scalars.
- The parser MUST support scalar values:
null,boolean,number, andstring. - The parser MUST support anchors (
&), aliases (*), and merge key (<<) for mappings. - The parser MUST NOT allow tabs for indentation.
- The parser MUST NOT allow multiple YAML documents (
---,...). - The parser MUST NOT allow block scalars (
|,>), YAML tags (!), or non-empty flow collections ([a],{a: 1}). - Empty flow collections
[]and{}MAY be used.
7. Error handling
- Invalid config structure MUST throw an error prefixed with:
[loadConfig] Invalid faas.yaml <filePath> at "<keyPath>": <reason>
- Unsupported YAML syntax/features MUST throw parse errors prefixed with:
[parseYaml]
- Config consumers (for example dev server startup or typegen) SHOULD fail fast when config loading fails.
Examples
defaults:
server:
root: .
base: /api
plugins:
http:
type: http
config:
cookie:
secure: false
session:
secret: replace-me