class

Analyzer::Javascript::Fastify

Inherits Analyzer::Javascript::JavascriptEngine < Analyzer < FileHelper < Reference < Object

Constants

AUTO_PREFIX_RE = /\bautoPrefix\s*=\s*['"]([^'"]+)['"]/

export const autoPrefix = '/x' (or CJS module.exports.autoPrefix = '/x') lets a route file declare its own autoload prefix. The \bautoPrefix\s*=\s*<string> shape matches the assignment but not a read like reply.redirect(autoPrefix).

AUTOLOAD_MARKERS_RE = Regex.union("@fastify/autoload", "fastify-autoload")

Markers that a file configures @fastify/autoload. Both the scoped package and the legacy bare name are matched so older projects work. Precompiled once — a single PCRE2-JIT scan replaces two naive String#includes? substring scans. Regex.union auto-escapes each literal, so it is provably equivalent to the OR-of-includes? it replaces.

HTTP_METHODS = ["get", "post", "put", "delete", "patch", "options", "head", "query"] of ::String
QUERY_METHOD_MARKERS_RE = Regex.union(/\baddHttpMethod\s*\(\s*['"]QUERY['"]/i, /fastify-http-query/)

Markers indicating that HTTP QUERY method support is registered.

ROUTE_CALL_RES = HTTP_METHODS.map do |m| {m, /\b(?:fastify|app|server)\s*\.\s*#{m}\s*\(\s*['"]([^'"]+)['"]/} end.to_h

Compiled once — an interpolated regex literal would otherwise be rebuilt (full PCRE2 compile) for every method on every line.

Class methods

tech_name
Source

Instance methods

analyze
Source
extract_path_from_route_handler(line : String) : String
Source
line_to_endpoint(line : String, has_query : Bool = true) : Endpoint
Source
line_to_param(line : String) : Param
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source

Nested types