class

Detector::Javascript::VercelFunctions

Inherits Detector < Reference < Object

A Vercel Function: a Node.js module under a project's root api/ directory exporting a handler, in a Vercel project (vercel.json / now.json, an @vercel/node / @vercel/functions dependency) or importing those packages itself. The root anchoring and the Vercel signal keep Next.js pages/api/ and Nuxt server/api/ out.

Constants

EXTENSIONS = {".js", ".mjs", ".ts", ".tsx"}
HANDLER_EXPORT = /(?:^|[^\w$.])export\s+default\b|(?:^|[^\w$.])module\s*\.\s*exports\s*=(?!=)|(?:^|[^\w$.])export\s+(?:(?:async\s+)?function\s+|(?:const|let|var)\s+)(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/m

Instance methods

applicable?(filename : String) : Bool

Cheap filename-only filter the detector pass uses to skip detect on files the detector cannot possibly match. The default true preserves prior behavior (every detector runs on every file). Override with the same predicate the body of detect starts with — e.g., filename.ends_with?(".py") for a Python framework detector — so the detector loop avoids the detect dispatch on files outside the detector's language.

On large codebases (saleor's 4255 .py files) this lifts ~100 virtual detect calls per file out of the hot loop because most detectors' inner first-line is exactly this kind of cheap filename check.

Source
detect(filename : String, file_contents : String) : Bool
Source
name

The tech name; detector_for overrides it. Empty on the bare base.

Source
path_sensitive?

Whether applicable? inspects more than the basename — directory segments (/metadata/, /.kamal/) or root placement.

The detect loop memoizes applicable? by basename, so a detector that consults the path but does not declare it here has its path gate silently deleted: applicable? is only ever asked about the bare filename. That is a false-negative, not a crash, so nothing fails loudly. Noir::Detection.path_sensitive? also probes for this, but the probe is fail-open — a probe whose basename independently matches masks the directory gate behind it (this is exactly how the Hasura metadata/** gate was lost). Declare it explicitly.

Guarded by spec/unit_test/detector/applicable_lookup_fidelity_spec.cr.

Source