Gathering detailed insights and metrics for find-my-way
Gathering detailed insights and metrics for find-my-way
Gathering detailed insights and metrics for find-my-way
Gathering detailed insights and metrics for find-my-way
npm install find-my-way
Typescript
Module System
Min. Node Version
Node Version
NPM Version
85.4
Supply Chain
99.6
Quality
83.2
Maintenance
100
Vulnerability
100
License
JavaScript (98.07%)
TypeScript (1.93%)
Total Downloads
236,034,102
Last Day
292,643
Last Week
2,207,841
Last Month
9,950,075
Last Year
95,174,854
1,507 Stars
461 Commits
140 Forks
21 Watching
12 Branches
63 Contributors
Minified
Minified + Gzipped
Latest Version
9.1.0
Package Id
find-my-way@9.1.0
Unpacked Size
376.78 kB
Size
57.00 kB
File Count
93
NPM Version
10.8.2
Node Version
20.17.0
Publised On
28 Sept 2024
Cumulative downloads
Total Downloads
Last day
-31.8%
292,643
Compared to previous day
Last week
-7.7%
2,207,841
Compared to previous week
Last month
5.9%
9,950,075
Compared to previous month
Last year
48.7%
95,174,854
Compared to previous year
A crazy fast HTTP router, internally uses an highly performant Radix Tree (aka compact Prefix Tree), supports route params, wildcards, and it's framework independent.
If you want to see a benchmark comparison with the most commonly used routers, see here.
Do you need a real-world example that uses this router? Check out Fastify or Restify.
npm i find-my-way --save
1const http = require('http') 2const router = require('find-my-way')() 3 4router.on('GET', '/', (req, res, params) => { 5 res.end('{"message":"hello world"}') 6}) 7 8const server = http.createServer((req, res) => { 9 router.lookup(req, res) 10}) 11 12server.listen(3000, err => { 13 if (err) throw err 14 console.log('Server listening on: http://localhost:3000') 15})
Instance a new router.
You can pass a default route with the option defaultRoute
.
1const router = require('find-my-way')({ 2 defaultRoute: (req, res) => { 3 res.statusCode = 404 4 res.end() 5 } 6})
In case of a badly formatted url (eg: /hello/%world
), by default find-my-way
will invoke the defaultRoute
, unless you specify the onBadUrl
option:
1const router = require('find-my-way')({ 2 onBadUrl: (path, req, res) => { 3 res.statusCode = 400 4 res.end(`Bad path: ${path}`) 5 } 6})
Trailing slashes can be ignored by supplying the ignoreTrailingSlash
option:
1const router = require('find-my-way')({ 2 ignoreTrailingSlash: true 3}) 4function handler (req, res, params) { 5 res.end('foo') 6} 7// maps "/foo/" and "/foo" to `handler` 8router.on('GET', '/foo/', handler)
Duplicate slashes can be ignored by supplying the ignoreDuplicateSlashes
option:
1const router = require('find-my-way')({ 2 ignoreDuplicateSlashes: true 3}) 4function handler (req, res, params) { 5 res.end('foo') 6} 7// maps "/foo", "//foo", "///foo", etc to `handler` 8router.on('GET', '////foo', handler)
Note that when ignoreTrailingSlash
and ignoreDuplicateSlashes
are both set to true, duplicate slashes will first be removed and then trailing slashes will, meaning //a//b//c//
will be converted to /a/b/c
.
You can set a custom length for parameters in parametric (standard, regex and multi) routes by using maxParamLength
option, the default value is 100 characters.
If the maximum length limit is reached, the default route will be invoked.
1const router = require('find-my-way')({ 2 maxParamLength: 500 3})
If you are using a regex based route, find-my-way
will throw an error if detects potentially catastrophic exponential-time regular expressions (internally uses safe-regex2
).
If you want to disable this behavior, pass the option allowUnsafeRegex
.
1const router = require('find-my-way')({ 2 allowUnsafeRegex: true 3})
According to RFC3986, find-my-way is case sensitive by default.
You can disable this by setting the caseSensitive
option to false
:
in that case, all paths will be matched as lowercase, but the route parameters or wildcards will maintain their original letter casing. You can turn off case sensitivity with:
1const router = require('find-my-way')({ 2 caseSensitive: false 3})
The default query string parser that find-my-way uses is fast-querystring module. You can change this default setting by passing the option querystringParser and use a custom one, such as qs.
1const qs = require('qs') 2const router = require('find-my-way')({ 3 querystringParser: str => qs.parse(str) 4}) 5 6router.on('GET', '/', (req, res, params, store, searchParams) => { 7 assert.equal(searchParams, { foo: 'bar', baz: 'faz' }) 8}) 9 10router.lookup({ method: 'GET', url: '/?foo=bar&baz=faz' }, null)
According to RFC3986, find-my-way separates path and query string with ?
character. But earlier versions also used ;
as delimiter character. To support this behaviour, add the useSemicolonDelimiter
option to true
:
1const router = require('find-my-way')({ 2 useSemicolonDelimiter: true 3})
You can assign a buildPrettyMeta
function to sanitize a route's store
object to use with the prettyPrint
functions. This function should accept a single object and return an object.
1 2const privateKey = new Symbol('private key') 3const store = { token: '12345', [privateKey]: 'private value' } 4 5const router = require('find-my-way')({ 6 buildPrettyMeta: route => { 7 const cleanMeta = Object.assign({}, route.store) 8 9 // remove private properties 10 Object.keys(cleanMeta).forEach(k => { 11 if (typeof k === 'symbol') delete cleanMeta[k] 12 }) 13 14 return cleanMeta // this will show up in the pretty print output! 15 } 16}) 17 18store[privateKey] = 'private value' 19router.on('GET', '/hello_world', (req, res) => {}, store) 20 21router.prettyPrint() 22 23//└── / (-) 24// └── hello_world (GET) 25// • (token) "12345" 26
Register a new route.
1router.on('GET', '/example', (req, res, params, store, searchParams) => { 2 // your code 3})
Last argument, store
is used to pass an object that you can access later inside the handler function. If needed, store
can be updated.
1router.on('GET', '/example', (req, res, params, store) => { 2 assert.equal(store, { message: 'hello world' }) 3}, { message: 'hello world' })
If needed, you can provide a version
route constraint, which will allow you to declare multiple versions of the same route that are used selectively when requests ask for different version using the Accept-Version
header. This is useful if you want to support several different behaviours for a given route and different clients select among them.
If you never configure a versioned route, the 'Accept-Version'
header will be ignored. Remember to set a Vary header in your responses with the value you are using for defining the versioning (e.g.: 'Accept-Version'), to prevent cache poisoning attacks. You can also configure this as part your Proxy/CDN.
The default versioning strategy follows the semver specification. When using lookup
, find-my-way
will automatically detect the Accept-Version
header and route the request accordingly. Internally find-my-way
uses the semver-store
to get the correct version of the route; advanced ranges and pre-releases currently are not supported.
Be aware that using this feature will cause a degradation of the overall performances of the router.
1router.on('GET', '/example', { constraints: { version: '1.2.0' }}, (req, res, params) => { 2 res.end('Hello from 1.2.0!') 3}) 4 5router.on('GET', '/example', { constraints: { version: '2.4.0' }}, (req, res, params) => { 6 res.end('Hello from 2.4.0!') 7}) 8 9// The 'Accept-Version' header could be '1.2.0' as well as '*', '2.x' or '2.4.x'
If you declare multiple versions with the same major or minor find-my-way
will always choose the highest compatible with the Accept-Version
header value.
It's also possible to define a custom versioning strategy during the find-my-way
initialization. In this case the logic of matching the request to the specific handler depends on the versioning strategy you use.
Register a new route for each method specified in the methods
array.
It comes handy when you need to declare multiple routes with the same handler but different methods.
1router.on(['GET', 'POST'], '/example', (req, res, params) => { 2 // your code 3})
To register a parametric path, use the colon before the parameter name. For wildcard use the star. Remember that static routes are always inserted before parametric and wildcard.
1// parametric 2router.on('GET', '/example/:userId', (req, res, params) => {})) 3router.on('GET', '/example/:userId/:secretToken', (req, res, params) => {})) 4 5// wildcard 6router.on('GET', '/example/*', (req, res, params) => {}))
Regular expression routes are supported as well, but pay attention, RegExp are very expensive in term of performance!
If you want to declare a regular expression route, you must put the regular expression inside round parenthesis after the parameter name.
1// parametric with regexp 2router.on('GET', '/example/:file(^\\d+).png', () => {}))
It's possible to define more than one parameter within the same couple of slash ("/"). Such as:
1router.on('GET', '/example/near/:lat-:lng/radius/:r', (req, res, params) => {}))
Remember in this case to use the dash ("-") as parameters separator.
Finally it's possible to have multiple parameters with RegExp.
1router.on('GET', '/example/at/:hour(^\\d{2})h:minute(^\\d{2})m', (req, res, params) => {}))
In this case as parameter separator it's possible to use whatever character is not matched by the regular expression.
The last parameter can be made optional if you add a question mark ("?") at the end of the parameters name.
1router.on('GET', '/example/posts/:id?', (req, res, params) => {}))
In this case you can request /example/posts
as well as /example/posts/1
. The optional param will be undefined if not specified.
Having a route with multiple parameters may affect negatively the performance, so prefer single parameter approach whenever possible, especially on routes which are on the hot path of your application.
Note that you must encode the parameters containing reserved characters.
The routing algorithm matches one node at a time (where the node is a string between two slashes), this means that it cannot know if a route is static or dynamic until it finishes to match the URL.
The nodes are matched in the following order:
So if you declare the following routes
/foo/filename.png
- static route/foo/:filename.png
- route with param filename
and static ending .png
/foo/:filename.:ext
- route with two params filename
and ext
/foo/:filename
- route with one param filename
/*
- wildcard routeYou will have next matching rules:
/foo/filename.png
.png
extension. If one node static ending ends with another node static ending, the node with a longer static ending would have higher priority.
/foo/:filename.png.png
- higher priority, more specific route/foo/:filename.png
- lower priorityOnce a url has been matched, find-my-way
will figure out which handler registered for that path matches the request if there are any constraints.
find-my-way
will check the most constrained handlers first, which means the handlers with the most keys in the constraints
object.
If you just want a path containing a colon without declaring a parameter, use a double colon. For example,
/name::customVerb
will be interpreted as/name:customVerb
The router is able to route all HTTP methods defined by http
core module.
Used to deregister routes.
If no constraint argument is passed, all routes with identical path and method are deregistered, regardless of whether a route has constraints or not.
1router.on('GET', '/example', { constraints: { host: 'fastify.io' } }) 2router.on('GET', '/example', { constraints: { version: '1.x' } }) 3router.on('GET', '/example') 4 5// Deregisters all 3 routes registered above 6router.off('GET', '/example')
If a constraint object is specified, only those routes are deleted that have the same constraints as well as the identical path and method. If an empty object is passed, only unconstrained routes will be deleted.
1router.on('GET', '/example', { constraints: { host: 'fastify.io' } }) 2router.on('GET', '/example', { constraints: { version: '1.x' } }) 3router.on('GET', '/example') 4 5// Deregisters only the third route without constraints 6router.off('GET', '/example', {}) 7 8// Deregisters only the first route 9router.off('GET', '/example', { host: 'fastify.io' })
Deregister a route for each method specified in the methods array. It comes handy when you need to deregister multiple routes with the same path but different methods. As explained above, the constraints will be ignored here.
1router.on('GET', '/example', { constraints: { host: 'fastify.io' } }) 2router.on('POST', '/example', { constraints: { version: '1.x' } }) 3router.on('PUT', '/example') 4 5// Deregisters all 3 routes registered above 6router.off(['POST', 'GET', 'PUT'], '/example')
1router.on('GET', '/example', { constraints: { host: 'fastify.io' } }) // first route 2router.on('POST', '/example', { constraints: { host: 'fastify.io' } }) // second route 3router.on('POST', '/example', { constraints: { host: 'google.de' } }) // third route 4router.on('GET', '/example') // fourth route 5router.on('POST', '/example') // fifth route 6 7// Deregisters only first and second route 8router.off(['POST', 'GET'], '/example', { host: 'fastify.io' }) 9 10// Deregisters only fourth and fifth route 11router.off(['POST', 'GET'], '/example', {})
Finds a route by server route's path (not like find
which finds a route by the url). Returns the route object if found, otherwise returns null
. findRoute
does not compare routes paths directly, instead it compares only paths patters. This means that findRoute
will return a route even if the path passed to it does not match the route's path exactly. For example, if a route is registered with the path /example/:param1
, findRoute
will return the route if the path passed to it is /example/:param2
.
1const handler = (req, res, params) => { 2 res.end('Hello World!') 3} 4router.on('GET', '/:file(^\\S+).png', handler) 5 6router.findRoute('GET', '/:file(^\\S+).png') 7// => { handler: Function, store: Object, params: ['file'] } 8 9router.findRoute('GET', '/:file(^\\D+).jpg') 10// => null
1const handler = (req, res, params) => { 2 res.end('Hello World!') 3} 4router.on('GET', '/:param1', handler) 5 6router.findRoute('GET', '/:param1') 7// => { handler: Function, store: Object, params: ['param1'] } 8 9router.findRoute('GET', '/:param2') 10// => { handler: Function, store: Object, params: ['param1'] }
Checks if a route exists by server route's path (see findRoute
for more details). Returns true
if found, otherwise returns false
.
1router.on('GET', '/:file(^\\S+).png', handler) 2 3router.hasRoute('GET', '/:file(^\\S+).png') 4// => true 5 6router.hasRoute('GET', '/:file(^\\D+).jpg') 7// => false
Start a new search, request
and response
are the server req/res objects.
If a route is found it will automatically call the handler, otherwise the default route will be called.
The url is sanitized internally, all the parameters and wildcards are decoded automatically.
1router.lookup(req, res)
lookup
accepts an optional context which will be the value of this
when executing a handler
1router.on('GET', '*', function(req, res) { 2 res.end(this.greeting); 3}) 4router.lookup(req, res, { greeting: 'Hello, World!' })
lookup
accepts an optional done
callback for case when you use an async deriveConstraint
function.
1router.on('GET', '*', function(req, res) { 2 res.end({ hello: 'world' }); 3}) 4router.lookup(req, res, (err) => { 5 if (err !== null) { 6 // handle error 7 } 8 console.log('Handler executed!!!'); 9})
Return (if present) the route registered in method:path.
The path must be sanitized, all the parameters and wildcards are decoded automatically.
An object with routing constraints should usually be passed as constraints
, containing keys like the host
for the request, the version
for the route to be matched, or other custom constraint values. If the router is using the default versioning strategy, the version value should be conform to the semver specification. If you want to use the existing constraint strategies to derive the constraint values from an incoming request, use lookup
instead of find
. If no value is passed for constraints
, the router won't match any constrained routes. If using constrained routes, passing undefined
for the constraints leads to undefined behavior and should be avoided.
1router.find('GET', '/example', { host: 'fastify.io' }) 2// => { handler: Function, params: Object, store: Object} 3// => null 4 5router.find('GET', '/example', { host: 'fastify.io', version: '1.x' }) 6// => { handler: Function, params: Object, store: Object} 7// => null
find-my-way
builds a tree of routes for each HTTP method. If you call the prettyPrint
without specifying an HTTP method, it will merge all the trees to one and print it.
The merged tree does't represent the internal router structure. Don't use it for debugging.
1findMyWay.on('GET', '/test', () => {}) 2findMyWay.on('GET', '/test/hello', () => {}) 3findMyWay.on('GET', '/testing', () => {}) 4findMyWay.on('GET', '/testing/:param', () => {}) 5findMyWay.on('PUT', '/update', () => {}) 6 7console.log(findMyWay.prettyPrint()) 8// └── / 9// ├── test (GET) 10// │ ├── /hello (GET) 11// │ └── ing (GET) 12// │ └── / 13// │ └── :param (GET) 14// └── update (PUT)
If you want to print the internal tree, you can specify the method
param.
Printed tree will represent the internal router structure. Use it for debugging.
1findMyWay.on('GET', '/test', () => {}) 2findMyWay.on('GET', '/test/hello', () => {}) 3findMyWay.on('GET', '/testing', () => {}) 4findMyWay.on('GET', '/testing/:param', () => {}) 5findMyWay.on('PUT', '/update', () => {}) 6 7console.log(findMyWay.prettyPrint({ method: 'GET' })) 8// └── / 9// └── test (GET) 10// ├── /hello (GET) 11// └── ing (GET) 12// └── / 13// └── :param (GET) 14 15console.log(findMyWay.prettyPrint({ method: 'PUT' })) 16// └── / 17// └── update (PUT)
prettyPrint
accepts an optional setting to print compressed routes. This is useful
when you have a large number of routes with common prefixes. Doesn't represent the
internal router structure. Don't use it for debugging.
1console.log(findMyWay.prettyPrint({ commonPrefix: false })) 2// ├── /test (GET) 3// │ ├── /hello (GET) 4// │ └── ing (GET) 5// │ └── /:param (GET) 6// └── /update (PUT)
To include a display of the store
data passed to individual routes, the
option includeMeta
may be passed. If set to true
all items will be
displayed, this can also be set to an array specifying which keys (if
present) should be displayed. This information can be further sanitized
by specifying a buildPrettyMeta
function which consumes and returns
an object.
1findMyWay.on('GET', '/test', () => {}, { onRequest: () => {}, authIDs: [1, 2, 3] }) 2findMyWay.on('GET', '/test/hello', () => {}, { token: 'df123-4567' }) 3findMyWay.on('GET', '/testing', () => {}) 4findMyWay.on('GET', '/testing/:param', () => {}) 5findMyWay.on('PUT', '/update', () => {}) 6 7console.log(findMyWay.prettyPrint({ commonPrefix: false, includeMeta: ['onRequest'] })) 8// ├── /test (GET) 9// │ • (onRequest) "onRequest()" 10// │ ├── /hello (GET) 11// │ └── ing (GET) 12// │ └── /:param (GET) 13// └── /update (PUT) 14 15console.log(findMyWay.prettyPrint({ commonPrefix: false, includeMeta: true })) 16// ├── /test (GET) 17// │ • (onRequest) "onRequest()" 18// │ • (authIDs) [1,2,3] 19// │ ├── /hello (GET) 20// │ │ • (token) "df123-4567" 21// │ └── ing (GET) 22// │ └── /:param (GET) 23// └── /update (PUT)
Empty router.
1router.reset()
Return the all routes registered at moment, useful for debugging.
1const findMyWay = require('find-my-way')() 2 3findMyWay.on('GET', '/test', () => {}) 4findMyWay.on('GET', '/test/hello', () => {}) 5 6console.log(findMyWay.routes) 7// Will print 8// [ 9// { 10// method: 'GET', 11// path: '/test', 12// opts: {}, 13// handler: [Function], 14// store: undefined 15// }, 16// { 17// method: 'GET', 18// path: '/test/hello', 19// opts: {}, 20// handler: [Function], 21// store: undefined 22// } 23// ]
1const findMyWay = FindMyWay({ 2 defaultRoute: (req, res) => {} 3}) 4 5findMyWay.on('GET', '/user/:userId(^\\d+)', (req, res, params) => {}) 6 7findMyWay.on('GET', '/user/:username(^[a-z]+)', (req, res, params) => {}) 8// Method 'GET' already declared for route ':'
If you want an even nicer api, you can also use the shorthand methods to declare your routes.
For each HTTP supported method, there's the shorthand method. For example:
1router.get(path, handler [, store]) 2router.delete(path, handler [, store]) 3router.head(path, handler [, store]) 4router.patch(path, handler [, store]) 5router.post(path, handler [, store]) 6router.put(path, handler [, store]) 7router.options(path, handler [, store]) 8// ...
If you need a route that supports all methods you can use the all
api.
1router.all(path, handler [, store])
find-my-way
supports restricting handlers to only match certain requests for the same path. This can be used to support different versions of the same route that conform to a semver based versioning strategy, or restricting some routes to only be available on hosts. find-my-way
has the semver based versioning strategy and a regex based hostname constraint strategy built in.
To constrain a route to only match sometimes, pass constraints
to the route options when registering the route:
1findMyWay.on('GET', '/', { constraints: { version: '1.0.2' } }, (req, res) => { 2 // will only run when the request's Accept-Version header asks for a version semver compatible with 1.0.2, like 1.x, or 1.0.x. 3}) 4 5findMyWay.on('GET', '/', { constraints: { host: 'example.com' } }, (req, res) => { 6 // will only run when the request's Host header is `example.com` 7})
Constraints can be combined, and route handlers will only match if all of the constraints for the handler match the request. find-my-way
does a boolean AND with each route constraint, not an OR.
find-my-way
will try to match the most constrained handlers first before handler with fewer or no constraints.
Custom constraining strategies can be added and are matched against incoming requests while trying to maintain find-my-way
's high performance. To register a new type of constraint, you must add a new constraint strategy that knows how to match values to handlers, and that knows how to get the constraint value from a request. Register strategies when constructing a router or use the addConstraintStrategy method.
Add a custom constrain strategy when constructing a router:
1const customResponseTypeStrategy = { 2 // strategy name for referencing in the route handler `constraints` options 3 name: 'accept', 4 // storage factory for storing routes in the find-my-way route tree 5 storage: function () { 6 let handlers = {} 7 return { 8 get: (type) => { return handlers[type] || null }, 9 set: (type, store) => { handlers[type] = store } 10 } 11 }, 12 // function to get the value of the constraint from each incoming request 13 deriveConstraint: (req, ctx) => { 14 return req.headers['accept'] 15 }, 16 // optional flag marking if handlers without constraints can match requests that have a value for this constraint 17 mustMatchWhenDerived: true 18} 19 20const router = FindMyWay({ constraints: { accept: customResponseTypeStrategy } });
Add an async custom constrain strategy when constructing a router:
1const asyncCustomResponseTypeStrategy = { 2 // strategy name for referencing in the route handler `constraints` options 3 name: 'accept', 4 // storage factory for storing routes in the find-my-way route tree 5 storage: function () { 6 let handlers = {} 7 return { 8 get: (type) => { return handlers[type] || null }, 9 set: (type, store) => { handlers[type] = store } 10 } 11 }, 12 // function to get the value of the constraint from each incoming request 13 deriveConstraint: (req, ctx, done) => { 14 done(null, req.headers['accept']) 15 }, 16 // optional flag marking if handlers without constraints can match requests that have a value for this constraint 17 mustMatchWhenDerived: true 18} 19 20const router = FindMyWay({ constraints: { accept: asyncCustomResponseTypeStrategy } });
Add a custom constraint strategy using the addConstraintStrategy
method:
1const customResponseTypeStrategy = { 2 // strategy name for referencing in the route handler `constraints` options 3 name: 'accept', 4 // storage factory for storing routes in the find-my-way route tree 5 storage: function () { 6 let handlers = {} 7 return { 8 get: (type) => { return handlers[type] || null }, 9 set: (type, store) => { handlers[type] = store } 10 } 11 }, 12 // function to get the value of the constraint from each incoming request 13 deriveConstraint: (req, ctx) => { 14 return req.headers['accept'] 15 }, 16 // optional flag marking if handlers without constraints can match requests that have a value for this constraint 17 mustMatchWhenDerived: true 18} 19 20const router = FindMyWay(); 21router.addConstraintStrategy(customResponseTypeStrategy);
Once a custom constraint strategy is registered, routes can be added that are constrained using it:
1findMyWay.on('GET', '/', { constraints: { accept: 'application/fancy+json' } }, (req, res) => { 2 // will only run when the request's Accept header asks for 'application/fancy+json' 3}) 4 5findMyWay.on('GET', '/', { constraints: { accept: 'application/fancy+xml' } }, (req, res) => { 6 // will only run when the request's Accept header asks for 'application/fancy+xml' 7})
Constraint strategies should be careful to make the deriveConstraint
function performant as it is run for every request matched by the router. See the lib/strategies
directory for examples of the built in constraint strategies.
By default, find-my-way
uses a built in strategies for the version constraint that uses semantic version based matching logic, which is detailed below. It is possible to define an alternative strategy:
1const customVersioning = { 2 // replace the built in version strategy 3 name: 'version', 4 // provide a storage factory to store handlers in a simple way 5 storage: function () { 6 let versions = {} 7 return { 8 get: (version) => { return versions[version] || null }, 9 set: (version, store) => { versions[version] = store } 10 } 11 }, 12 deriveConstraint: (req, ctx) => { 13 return req.headers['accept'] 14 }, 15 mustMatchWhenDerived: true, // if the request is asking for a version, don't match un-version-constrained handlers 16 validate (value) { // optional validate function, validates the assigned value at route-configuration (the .on function) time (not the runtime-value) 17 assert(typeof value === 'string', 'Version should be a string') 18 } 19} 20 21const router = FindMyWay({ constraints: { version: customVersioning } });
The custom strategy object should contain next properties:
storage
- a factory function to store lists of handlers for each possible constraint value. The storage object can use domain-specific storage mechanisms to store handlers in a way that makes sense for the constraint at hand. See lib/strategies
for examples, like the version
constraint strategy that matches using semantic versions, or the host
strategy that allows both exact and regex host constraints.deriveConstraint
- the function to determine the value of this constraint given a requestThe signature of the functions and objects must match the one from the example above.
Please, be aware, if you use your own constraining strategy - you use it on your own risk. This can lead both to the performance degradation and bugs which are not related to find-my-way
itself!
It is inspired by the echo router, some parts have been extracted from trekjs router.
find-my-way - MIT
trekjs/router - MIT
Copyright © 2017-2019 Tomas Della Vedova
Stable Version
2
7.5/10
Summary
find-my-way has a ReDoS vulnerability in multiparametric routes
Affected Versions
>= 5.5.0, < 8.2.2
Patched Versions
8.2.2
7.5/10
Summary
find-my-way has a ReDoS vulnerability in multiparametric routes
Affected Versions
>= 9.0.0, < 9.0.1
Patched Versions
9.0.1
2
5.9/10
Summary
Web Cache Poisoning in find-my-way
Affected Versions
>= 3.0.0, < 3.0.5
Patched Versions
3.0.5
5.9/10
Summary
Web Cache Poisoning in find-my-way
Affected Versions
< 2.2.5
Patched Versions
2.2.5
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 17/27 approved changesets -- score normalized to 6
Reason
5 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More