Skip to content

Map Serverless Framework endpoints from serverless.yml - #132

Merged
haydenschmitty merged 2 commits into
haydenschmitty:mainfrom
ShehanEk:feat/serverless-routes
Nov 16, 2026
Merged

haydenschmitty merged 2 commits into
haydenschmitty:mainfrom
ShehanEk:feat/serverless-routes

Conversation

@ShehanEk

@ShehanEk ShehanEk commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Fixes #131

Backends whose endpoints are declared in serverless.yml rather than in code now have their endpoints on the map, linked to the website's requests and checked by Health.

  • New scripts/lib/serverless.mjs: a small YAML reader (no dependencies) for serverless.yml, serverless-*.yml and serverless_*.yml, following ${file(...)} includes (with an optional :key) and function lists split across files.
  • Endpoints come from http and httpApi events: long form, short form (http: GET /orders), any and *. Each one sits in the file its handler: names, followed through a re-export (export { x } from, export *), or one hop into another file's function when the handler only passes the request on to it.
  • Health: an authorizer, private: true (API key), or a sign-in check handed to the wrapper counts as protecting the endpoint; otherwise the handler is read for its own check, as for other frameworks.
  • The scan summary gets a SERVERLESS section: endpoint count, functions whose handler file wasn't found, and background functions (schedule, sqs, stream, eventBridge, s3…) for a worker node.
  • CloudFormation tags (!Ref, !GetAtt, !Sub), ${opt:…}/${self:…} variables, anchors and merge keys are read without failing.

Not covered yet: variables inside handler paths, JavaScript configs (${file(./x.js)}), plain CloudFormation AWS::ApiGateway resources, and authorizers set only at the provider level.

How I tested it

  • tests/serverless.test.mjs with a generic todo-app sample in tests/fixtures/serverless-app/; without the change, its 6 end-to-end tests fail (the other 3 test the YAML reader on its own). It also covers a handler answering at two addresses (one with an authorizer, one without), a handler whose own name sounds like a check, and YAML with stray brackets and very long lines (read quickly, never forever).
  • A real TypeScript serverless backend (one repo, 10 Serverless config files, AWS Lambda + API Gateway). Before: 0 endpoints, Endpoint sign-in skipped. After: all 328 http/httpApi events found across 61 handler files, Endpoint sign-in checks all 328, and 98 background functions are listed. CI has only run locally so far (Node 20, Windows).

Checklist

  • No new dependencies
  • Anything the map shows people is in plain language
  • No secret values stored or printed
  • No details of a real private project in code, comments, docs or screenshots
  • npm test passes (475/475)
  • claude plugin validate . passes
  • CHANGELOG.md updated, if people will notice the change

A backend whose API Gateway routes are declared in serverless.yml rather
than in code showed no endpoints, so the website's requests to it weren't
linked and Health skipped its sign-in check.

A small YAML reader (no dependencies) reads http and httpApi events from
serverless*.yml and the files they include with ${file(...)}, and places
each endpoint in its handler's file: through a re-export, or into the
function a wrapper hands the request to. Health counts an authorizer,
private: true or a sign-in check handed to the wrapper as protecting the
endpoint. Background functions are listed in the scan summary.
- A stray ] or } in a flow list or map (key: [}]) made the YAML reader
  loop forever; each pass now moves forward.
- Long lines were slow to read (a trailing-space pattern and the key
  pattern backtracked); keys are now split in one pass.
- A wrapper's own name, or the function it hands on to, no longer counts
  as a sign-in check (deleteUser, getSession).
- A handler answering at several addresses gets a Health verdict per
  address, so one with an authorizer can't hide one without.
- path: '' is the root endpoint rather than being dropped.
@haydenschmitty
haydenschmitty merged commit 4bd04ca into haydenschmitty:main Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serverless Framework backends show no endpoints

2 participants