class Detector::Javascript::Express

Defined in:

detector/detectors/javascript/express.cr

Constant Summary

SIGNAL = Regex.union(/require\(['"]express['"]\)/, /from ['"]express['"]/, /app\.use\(express\.json\(\)\)/, /app\.use\(express\.urlencoded\(\{ extended: true \}\)\)/)

Single precompiled alternation — one PCRE2 scan over the file instead of up to four separate .match passes. Regex.union wraps each branch verbatim, so the boolean result is identical.

SOURCE_EXTENSIONS = [".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx"] of ::String

Mirrors the extensions: list above. The two drifted before: the gate admitted .jsx/.tsx, this guard did not, so a project whose only Express source was a .jsx file reported "No technologies detected" while the analyzer was perfectly able to parse it.

Class Method Summary

Instance Method Summary

Instance methods inherited from class Detector

applicable?(filename : String) : Bool applicable?, base_relative_path(filename : String) : String base_relative_path, content_matches?(file_contents : String, markers : Regex) : Bool content_matches?, detect(filename : String, file_contents : String) : Bool detect, gemfile_dependency?(file_contents : String, gem_name : String) : Bool gemfile_dependency?, gemspec_dependency?(file_contents : String, gem_name : String) : Bool gemspec_dependency?, idempotent? : Bool idempotent?, logger : NoirLogger logger, name : String name, path_sensitive? : Bool path_sensitive?

Constructor methods inherited from class Detector

new(options : Hash(String, YAML::Any)) new

Macros inherited from class Detector

detector_for(tech, extensions = nil, basenames = nil, path_segments = nil, idempotent = nil) detector_for

Class Method Detail

def self.tech_name : String #

The tech name without needing an instance, so the registry can be read off the classes themselves rather than from a parallel list.


[View source]

Instance Method Detail

def applicable?(filename : String) : Bool #

No basenames: %w[package.json]: "express": "^4.x" in a manifest is not evidence of a hand-written Express app, because Feathers, Sails and NestJS all carry Express as a transitive dependency. Detection stays source-only. The declaration used to be there and was dead anyway — #detect rejected every non-source filename — so dropping it changes no result, it just stops handing package.json to a #detect that always answered false.


[View source]
def detect(filename : String, file_contents : String) : Bool #

[View source]
def set_name #

No basenames: %w[package.json]: "express": "^4.x" in a manifest is not evidence of a hand-written Express app, because Feathers, Sails and NestJS all carry Express as a transitive dependency. Detection stays source-only. The declaration used to be there and was dead anyway — #detect rejected every non-source filename — so dropping it changes no result, it just stops handing package.json to a #detect that always answered false.


[View source]