{"id":16031,"library":"find-my-way-ts","title":"find-my-way-ts Fast HTTP Router","description":"find-my-way-ts is a highly performant, framework-independent HTTP router designed for Node.js environments, leveraging a Radix Tree (also known as a compact Prefix Tree) for extremely fast route matching. It is a TypeScript-first fork of the popular `find-my-way` router, providing enhanced type safety and improved developer experience through its explicit type definitions. Currently at version 0.1.6, the package appears to be under active development, with frequent patch releases addressing bug fixes and minor enhancements, such as improved URI error handling and `QueryString` module integration. Its primary differentiator is its speed and efficient algorithm for path resolution, supporting route parameters and wildcards, making it suitable for high-throughput HTTP servers. Its pre-1.0 status suggests a relatively fast-moving API, though the current changes are mostly iterative improvements.","status":"active","version":"0.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/tim-smart/find-my-way-ts","tags":["javascript","typescript"],"install":[{"cmd":"npm install find-my-way-ts","lang":"bash","label":"npm"},{"cmd":"yarn add find-my-way-ts","lang":"bash","label":"yarn"},{"cmd":"pnpm add find-my-way-ts","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary function to instantiate the router. Being a TypeScript-first package, ESM `import` is the recommended and best-supported pattern.","wrong":"const findMyWay = require('find-my-way-ts');","symbol":"findMyWay","correct":"import { findMyWay } from 'find-my-way-ts';"},{"note":"This is a TypeScript enum/type for HTTP methods. Use `import type` to ensure it's removed from the compiled JavaScript bundle.","wrong":"import { HTTPMethod } from 'find-my-way-ts';","symbol":"HTTPMethod","correct":"import type { HTTPMethod } from 'find-my-way-ts';"},{"note":"This is a TypeScript type definition for route handlers. Use `import type`.","wrong":"import { Handler } from 'find-my-way-ts';","symbol":"Handler","correct":"import type { Handler } from 'find-my-way-ts';"}],"quickstart":{"code":"import { findMyWay } from 'find-my-way-ts';\nimport * as http from 'http';\n\nconst router = findMyWay();\n\nrouter.on('GET', '/', (req, res, params, store, searchParams) => {\n  res.statusCode = 200;\n  res.setHeader('Content-Type', 'application/json');\n  res.end(JSON.stringify({ message: 'Hello from root!', params, searchParams }));\n});\n\nrouter.on('GET', '/user/:id', (req, res, params, store, searchParams) => {\n  res.statusCode = 200;\n  res.setHeader('Content-Type', 'application/json');\n  res.end(JSON.stringify({ message: `Hello user ${params.id}!`, params, searchParams }));\n});\n\nrouter.on(['POST', 'PUT'], '/data', (req, res, params, store, searchParams) => {\n  let body = '';\n  req.on('data', chunk => { body += chunk; });\n  req.on('end', () => {\n    res.statusCode = 200;\n    res.setHeader('Content-Type', 'application/json');\n    res.end(JSON.stringify({ message: `Data received for ${req.method}!`, body: JSON.parse(body || '{}'), params, searchParams }));\n  });\n});\n\nrouter.on('GET', '/search', (req, res, params, store, searchParams) => {\n  res.statusCode = 200;\n  res.setHeader('Content-Type', 'application/json');\n  res.end(JSON.stringify({ message: 'Search results!', params, searchParams, query: req.url?.split('?')[1] }));\n});\n\nconst server = http.createServer((req, res) => {\n  router.lookup(req, res);\n});\n\nconst PORT = process.env.PORT || 3000;\nserver.listen(PORT, () => {\n  console.log(`Server listening on http://localhost:${PORT}`);\n  console.log('Try visiting:');\n  console.log(`- http://localhost:${PORT}/`);\n  console.log(`- http://localhost:${PORT}/user/123`);\n  console.log(`- http://localhost:${PORT}/search?q=test&page=1`);\n  console.log(`- curl -X POST -H \"Content-Type: application/json\" -d '{\"item\": \"new\"}' http://localhost:${PORT}/data`);\n});","lang":"typescript","description":"This quickstart sets up a basic HTTP server using `find-my-way-ts` to route incoming requests. It demonstrates GET routes with and without parameters, a POST/PUT route with body parsing, and accessing query parameters. It uses Node.js's native `http` module for server creation."},"warnings":[{"fix":"Always review the release notes (`CHANGELOG.md`) when upgrading and lock package versions in `package.json` to specific patch releases (e.g., `\"find-my-way-ts\": \"~0.1.6\"` or `\"find-my-way-ts\": \"0.1.6\"`).","message":"As a pre-1.0 package, the API of `find-my-way-ts` is subject to frequent changes without adhering to semantic versioning for major releases. Users should expect potential breaking changes between minor versions (e.g., 0.1.x to 0.2.x).","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Upgrade to `find-my-way-ts@0.1.6` or newer to benefit from improved URI error handling and stability.","message":"Older versions (pre-0.1.6) might have failed or behaved unpredictably when encountering malformed URIs. The `0.1.6` release specifically addresses improved handling of invalid URI errors, suggesting previous instability.","severity":"gotcha","affected_versions":"<0.1.6"},{"fix":"Ensure you are using `find-my-way-ts@0.1.4` or newer to avoid `new Function`-related issues and ensure broader runtime compatibility.","message":"Early versions (pre-0.1.4 and pre-0.1.1) used `new Function` for internal optimizations, which caused compatibility issues and performance penalties in certain serverless and edge runtimes (e.g., Cloudflare Workers, EdgeRuntime). These usages have since been removed.","severity":"gotcha","affected_versions":"<0.1.4"},{"fix":"Refer to the `find-my-way-ts` documentation and source code for the most accurate and up-to-date API specifics and behavioral guarantees, rather than relying solely on `find-my-way` knowledge.","message":"`find-my-way-ts` is a fork of `find-my-way`. While aiming for similar functionality, there might be subtle behavioral differences or API divergences that could affect migration or expectations if you're familiar with the original package.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Carefully review and test complex regex-based routes for potential ReDoS attack vectors. Monitor `find-my-way-ts`'s security advisories and ensure regular updates to mitigate known vulnerabilities.","message":"The original `find-my-way` library (which `find-my-way-ts` is based on) has had a ReDoS vulnerability in multiparametric routes (CVE-2024-45813). While `find-my-way-ts` may have different internal implementations, it's prudent to be aware of potential similar vulnerabilities in regex-based routing if not explicitly patched or verified.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you are using ESM `import { findMyWay } from 'find-my-way-ts';` and that your build/runtime environment supports ESM. If using Node.js, ensure your package.json `type` is set to `module` or use `.mjs` extension for your file.","cause":"Attempting to import `findMyWay` using CommonJS `require()` syntax or an incorrect ESM named import pattern in an environment that expects ESM.","error":"TypeError: (0 , find_my_way_ts__WEBPACK_IMPORTED_MODULE_0__.findMyWay) is not a function"},{"fix":"Upgrade to `find-my-way-ts@0.1.6` or newer. If the issue persists with valid URIs, ensure client-side URI encoding is correct or implement custom URL sanitization before passing to the router.","cause":"Passing an improperly encoded or malformed URI path to the router, which earlier versions of `find-my-way-ts` did not gracefully handle.","error":"URIError: URI malformed"},{"fix":"Upgrade to `find-my-way-ts@0.1.2` or newer, which includes a fix for `searchParams` types. Ensure your `tsconfig.json` targets a modern TypeScript version.","cause":"Type definitions for `searchParams` on the `Route` object (or handler arguments) were incorrect or missing in older versions.","error":"Property 'searchParams' does not exist on type 'Route'."},{"fix":"Upgrade to `find-my-way-ts@0.1.4` or newer. This version specifically removed the usage of `new Function` to enhance compatibility with such runtimes.","cause":"This error can occur in highly restricted environments (like some serverless platforms) that disallow `new Function` if using `find-my-way-ts` versions prior to `0.1.4`.","error":"ReferenceError: Function is not defined"}],"ecosystem":"npm"}