; TypeScript entry-point detection queries
; Captures: @node (full declaration), @name (entry point function/class name)

; === Lambda/serverless handler exports ===

; export const handler = ...
; export const main = ...
(export_statement
  (lexical_declaration
    (variable_declarator
      name: (identifier) @name
      (#match? @name "^(handler|main|lambdaHandler)$")))) @node

; === Exported handler functions ===

; export function handler() {}
; export async function handler() {}
(export_statement
  (function_declaration
    name: (identifier) @name
    (#match? @name "^(handler|main|lambdaHandler)$"))) @node

; === CDK Construct / Stack classes ===

; export class MyStack extends Stack {}
(export_statement
  (class_declaration
    name: (type_identifier) @name
    (class_heritage
      (extends_clause
        value: (identifier) @_parent
        (#match? @_parent "^(Construct|Stack|NestedStack|Stage)$"))))) @node

; === Express/Hono/Fastify app exports ===

; export const app = express() / new Hono() / new App()
(export_statement
  (lexical_declaration
    (variable_declarator
      name: (identifier) @name
      (#match? @name "^(app|server|router)$")))) @node

; === Default export of app/handler ===

; export default app
(export_statement
  "default"
  (identifier) @name) @node
