Repository navigation
Map Serverless Framework endpoints from serverless.yml - #132
Merged
haydenschmitty merged 2 commits intoNov 16, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Fixes #131
Backends whose endpoints are declared in
serverless.ymlrather than in code now have their endpoints on the map, linked to the website's requests and checked by Health.scripts/lib/serverless.mjs: a small YAML reader (no dependencies) forserverless.yml,serverless-*.ymlandserverless_*.yml, following${file(...)}includes (with an optional:key) and function lists split across files.httpandhttpApievents: long form, short form (http: GET /orders),anyand*. Each one sits in the file itshandler: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.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.!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 CloudFormationAWS::ApiGatewayresources, and authorizers set only at the provider level.How I tested it
tests/serverless.test.mjswith a generic todo-app sample intests/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).http/httpApievents 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
npm testpasses (475/475)claude plugin validate .passesCHANGELOG.mdupdated, if people will notice the change