class
Noir::JSParser
- Noir::JSParser
- Reference
- Object
Overview
JSParser is a simple parser for JavaScript route-related patterns
Defined in:
miniparsers/js_parser.crConstant Summary
-
HTTP_CLIENT_RECEIVERS =
Set {"request", "axios", "superagent", "supertest", "got", "needle", "unirest", "ky", "phin", "chai"} -
Pre-scan tokens to identify router variables Routers are identified by:
- Assignment from express.Router(): const router = express.Router()
- Having route methods called on them: router.get(...)
Receivers that are HTTP clients, never routers.
request.get(url, opts)in a test file has the same token shape asrouter.get(path, handler)— an identifier, a verb, a path-ish first argument and a second argument — soroute_handler_arg?cannot separate them and deliberately errs toward keeping the route. The receiver name can: none of these is ever assigned an Express/Koa/Fastify router, and NodeBB'stest/*.jsalone turns 385 such calls into routes that do not exist. Keep the list to library names that would be perverse to use for a router — a receiver namedapiorclientmay well be one, so neither is listed.