Socket
Socket
Sign inDemoInstall

find-my-way

Package Overview
Dependencies
Maintainers
2
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-my-way - npm Package Compare versions

Comparing version 3.0.5 to 4.0.0

lib/constrainer.js

37

bench.js

@@ -26,3 +26,2 @@ 'use strict'

findMyWay.on('GET', '/abc/def/ghi/lmn/opq/rst/uvz', () => true)
findMyWay.on('GET', '/', { version: '1.2.0' }, () => true)

@@ -43,28 +42,37 @@ findMyWay.on('GET', '/products', () => true)

findMyWay.on('GET', '/pages', () => true)
findMyWay.on('POST', '/pages', () => true)
findMyWay.on('GET', '/pages/:id', () => true)
const constrained = new FindMyWay()
constrained.on('GET', '/', () => true)
constrained.on('GET', '/versioned', () => true)
constrained.on('GET', '/versioned', { constraints: { version: '1.2.0' } }, () => true)
constrained.on('GET', '/versioned', { constraints: { version: '2.0.0', host: 'example.com' } }, () => true)
constrained.on('GET', '/versioned', { constraints: { version: '2.0.0', host: 'fastify.io' } }, () => true)
suite
.add('lookup static route', function () {
findMyWay.lookup({ method: 'GET', url: '/', headers: {} }, null)
findMyWay.lookup({ method: 'GET', url: '/', headers: { host: 'fastify.io' } }, null)
})
.add('lookup dynamic route', function () {
findMyWay.lookup({ method: 'GET', url: '/user/tomas', headers: {} }, null)
findMyWay.lookup({ method: 'GET', url: '/user/tomas', headers: { host: 'fastify.io' } }, null)
})
.add('lookup dynamic multi-parametric route', function () {
findMyWay.lookup({ method: 'GET', url: '/customer/john-doe', headers: {} }, null)
findMyWay.lookup({ method: 'GET', url: '/customer/john-doe', headers: { host: 'fastify.io' } }, null)
})
.add('lookup dynamic multi-parametric route with regex', function () {
findMyWay.lookup({ method: 'GET', url: '/at/12h00m', headers: {} }, null)
findMyWay.lookup({ method: 'GET', url: '/at/12h00m', headers: { host: 'fastify.io' } }, null)
})
.add('lookup long static route', function () {
findMyWay.lookup({ method: 'GET', url: '/abc/def/ghi/lmn/opq/rst/uvz', headers: {} }, null)
findMyWay.lookup({ method: 'GET', url: '/abc/def/ghi/lmn/opq/rst/uvz', headers: { host: 'fastify.io' } }, null)
})
.add('lookup long dynamic route', function () {
findMyWay.lookup({ method: 'GET', url: '/user/qwertyuiopasdfghjklzxcvbnm/static', headers: {} }, null)
findMyWay.lookup({ method: 'GET', url: '/user/qwertyuiopasdfghjklzxcvbnm/static', headers: { host: 'fastify.io' } }, null)
})
.add('lookup static route on constrained router', function () {
constrained.lookup({ method: 'GET', url: '/', headers: { host: 'fastify.io' } }, null)
})
.add('lookup static versioned route', function () {
findMyWay.lookup({ method: 'GET', url: '/', headers: { 'accept-version': '1.x' } }, null)
constrained.lookup({ method: 'GET', url: '/versioned', headers: { 'accept-version': '1.x', host: 'fastify.io' } }, null)
})
.add('lookup static constrained (version & host) route', function () {
constrained.lookup({ method: 'GET', url: '/versioned', headers: { 'accept-version': '2.x', host: 'fastify.io' } }, null)
})
.add('find static route', function () {

@@ -88,5 +96,8 @@ findMyWay.find('GET', '/', undefined)

})
.add('find static versioned route', function () {
findMyWay.find('GET', '/', '1.x')
.add('find long nested dynamic route', function () {
findMyWay.find('GET', '/posts/10/comments/42/author', undefined)
})
.add('find long nested dynamic route with other method', function () {
findMyWay.find('POST', '/posts/10/comments', undefined)
})
.add('find long nested dynamic route', function () {

@@ -93,0 +104,0 @@ findMyWay.find('GET', '/posts/10/comments/42/author', undefined)

@@ -60,2 +60,15 @@ import { IncomingMessage, ServerResponse } from 'http';

interface ConstraintStrategy<V extends HTTPVersion> {
name: string,
mustMatchWhenDerived?: boolean,
storage() : {
get(version: String) : Handler<V> | null,
set(version: String, store: Handler<V>) : void,
del(version: String) : void,
empty() : void
},
validate(value: unknown): void,
deriveConstraint<Context>(req: Req<V>, ctx?: Context) : String,
}
interface Config<V extends HTTPVersion> {

@@ -81,10 +94,4 @@ ignoreTrailingSlash?: boolean;

versioning? : {
storage() : {
get(version: String) : Handler<V> | null,
set(version: String, store: Handler<V>) : void,
del(version: String) : void,
empty() : void
},
deriveVersion<Context>(req: Req<V>, ctx?: Context) : String,
constraints? : {
[key: string]: ConstraintStrategy<V>
}

@@ -94,3 +101,3 @@ }

interface RouteOptions {
version: string;
constraints?: { [key: string]: any }
}

@@ -148,3 +155,3 @@

path: string,
version?: string
constraints?: { [key: string]: any }
): FindResult<V> | null;

@@ -151,0 +158,0 @@

@@ -20,2 +20,4 @@ 'use strict'

const Node = require('./node')
const Constrainer = require('./lib/constrainer')
const NODE_TYPES = Node.prototype.types

@@ -29,4 +31,2 @@ const httpMethods = http.METHODS

const acceptVersionStrategy = require('./lib/accept-version')
function Router (opts) {

@@ -56,3 +56,3 @@ if (!(this instanceof Router)) {

this.allowUnsafeRegex = opts.allowUnsafeRegex || false
this.versioning = opts.versioning || acceptVersionStrategy(false)
this.constrainer = new Constrainer(opts.constraints)
this.trees = {}

@@ -96,11 +96,17 @@ this.routes = []

// method validation
assert(typeof method === 'string', 'Method should be a string')
assert(httpMethods.indexOf(method) !== -1, `Method '${method}' is not an http method.`)
// version validation
if (opts.version !== undefined) {
assert(typeof opts.version === 'string', 'Version should be a string')
let constraints = {}
if (opts.constraints !== undefined) {
assert(typeof opts.constraints === 'object' && opts.constraints !== null, 'Constraints should be an object')
if (Object.keys(opts.constraints).length !== 0) {
constraints = opts.constraints
}
}
this.constrainer.validateConstraints(constraints)
// Let the constrainer know if any constraints are being used now
this.constrainer.noteUsage(constraints)
const params = []

@@ -117,7 +123,2 @@ var j = 0

const version = opts.version
if (version != null && this.versioning.disabled) {
this.versioning = acceptVersionStrategy(true)
}
for (var i = 0, len = path.length; i < len; i++) {

@@ -127,2 +128,9 @@ // search for parametric or wildcard routes

if (path.charCodeAt(i) === 58) {
if (i !== len - 1 && path.charCodeAt(i + 1) === 58) {
// It's a double colon. Let's just replace it with a single colon and go ahead
path = path.slice(0, i) + path.slice(i + 1)
len = path.length
continue
}
var nodeType = NODE_TYPES.PARAM

@@ -137,3 +145,3 @@ j = i + 1

// add the static part of the route to the tree
this._insert(method, staticPart, NODE_TYPES.STATIC, null, null, null, null, version)
this._insert(method, staticPart, NODE_TYPES.STATIC, null, null, null, null, constraints)

@@ -180,3 +188,3 @@ // isolate the parameter name

}
return this._insert(method, completedPath, nodeType, params, handler, store, regex, version)
return this._insert(method, completedPath, nodeType, params, handler, store, regex, constraints)
}

@@ -188,3 +196,3 @@ // add the parameter and continue with the search

}
this._insert(method, staticPart, nodeType, params, null, null, regex, version)
this._insert(method, staticPart, nodeType, params, null, null, regex, constraints)

@@ -194,6 +202,6 @@ i--

} else if (path.charCodeAt(i) === 42) {
this._insert(method, path.slice(0, i), NODE_TYPES.STATIC, null, null, null, null, version)
this._insert(method, path.slice(0, i), NODE_TYPES.STATIC, null, null, null, null, constraints)
// add the wildcard parameter
params.push('*')
return this._insert(method, path.slice(0, len), NODE_TYPES.MATCH_ALL, params, handler, store, null, version)
return this._insert(method, path.slice(0, len), NODE_TYPES.MATCH_ALL, params, handler, store, null, constraints)
}

@@ -207,6 +215,6 @@ }

// static route
this._insert(method, path, NODE_TYPES.STATIC, params, handler, store, null, version)
this._insert(method, path, NODE_TYPES.STATIC, params, handler, store, null, constraints)
}
Router.prototype._insert = function _insert (method, path, kind, params, handler, store, regex, version) {
Router.prototype._insert = function _insert (method, path, kind, params, handler, store, regex, constraints) {
const route = path

@@ -220,5 +228,6 @@ var prefix = ''

// Boot the tree for this method if it doesn't exist yet
var currentNode = this.trees[method]
if (typeof currentNode === 'undefined') {
currentNode = new Node({ method: method, versions: this.versioning.storage() })
currentNode = new Node({ method: method, constrainer: this.constrainer })
this.trees[method] = currentNode

@@ -240,32 +249,9 @@ }

if (len < prefixLen) {
node = new Node(
{
method: method,
prefix: prefix.slice(len),
children: currentNode.children,
kind: currentNode.kind,
handler: currentNode.handler,
regex: currentNode.regex,
versions: currentNode.versions
}
)
if (currentNode.wildcardChild !== null) {
node.wildcardChild = currentNode.wildcardChild
}
node = currentNode.split(len)
// reset the parent
currentNode
.reset(prefix.slice(0, len), this.versioning.storage())
.addChild(node)
// if the longest common prefix has the same length of the current path
// the handler should be added to the current node, to a child otherwise
if (len === pathLen) {
if (version) {
assert(!currentNode.getVersionHandler(version), `Method '${method}' already declared for route '${route}' version '${version}'`)
currentNode.setVersionHandler(version, handler, params, store)
} else {
assert(!currentNode.handler, `Method '${method}' already declared for route '${route}'`)
currentNode.setHandler(handler, params, store)
}
assert(!currentNode.getHandler(constraints), `Method '${method}' already declared for route '${route}' with constraints '${JSON.stringify(constraints)}'`)
currentNode.addHandler(handler, params, store, constraints)
currentNode.kind = kind

@@ -279,9 +265,5 @@ } else {

regex: regex,
versions: this.versioning.storage()
constrainer: this.constrainer
})
if (version) {
node.setVersionHandler(version, handler, params, store)
} else {
node.setHandler(handler, params, store)
}
node.addHandler(handler, params, store, constraints)
currentNode.addChild(node)

@@ -303,9 +285,4 @@ }

// there are not children within the given label, let's create a new one!
node = new Node({ method: method, prefix: path, kind: kind, regex: regex, versions: this.versioning.storage() })
if (version) {
node.setVersionHandler(version, handler, params, store)
} else {
node.setHandler(handler, params, store)
}
node = new Node({ method: method, prefix: path, kind: kind, handlers: null, regex: regex, constrainer: this.constrainer })
node.addHandler(handler, params, store, constraints)
currentNode.addChild(node)

@@ -315,9 +292,4 @@

} else if (handler) {
if (version) {
assert(!currentNode.getVersionHandler(version), `Method '${method}' already declared for route '${route}' version '${version}'`)
currentNode.setVersionHandler(version, handler, params, store)
} else {
assert(!currentNode.handler, `Method '${method}' already declared for route '${route}'`)
currentNode.setHandler(handler, params, store)
}
assert(!currentNode.getHandler(constraints), `Method '${method}' already declared for route '${route}' with constraints '${JSON.stringify(constraints)}'`)
currentNode.addHandler(handler, params, store, constraints)
}

@@ -380,3 +352,3 @@ return

Router.prototype.lookup = function lookup (req, res, ctx) {
var handle = this.find(req.method, sanitizeUrl(req.url), this.versioning.deriveVersion(req, ctx))
var handle = this.find(req.method, sanitizeUrl(req.url), this.constrainer.deriveConstraints(req, ctx))
if (handle === null) return this._defaultRoute(req, res, ctx)

@@ -388,5 +360,5 @@ return ctx === undefined

Router.prototype.find = function find (method, path, version) {
Router.prototype.find = function find (method, path, derivedConstraints) {
var currentNode = this.trees[method]
if (!currentNode) return null
if (currentNode === undefined) return null

@@ -409,3 +381,3 @@ if (path.charCodeAt(0) !== 47) { // 47 is '/'

var pindex = 0
var params = []
var params = null
var i = 0

@@ -417,10 +389,6 @@ var idxInOriginalPath = 0

var prefix = currentNode.prefix
var prefixLen = prefix.length
var len = 0
var previousPath = path
// found the route
if (pathLen === 0 || path === prefix) {
var handle = version === undefined
? currentNode.handler
: currentNode.getVersionHandler(version)
var handle = derivedConstraints !== undefined ? currentNode.getMatchingHandler(derivedConstraints) : currentNode.unconstrainedHandler
if (handle !== null && handle !== undefined) {

@@ -444,2 +412,6 @@ var paramsObj = {}

var prefixLen = prefix.length
var len = 0
var previousPath = path
// search for the longest common prefix

@@ -455,5 +427,3 @@ i = pathLen < prefixLen ? pathLen : prefixLen

var node = version === undefined
? currentNode.findChild(path)
: currentNode.findVersionChild(version, path)
var node = currentNode.findMatchingChild(derivedConstraints, path)

@@ -516,2 +486,3 @@ if (node === null) {

}
params || (params = [])
params[pindex++] = decoded

@@ -531,2 +502,3 @@ path = path.slice(i)

}
params || (params = [])
params[pindex] = decoded

@@ -551,2 +523,3 @@ currentNode = node

if (!node.regex.test(decoded)) return null
params || (params = [])
params[pindex++] = decoded

@@ -576,2 +549,3 @@ path = path.slice(i)

}
params || (params = [])
params[pindex++] = decoded

@@ -595,3 +569,3 @@ path = path.slice(i)

}
var handle = node.handler
var handle = node.handlers[0]
if (handle !== null && handle !== undefined) {

@@ -598,0 +572,0 @@ return {

function prettyPrintFlattenedNode (flattenedNode, prefix, tail) {
var paramName = ''
var methods = new Set(flattenedNode.nodes.map(node => node.method))
const printHandlers = []
if (flattenedNode.prefix.includes(':')) {
flattenedNode.nodes.forEach((node, index) => {
var params = node.handler.params
var param = params[params.length - 1]
if (methods.size > 1) {
if (index === 0) {
paramName += param + ` (${node.method})\n`
return
}
paramName += prefix + ' :' + param + ` (${node.method})`
paramName += (index === methods.size - 1 ? '' : '\n')
} else {
paramName = params[params.length - 1] + ` (${node.method})`
}
})
} else if (methods.size) {
paramName = ` (${Array.from(methods).join('|')})`
for (const node of flattenedNode.nodes) {
for (const handler of node.handlers) {
printHandlers.push({ method: node.method, ...handler })
}
}
printHandlers.forEach((handler, index) => {
let suffix = `(${handler.method}`
if (Object.keys(handler.constraints).length > 0) {
suffix += ' ' + JSON.stringify(handler.constraints)
}
suffix += ')'
let name = ''
if (flattenedNode.prefix.includes(':')) {
var params = handler.params
name = params[params.length - 1]
if (index > 0) {
name = ':' + name
}
} else if (index > 0) {
name = flattenedNode.prefix
}
if (index === 0) {
paramName += name + ` ${suffix}`
return
} else {
paramName += '\n'
}
paramName += prefix + ' ' + name + ` ${suffix}`
})
var tree = `${prefix}${tail ? '└── ' : '├── '}${flattenedNode.prefix}${paramName}\n`

@@ -36,3 +51,3 @@

function flattenNode (flattened, node) {
if (node.handler) {
if (node.handlers.length > 0) {
flattened.nodes.push(node)

@@ -39,0 +54,0 @@ }

'use strict'
const assert = require('assert')
const deepEqual = require('fast-deep-equal')

@@ -18,11 +19,14 @@ const types = {

this.label = this.prefix[0]
this.method = options.method // just for debugging and error messages
this.method = options.method // not used for logic, just for debugging and pretty printing
this.handlers = options.handlers || [] // unoptimized list of handler objects for which the fast matcher function will be compiled
this.unconstrainedHandler = options.unconstrainedHandler || null // optimized reference to the handler that will match most of the time
this.children = options.children || {}
this.numberOfChildren = Object.keys(this.children).length
this.kind = options.kind || this.types.STATIC
this.handler = options.handler
this.regex = options.regex || null
this.wildcardChild = null
this.parametricBrother = null
this.versions = options.versions
this.constrainer = options.constrainer
this.hasConstraints = false || options.hasConstraints
this.constrainedHandlerStores = null
}

@@ -100,14 +104,39 @@

Node.prototype.reset = function (prefix, versions) {
Node.prototype.reset = function (prefix) {
this.prefix = prefix
this.children = {}
this.handlers = []
this.unconstrainedHandler = null
this.kind = this.types.STATIC
this.handler = null
this.numberOfChildren = 0
this.regex = null
this.wildcardChild = null
this.versions = versions
this.hasConstraints = false
this._decompileGetHandlerMatchingConstraints()
return this
}
Node.prototype.split = function (length) {
const newChild = new Node(
{
prefix: this.prefix.slice(length),
children: this.children,
kind: this.kind,
handlers: this.handlers.slice(0),
regex: this.regex,
constrainer: this.constrainer,
hasConstraints: this.hasConstraints,
unconstrainedHandler: this.unconstrainedHandler
}
)
if (this.wildcardChild !== null) {
newChild.wildcardChild = this.wildcardChild
}
this.reset(this.prefix.slice(0, length))
this.addChild(newChild)
return newChild
}
Node.prototype.findByLabel = function (path) {

@@ -117,5 +146,5 @@ return this.children[path[0]]

Node.prototype.findChild = function (path) {
Node.prototype.findMatchingChild = function (derivedConstraints, path) {
var child = this.children[path[0]]
if (child !== undefined && (child.numberOfChildren > 0 || child.handler !== null)) {
if (child !== undefined && (child.numberOfChildren > 0 || child.getMatchingHandler(derivedConstraints) !== null)) {
if (path.slice(0, child.prefix.length) === child.prefix) {

@@ -127,3 +156,3 @@ return child

child = this.children[':']
if (child !== undefined && (child.numberOfChildren > 0 || child.handler !== null)) {
if (child !== undefined && (child.numberOfChildren > 0 || child.getMatchingHandler(derivedConstraints) !== null)) {
return child

@@ -133,3 +162,3 @@ }

child = this.children['*']
if (child !== undefined && (child.numberOfChildren > 0 || child.handler !== null)) {
if (child !== undefined && (child.numberOfChildren > 0 || child.getMatchingHandler(derivedConstraints) !== null)) {
return child

@@ -141,59 +170,155 @@ }

Node.prototype.findVersionChild = function (version, path) {
var child = this.children[path[0]]
if (child !== undefined && (child.numberOfChildren > 0 || child.getVersionHandler(version) !== null)) {
if (path.slice(0, child.prefix.length) === child.prefix) {
return child
}
Node.prototype.addHandler = function (handler, params, store, constraints) {
if (!handler) return
assert(!this.getHandler(constraints), `There is already a handler with constraints '${JSON.stringify(constraints)}' and method '${this.method}'`)
const handlerObject = {
handler: handler,
params: params,
constraints: constraints,
store: store || null,
paramsLength: params.length
}
child = this.children[':']
if (child !== undefined && (child.numberOfChildren > 0 || child.getVersionHandler(version) !== null)) {
return child
this.handlers.push(handlerObject)
// Sort the most constrained handlers to the front of the list of handlers so they are tested first.
this.handlers.sort((a, b) => Object.keys(a.constraints).length - Object.keys(b.constraints).length)
if (Object.keys(constraints).length > 0) {
this.hasConstraints = true
} else {
this.unconstrainedHandler = handlerObject
}
child = this.children['*']
if (child !== undefined && (child.numberOfChildren > 0 || child.getVersionHandler(version) !== null)) {
return child
if (this.hasConstraints && this.handlers.length > 32) {
throw new Error('find-my-way supports a maximum of 32 route handlers per node when there are constraints, limit reached')
}
return null
// Note that the fancy constraint handler matcher needs to be recompiled now that the list of handlers has changed
// This lazy compilation means we don't do the compile until the first time the route match is tried, which doesn't waste time re-compiling every time a new handler is added
this._decompileGetHandlerMatchingConstraints()
}
Node.prototype.setHandler = function (handler, params, store) {
if (!handler) return
Node.prototype.getHandler = function (constraints) {
return this.handlers.filter(handler => deepEqual(constraints, handler.constraints))[0]
}
assert(
!this.handler,
`There is already an handler with method '${this.method}'`
)
// We compile the handler matcher the first time this node is matched. We need to recompile it if new handlers are added, so when a new handler is added, we reset the handler matching function to this base one that will recompile it.
function compileThenGetHandlerMatchingConstraints (derivedConstraints) {
this._compileGetHandlerMatchingConstraints()
return this._getHandlerMatchingConstraints(derivedConstraints)
}
this.handler = {
handler: handler,
params: params,
store: store || null,
paramsLength: params.length
// This is the hot path for node handler finding -- change with care!
Node.prototype.getMatchingHandler = function (derivedConstraints) {
if (this.hasConstraints) {
// This node is constrained, use the performant precompiled constraint matcher
return this._getHandlerMatchingConstraints(derivedConstraints)
} else {
// This node doesn't have any handlers that are constrained, so it's handlers probably match. Some requests have constraint values that *must* match however, like version, so check for those before returning it.
if (derivedConstraints && derivedConstraints.__hasMustMatchValues) {
return null
} else {
return this.unconstrainedHandler
}
}
}
Node.prototype.setVersionHandler = function (version, handler, params, store) {
if (!handler) return
// Slot for the compiled constraint matching function
Node.prototype._getHandlerMatchingConstraints = compileThenGetHandlerMatchingConstraints
assert(
!this.versions.get(version),
`There is already an handler with version '${version}' and method '${this.method}'`
)
Node.prototype._decompileGetHandlerMatchingConstraints = function () {
this._getHandlerMatchingConstraints = compileThenGetHandlerMatchingConstraints
return null
}
this.versions.set(version, {
handler: handler,
params: params,
store: store || null,
paramsLength: params.length
})
// Builds a store object that maps from constraint values to a bitmap of handler indexes which pass the constraint for a value
// So for a host constraint, this might look like { "fastify.io": 0b0010, "google.ca": 0b0101 }, meaning the 3rd handler is constrainted to fastify.io, and the 2nd and 4th handlers are constrained to google.ca.
// The store's implementation comes from the strategies provided to the Router.
Node.prototype._buildConstraintStore = function (constraint) {
const store = this.constrainer.newStoreForConstraint(constraint)
for (let i = 0; i < this.handlers.length; i++) {
const handler = this.handlers[i]
const mustMatchValue = handler.constraints[constraint]
if (typeof mustMatchValue !== 'undefined') {
let indexes = store.get(mustMatchValue)
if (!indexes) {
indexes = 0
}
indexes |= 1 << i // set the i-th bit for the mask because this handler is constrained by this value https://stackoverflow.com/questions/1436438/how-do-you-set-clear-and-toggle-a-single-bit-in-javascrip
store.set(mustMatchValue, indexes)
}
}
return store
}
Node.prototype.getVersionHandler = function (version) {
return this.versions.get(version)
// Builds a bitmask for a given constraint that has a bit for each handler index that is 0 when that handler *is* constrained and 1 when the handler *isnt* constrainted. This is opposite to what might be obvious, but is just for convienience when doing the bitwise operations.
Node.prototype._constrainedIndexBitmask = function (constraint) {
let mask = 0b0
for (let i = 0; i < this.handlers.length; i++) {
const handler = this.handlers[i]
if (handler.constraints && constraint in handler.constraints) {
mask |= 1 << i
}
}
return ~mask
}
// Compile a fast function to match the handlers for this node
// The function implements a general case multi-constraint matching algorithm.
// The general idea is this: we have a bunch of handlers, each with a potentially different set of constraints, and sometimes none at all. We're given a list of constraint values and we have to use the constraint-value-comparison strategies to see which handlers match the constraint values passed in.
// We do this by asking each constraint store which handler indexes match the given constraint value for each store. Trickily, the handlers that a store says match are the handlers constrained by that store, but handlers that aren't constrained at all by that store could still match just fine. So, each constraint store can only describe matches for it, and it won't have any bearing on the handlers it doesn't care about. For this reason, we have to ask each stores which handlers match and track which have been matched (or not cared about) by all of them.
// We use bitmaps to represent these lists of matches so we can use bitwise operations to implement this efficiently. Bitmaps are cheap to allocate, let us implement this masking behaviour in one CPU instruction, and are quite compact in memory. We start with a bitmap set to all 1s representing every handler that is a match candidate, and then for each constraint, see which handlers match using the store, and then mask the result by the mask of handlers that that store applies to, and bitwise AND with the candidate list. Phew.
// We consider all this compiling function complexity to be worth it, because the naive implementation that just loops over the handlers asking which stores match is quite a bit slower.
Node.prototype._compileGetHandlerMatchingConstraints = function () {
this.constrainedHandlerStores = {}
let constraints = new Set()
for (const handler of this.handlers) {
for (const key of Object.keys(handler.constraints)) {
constraints.add(key)
}
}
constraints = Array.from(constraints)
const lines = []
// always check the version constraint first as it is the most selective
constraints.sort((a, b) => a === 'version' ? 1 : 0)
for (const constraint of constraints) {
this.constrainedHandlerStores[constraint] = this._buildConstraintStore(constraint)
}
lines.push(`
let candidates = 0b${'1'.repeat(this.handlers.length)}
let mask, matches
`)
for (const constraint of constraints) {
// Setup the mask for indexes this constraint applies to. The mask bits are set to 1 for each position if the constraint applies.
lines.push(`
mask = ${this._constrainedIndexBitmask(constraint)}
value = derivedConstraints.${constraint}
`)
// If there's no constraint value, none of the handlers constrained by this constraint can match. Remove them from the candidates.
// If there is a constraint value, get the matching indexes bitmap from the store, and mask it down to only the indexes this constraint applies to, and then bitwise and with the candidates list to leave only matching candidates left.
lines.push(`
if (typeof value === "undefined") {
candidates &= mask
} else {
matches = this.constrainedHandlerStores.${constraint}.get(value) || 0
candidates &= (matches | mask)
}
if (candidates === 0) return null;
`)
}
// Return the first handler who's bit is set in the candidates https://stackoverflow.com/questions/18134985/how-to-find-index-of-first-set-bit
lines.push(`
return this.handlers[Math.floor(Math.log2(candidates))]
`)
this._getHandlerMatchingConstraints = new Function('derivedConstraints', lines.join('\n')) // eslint-disable-line
}
module.exports = Node
{
"name": "find-my-way",
"version": "3.0.5",
"version": "4.0.0",
"description": "Crazy fast http radix based router",

@@ -47,2 +47,3 @@ "main": "index.js",

"fast-decode-uri-component": "^1.0.1",
"fast-deep-equal": "^3.1.3",
"safe-regex2": "^2.0.0",

@@ -49,0 +50,0 @@ "semver-store": "^0.3.0"

@@ -99,7 +99,76 @@ # find-my-way

## Constraints
`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](#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:
```js
findMyWay.on('GET', '/', { constraints: { version: '1.0.2' } }, (req, res) => {
// 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.
})
findMyWay.on('GET', '/', { constraints: { host: 'example.com' } }, (req, res) => {
// will only run when the request's Host header is `example.com`
})
```
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.
<a name="custom-constraint-strategies"></a>
### Custom Constraint Strategies
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:
```js
const customResponseTypeStrategy = {
// strategy name for referencing in the route handler `constraints` options
name: 'accept',
// storage factory for storing routes in the find-my-way route tree
storage: function () {
let handlers = {}
return {
get: (type) => { return handlers[type] || null },
set: (type, store) => { handlers[type] = store },
del: (type) => { delete handlers[type] },
empty: () => { handlers = {} }
}
},
// function to get the value of the constraint from each incoming request
deriveConstraint: (req, ctx) => {
return req.headers['accept']
},
// optional flag marking if handlers without constraints can match requests that have a value for this constraint
mustMatchWhenDerived: true
}
const router = FindMyWay({ constraints: { accept: customResponseTypeStrategy } });
```
Once a custom constraint strategy is registered, routes can be added that are constrained using it:
```js
findMyWay.on('GET', '/', { constraints: { accept: 'application/fancy+json' } }, (req, res) => {
// will only run when the request's Accept header asks for 'application/fancy+json'
})
findMyWay.on('GET', '/', { constraints: { accept: 'application/fancy+xml' } }, (req, res) => {
// will only run when the request's Accept header asks for 'application/fancy+xml'
})
```
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.
<a name="custom-versioning"></a>
By default `find-my-way` uses [accept-version](./lib/accept-version.js) strategy to match requests with different versions of the handlers. The matching logic of that strategy is explained [below](#semver). It is possible to define the alternative strategy:
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](#semver). It is possible to define an alternative strategy:
```js
const customVersioning = {
// storage factory
// replace the built in version strategy
name: 'version',
// provide a storage factory to store handlers in a simple way
storage: function () {

@@ -114,19 +183,19 @@ let versions = {}

},
deriveVersion: (req, ctx) => {
deriveConstraint: (req, ctx) => {
return req.headers['accept']
}
},
mustMatchWhenDerived: true // if the request is asking for a version, don't match un-version-constrained handlers
}
const router = FindMyWay({ versioning: customVersioning });
const router = FindMyWay({ constraints: { version: customVersioning } });
```
The custom strategy object should contain next properties:
* `storage` - the factory function for the Storage of the handlers based on their version.
* `deriveVersion` - the function to determine the version based on the request
* `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 request
The 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!*
*Please, be aware, if you use custom versioning 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*
<a name="on"></a>

@@ -149,18 +218,18 @@ #### on(method, path, [opts], handler, [store])

If needed you can provide a `version` option, which will allow you to declare multiple versions of the same route. If you never configure a versioned route, the `'Accept-Version'` header will be ignored.
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.
Remember to set a [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) header in your responses with the value you are using for deifning the versioning (e.g.: 'Accept-Version'), to prevent cache poisoning attacks. You can also configure this as part your Proxy/CDN.
If you never configure a versioned route, the `'Accept-Version'` header will be ignored. Remember to set a [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) header in your responses with the value you are using for deifning the versioning (e.g.: 'Accept-Version'), to prevent cache poisoning attacks. You can also configure this as part your Proxy/CDN.
###### default
<a name="semver"></a>
Default versioning strategy is called `accept-version` and it follows the [semver](https://semver.org/) specification.<br/>
When using `lookup`, `find-my-way` will automatically detect the `Accept-Version` header and route the request accordingly.<br/>
Internally `find-my-way` uses the [`semver-store`](https://github.com/delvedor/semver-store) to get the correct version of the route; *advanced ranges* and *pre-releases* currently are not supported.<br/>
The default versioning strategy follows the [semver](https://semver.org/) 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`](https://github.com/delvedor/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.*
```js
router.on('GET', '/example', { version: '1.2.0' }, (req, res, params) => {
router.on('GET', '/example', { constraints: { version: '1.2.0' }}, (req, res, params) => {
res.end('Hello from 1.2.0!')
})
router.on('GET', '/example', { version: '2.4.0' }, (req, res, params) => {
router.on('GET', '/example', { constraints: { version: '2.4.0' }}, (req, res, params) => {
res.end('Hello from 2.4.0!')

@@ -171,2 +240,3 @@ })

```
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.

@@ -243,3 +313,8 @@

If the URL would have been /32/foo/bar, the first route would have been matched.
Once 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`
<a name="supported-methods"></a>

@@ -326,12 +401,13 @@ ##### Supported methods

<a name="find"></a>
#### find(method, path [, version])
#### find(method, path, [constraints])
Return (if present) the route registered in *method:path*.<br>
The path must be sanitized, all the parameters and wildcards are decoded automatically.<br/>
You can also pass an optional version string. In case of the default versioning strategy it should be conform to the [semver](https://semver.org/) specification.
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](https://semver.org/) 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.
```js
router.find('GET', '/example')
router.find('GET', '/example', { host: 'fastify.io' })
// => { handler: Function, params: Object, store: Object}
// => null
router.find('GET', '/example', '1.x')
router.find('GET', '/example', { host: 'fastify.io', version: '1.x' })
// => { handler: Function, params: Object, store: Object}

@@ -338,0 +414,0 @@ // => null

@@ -184,3 +184,3 @@ 'use strict'

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test\' with constraints \'{}\'')
}

@@ -202,3 +202,3 @@ })

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test\' with constraints \'{}\'')
}

@@ -210,3 +210,3 @@

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test/\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test/\' with constraints \'{}\'')
}

@@ -225,3 +225,3 @@ })

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test\' with constraints \'{}\'')
}

@@ -233,3 +233,3 @@

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test/\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test/\' with constraints \'{}\'')
}

@@ -251,3 +251,3 @@ })

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\' with constraints \'{}\'')
}

@@ -271,3 +271,3 @@ })

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\' with constraints \'{}\'')
}

@@ -279,6 +279,19 @@

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello/\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello/\' with constraints \'{}\'')
}
})
test('Method already declared with constraints', t => {
t.plan(1)
const findMyWay = FindMyWay()
findMyWay.on('GET', '/test', { constraints: { host: 'fastify.io' } }, () => {})
try {
findMyWay.on('GET', '/test', { constraints: { host: 'fastify.io' } }, () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test\' with constraints \'{"host":"fastify.io"}\'')
}
})
t.test('with trailing slash', t => {

@@ -296,3 +309,3 @@ t.plan(2)

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\' with constraints \'{}\'')
}

@@ -304,5 +317,5 @@

} catch (e) {
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello/\'')
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello/\' with constraints \'{}\'')
}
})
})

