module

Noir::EggRouterExtractor

Egg.js router registrations, as written in app/router.js and the app/router/** files it requires:

router.get('/users/:id', controller.user.show) router.post('login', '/login', auth, 'user.login') // named route app.router.resources('posts', '/api/posts', controller.posts) const v1 = router.namespace('/v1'); v1.get('/ping', controller.ping.index)

As in egg-core's router argument parsing, a second string argument is the path only when three or more arguments are passed, and the last argument is the controller.

Constants

CALL = /(?<![\w$.])((?:app\.)?[A-Za-z_$][\w$]*)\s*\.\s*(get|post|put|patch|delete|del|head|options|all|resources|redirect)\s*\(/
NAMESPACE = /(?<![\w$.])(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:app\.)?router\s*\.\s*namespace\s*\(\s*(['"`])([^'"`]+)\2/

Instance methods

extract(content : String) : Array(Route)
Source
string_literal(arg : String) : String | Nil

The value of a plain quoted string (no template interpolation).

Source

Nested types