Noir::ServerlessLayout
File-system layout rules shared by the file-routed serverless platforms
(Cloudflare Pages functions/, Vercel api/, Netlify
netlify/functions/). Detectors and analyzers both need to know which
directory a route is relative to, so the rule lives here rather than in
either layer.
Constants
Files that mark a directory as a deployable project root.
A module importing the Vercel runtime types marks itself as a function.
Instance methods
Netlify's default function directories: netlify/functions/ and
netlify/edge-functions/ under the site's base directory. Returns
{kind, segments_below_it} where kind is functions or
edge-functions.
A Netlify function's name from its path below the functions directory:
hello.mts, hello/hello.mts and hello/index.mts are all hello.
Anything deeper, or a sibling module in a function's own directory, is
a helper and not a function.
Colocated tests (x.test.ts, x.spec.js) and type declarations are
not deployed handlers.
Hidden (.x) and private (_x) entries, which Vercel does not deploy.
Locate the routing directory for path: the first dir_name segment
of its scan-base-relative form (relative, rooted with /) that sits
at the scan root or directly inside a project root. Returns the
absolute project root plus the path segments below the routing dir.
Anchoring on a project root is what keeps src/pages/api/x.ts (Next.js)
or server/api/x.ts (Nuxt) from being read as a Vercel api/ dir, and
netlify/functions/x.ts from being read as Cloudflare functions/.