@@ -20,10 +20,10 @@ 'use strict'

t.deepEqual(findMyWay.find('GET', 'http://localhost/a'), findMyWay.find('GET', '/a'))
t.deepEqual(findMyWay.find('GET', 'http://localhost:8080/a'), findMyWay.find('GET', '/a'))
t.deepEqual(findMyWay.find('GET', 'http://123.123.123.123/a'), findMyWay.find('GET', '/a'))
t.deepEqual(findMyWay.find('GET', 'https://localhost/a'), findMyWay.find('GET', '/a'))
t.deepEqual(findMyWay.find('GET', 'http://localhost/a', { host: 'localhost' }), findMyWay.find('GET', '/a', { host: 'localhost' }))
t.deepEqual(findMyWay.find('GET', 'http://localhost:8080/a', { host: 'localhost' }), findMyWay.find('GET', '/a', { host: 'localhost' }))
t.deepEqual(findMyWay.find('GET', 'http://123.123.123.123/a', {}), findMyWay.find('GET', '/a', {}))
t.deepEqual(findMyWay.find('GET', 'https://localhost/a', { host: 'localhost' }), findMyWay.find('GET', '/a', { host: 'localhost' }))
t.deepEqual(findMyWay.find('GET', 'http://localhost/a/100'), findMyWay.find('GET', '/a/100'))
t.deepEqual(findMyWay.find('GET', 'http://localhost:8080/a/100'), findMyWay.find('GET', '/a/100'))
t.deepEqual(findMyWay.find('GET', 'http://123.123.123.123/a/100'), findMyWay.find('GET', '/a/100'))
t.deepEqual(findMyWay.find('GET', 'https://localhost/a/100'), findMyWay.find('GET', '/a/100'))
t.deepEqual(findMyWay.find('GET', 'http://localhost/a/100', { host: 'localhost' }), findMyWay.find('GET', '/a/100', { host: 'localhost' }))
t.deepEqual(findMyWay.find('GET', 'http://localhost:8080/a/100', { host: 'localhost' }), findMyWay.find('GET', '/a/100', { host: 'localhost' }))
t.deepEqual(findMyWay.find('GET', 'http://123.123.123.123/a/100', {}), findMyWay.find('GET', '/a/100', {}))
t.deepEqual(findMyWay.find('GET', 'https://localhost/a/100', { host: 'localhost' }), findMyWay.find('GET', '/a/100', { host: 'localhost' }))

