class

Analyzer::Javascript::Hono

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

Constants

DOC_CHAIN_RE = /(?<![\w$])new\s+(?:OpenAPIHono|Hono)\s*(?:<[^;\n]*>)?\s*\(\s*\)\s*\.\s*doc(?:31)?\s*\(\s*['"]([^'"]+)['"]/
DOC_ROUTE_RE = /(?<![\w$])([A-Za-z_$][\w$]*)\s*\.\s*doc(?:31)?\s*\(\s*['"]([^'"]+)['"]/
EVENT_EMITTER_RECEIVER = /\A(?:ee|io|ws|process|events?|\w*(?:[Ee]mitter|[Ss]ocket|[Ss]tream))\z/
HTTP_METHODS = ["get", "post", "put", "delete", "patch", "options", "head", "query"] of ::String
ON_ROUTE_CALL_PATTERN = /\.(?:\s|\n|\r)*on(?:\s|\n|\r)*\(/
ON_ROUTE_RE = /(?<![\w$])([A-Za-z_$][\w$]*)\s*\.\s*on\s*\(\s*(?:['"](\w+)['"]|\[([^\]\n]+)\])\s*,\s*['"]([\/*][^'"\n]*)['"]/

<receiver>.on('GET', '/path', …) (method in group 2) or .on(['GET', 'POST'], '/path', …) (group 3); the path is group 4. Any receiver (books, api, …) with a / or * path — an event name is neither — except the usual event-emitter names, whose .on('get', '/room/1', cb) has the same shape.

OPENAPI_RECEIVER_RE = /(?<![\w$])(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*new\s+(?:OpenAPIHono|Hono)\b/

@hono/zod-openapi: createRoute({ method, path, request }) declares a route (served once handed to app.openapi(...)), and app.doc(path) serves the generated spec. Routes are reported where they are declared, under that file's mount prefixes. ponytail: a createRoute in a *.routes.ts takes that file's prefixes, not those of the router that registers it; follow .openapi( imports if those prefixes turn out to differ in practice. db.doc('users/1') (Firestore and friends) is the same call shape on a different receiver. Only an app built with new OpenAPIHono / new Hono.

ROUTE_CALL_RES = HTTP_METHODS.map do |m| {m, /\b(?:app|router|hono)\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
line_to_endpoints(line : String) : Array(Endpoint)
Source
line_to_params(line : String) : Array(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