@@ -14,10 +14,10 @@ 'use strict'

t.throws(() => {
findMyWay.on('GET', '/t1', { version: 42 }, noop)
findMyWay.on('GET', '/t1', { constraints: { version: 42 } }, noop)
})
t.throws(() => {
findMyWay.on('GET', '/t2', { version: null }, noop)
findMyWay.on('GET', '/t2', { constraints: { version: null } }, noop)
})
t.throws(() => {
findMyWay.on('GET', '/t2', { version: true }, noop)
findMyWay.on('GET', '/t2', { constraints: { version: true } }, noop)
})
})

@@ -27,3 +27,3 @@ 'use strict'

t.notOk(findMyWay.find('GET', '/foo/abc'))
t.ok(findMyWay.find('GET', '/foo/(abc)'))
t.ok(findMyWay.find('GET', '/foo/(abc)', {}))
})

@@ -13,9 +13,9 @@ 'use strict'

findMyWay.on('GET', '/t1', { version: '1.0.0' }, noop)
findMyWay.on('GET', '/t2', { version: '2.1.0' }, noop)
findMyWay.on('GET', '/t1', { constraints: { version: '1.0.0' } }, noop)
findMyWay.on('GET', '/t2', { constraints: { version: '2.1.0' } }, noop)
t.ok(findMyWay.find('GET', '/t1', '1.0.0'))
t.ok(findMyWay.find('GET', '/t2', '2.x'))
t.notOk(findMyWay.find('GET', '/t1', '2.x'))
t.notOk(findMyWay.find('GET', '/t2', '1.0.0'))
t.ok(findMyWay.find('GET', '/t1', { version: '1.0.0' }))
t.ok(findMyWay.find('GET', '/t2', { version: '2.x' }))
t.notOk(findMyWay.find('GET', '/t1', { version: '2.x' }))
t.notOk(findMyWay.find('GET', '/t2', { version: '1.0.0' }))
})

@@ -111,1 +111,24 @@ 'use strict'

})
test('pretty print - constrained parametric routes', t => {
t.plan(2)
const findMyWay = FindMyWay()
findMyWay.on('GET', '/test', () => {})
findMyWay.on('GET', '/test', { constraints: { host: 'auth.fastify.io' } }, () => {})
findMyWay.on('GET', '/test/:hello', () => {})
findMyWay.on('GET', '/test/:hello', { constraints: { version: '1.1.2' } }, () => {})
findMyWay.on('GET', '/test/:hello', { constraints: { version: '2.0.0' } }, () => {})
const tree = findMyWay.prettyPrint()
const expected = `└── /test (GET)
/test (GET {"host":"auth.fastify.io"})
└── /:hello (GET)
:hello (GET {"version":"1.1.2"})
:hello (GET {"version":"2.0.0"})
`
t.is(typeof tree, 'string')
t.equal(tree, expected)
})

@@ -142,3 +142,3 @@ 'use strict'

t.deepEqual(
findMyWay.find('GET', '/test/hel%"Flo'),
findMyWay.find('GET', '/test/hel%"Flo', {}),
null

@@ -145,0 +145,0 @@ )

@@ -273,3 +273,3 @@ 'use strict'

findMyWay.on('GET', '/test', { version: '1.2.3' }, (req, res, params) => {
findMyWay.on('GET', '/test', { constraints: { version: '1.2.3' } }, (req, res, params) => {
res.end('ok')

@@ -276,0 +276,0 @@ })

@@ -21,12 +21,17 @@ import { expectType } from 'tsd'

onBadUrl (path, http1Req, http1Res) {},
versioning: {
storage () {
return {
get (version) { return handler },
set (version, handler) {},
del (version) {},
empty () {}
}
},
deriveVersion(req) { return '1.0.0' }
constraints: {
foo: {
name: 'foo',
mustMatchWhenDerived: true,
storage () {
return {
get (version) { return handler },
set (version, handler) {},
del (version) {},
empty () {}
}
},
deriveConstraint(req) { return '1.0.0' },
validate(value) { if (typeof value === "string") { throw new Error("invalid")} }
}
}

@@ -38,10 +43,10 @@ })

expectType<void>(router.on(['GET', 'POST'], '/', () => {}))
expectType<void>(router.on('GET', '/', { version: '1.0.0' }, () => {}))
expectType<void>(router.on('GET', '/', { constraints: { version: '1.0.0' }}, () => {}))
expectType<void>(router.on('GET', '/', () => {}, {}))
expectType<void>(router.on('GET', '/', { version: '1.0.0' }, () => {}, {}))
expectType<void>(router.on('GET', '/', {constraints: { version: '1.0.0' }}, () => {}, {}))
expectType<void>(router.get('/', () => {}))
expectType<void>(router.get('/', { version: '1.0.0' }, () => {}))
expectType<void>(router.get('/', { constraints: { version: '1.0.0' }}, () => {}))
expectType<void>(router.get('/', () => {}, {}))
expectType<void>(router.get('/', { version: '1.0.0' }, () => {}, {}))
expectType<void>(router.get('/', { constraints: { version: '1.0.0' }}, () => {}, {}))

@@ -53,3 +58,4 @@ expectType<void>(router.off('GET', '/'))

expectType<Router.FindResult<Router.HTTPVersion.V1> | null>(router.find('GET', '/'))
expectType<Router.FindResult<Router.HTTPVersion.V1> | null>(router.find('GET', '/', '1.0.0'))
expectType<Router.FindResult<Router.HTTPVersion.V1> | null>(router.find('GET', '/', {}))
expectType<Router.FindResult<Router.HTTPVersion.V1> | null>(router.find('GET', '/', {version: '1.0.0'}))

@@ -70,12 +76,17 @@ expectType<void>(router.reset())

onBadUrl (path, http1Req, http1Res) {},
versioning: {
storage () {
return {
get (version) { return handler },
set (version, handler) {},
del (version) {},
empty () {}
}
},
deriveVersion(req) { return '1.0.0' }
constraints: {
foo: {
name: 'foo',
mustMatchWhenDerived: true,
storage () {
return {
get (version) { return handler },
set (version, handler) {},
del (version) {},
empty () {}
}
},
deriveConstraint(req) { return '1.0.0' },
validate(value) { if (typeof value === "string") { throw new Error("invalid")} }
}
}

@@ -87,10 +98,10 @@ })

expectType<void>(router.on(['GET', 'POST'], '/', () => {}))
expectType<void>(router.on('GET', '/', { version: '1.0.0' }, () => {}))
expectType<void>(router.on('GET', '/', { constraints: { version: '1.0.0' }}, () => {}))
expectType<void>(router.on('GET', '/', () => {}, {}))
expectType<void>(router.on('GET', '/', { version: '1.0.0' }, () => {}, {}))
expectType<void>(router.on('GET', '/', { constraints: { version: '1.0.0' }}, () => {}, {}))
expectType<void>(router.get('/', () => {}))
expectType<void>(router.get('/', { version: '1.0.0' }, () => {}))
expectType<void>(router.get('/', { constraints: { version: '1.0.0' }}, () => {}))
expectType<void>(router.get('/', () => {}, {}))
expectType<void>(router.get('/', { version: '1.0.0' }, () => {}, {}))
expectType<void>(router.get('/', { constraints: { version: '1.0.0' }}, () => {}, {}))

@@ -101,4 +112,4 @@ expectType<void>(router.off('GET', '/'))

expectType<void>(router.lookup(http2Req, http2Res))
expectType<Router.FindResult<Router.HTTPVersion.V2> | null>(router.find('GET', '/'))
expectType<Router.FindResult<Router.HTTPVersion.V2> | null>(router.find('GET', '/', '1.0.0'))
expectType<Router.FindResult<Router.HTTPVersion.V2> | null>(router.find('GET', '/', {}))
expectType<Router.FindResult<Router.HTTPVersion.V2> | null>(router.find('GET', '/', {version: '1.0.0', host: 'fastify.io'}))

@@ -105,0 +116,0 @@ expectType<void>(router.reset())

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc