{"_id":"@alteredconstants/express-router","_rev":"3-9441e685cecca900cec6dfb7ef015c2b","name":"@alteredconstants/express-router","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@alteredconstants/express-router","version":"0.1.0","author":"Zeff Svoboda","license":"MIT","_id":"@alteredconstants/express-router@0.1.0","maintainers":[{"name":"alteredconstants","email":"npm@alteredconstants.com"}],"dist":{"shasum":"b272c91be97afbd6253eb88561bac8b44b4aa885","tarball":"https://registry.npmjs.org/@alteredconstants/express-router/-/express-router-0.1.0.tgz","fileCount":32,"integrity":"sha512-57kGqS2Fa7W4Ud17M+VYcZXCfFA7mtLRpgO01VdAquGBwyVW1BPIkNRxfO5457yiz6NzXLuqN07ybBhO0yuJbA==","signatures":[{"sig":"MEUCIDwRsczF9CrMpGa5AahgcpRA4VI1+fJ6kH7VH/bVCRY2AiEApUU2UcsOvF55CE/09L4rIAcjth5kDAiru0mLtwfypW4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29045},"type":"module","shasum":"b272c91be97afbd6253eb88561bac8b44b4aa885","engines":{"bun":">=1.3.9"},"exports":{".":{"types":"./dist/exports.d.ts","import":"./dist/exports.js"}},"scripts":{"test":"bun test --coverage","build":"tsgo","check":"bun run --parallel 'check:*'","format":"prettier --write .","prepack":"bun run --sequential check test build","prebuild":"bun scripts/clean.ts","check:types":"tsgo --noEmit","check:format":"prettier --check --log-level warn .","check:test-types":"tsgo --noEmit --project tsconfig.test.json"},"_npmUser":{"name":"alteredconstants","email":"npm@alteredconstants.com"},"_integrity":"sha512-57kGqS2Fa7W4Ud17M+VYcZXCfFA7mtLRpgO01VdAquGBwyVW1BPIkNRxfO5457yiz6NzXLuqN07ybBhO0yuJbA==","repository":{"url":"git+https://github.com/AlteredConstants/express-router.git","type":"git"},"_npmVersion":"10.8.3","directories":{},"_nodeVersion":"24.3.0","_hasShrinkwrap":false,"devDependencies":{"prettier":"3.8.1","@types/bun":"latest","typescript":"^5.9.3","@types/express":"^5","@typescript/native-preview":"^7.0.0-dev.20260310.1","@trivago/prettier-plugin-sort-imports":"6.0.2"},"peerDependencies":{"express":"^5"},"_npmOperationalInternal":{"tmp":"tmp/express-router_0.1.0_1773266971384_0.4224747807127358","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@alteredconstants/express-router","version":"0.1.1","author":{"name":"Zeff Svoboda"},"license":"MIT","_id":"@alteredconstants/express-router@0.1.1","maintainers":[{"name":"alteredconstants","email":"npm@alteredconstants.com"}],"homepage":"https://github.com/AlteredConstants/express-router#readme","bugs":{"url":"https://github.com/AlteredConstants/express-router/issues"},"dist":{"shasum":"c86bd353c9cb051dd34804004cec71a2702f071b","tarball":"https://registry.npmjs.org/@alteredconstants/express-router/-/express-router-0.1.1.tgz","fileCount":33,"integrity":"sha512-oHvUZ+rajTZEHk/fYyXfL5xTzrxPv/D8v/HXiLjdHzcVzmZSIQyxEXTROswt7vzfQbsdYMpNEO+Xlom+ueJnYg==","signatures":[{"sig":"MEQCIFnnXM27F7szN8uDvZgcOZFEHQtQH4sUEm7gY2vHJ1aQAiBTag33dWegYOowrhD34/3bjnvQM2xklppNFOw0ZYa/Kw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29615},"type":"module","engines":{"bun":">=1.3.9"},"exports":{".":{"types":"./dist/exports.d.ts","import":"./dist/exports.js"}},"gitHead":"7c5c4508463ac258efd4df9d1abf1535a2d38c5f","scripts":{"test":"bun test --coverage","build":"tsgo --project tsconfig.app.json","check":"bun run --parallel 'check:*'","format":"prettier --write .","prepack":"bun run --sequential check test build","prebuild":"bun scripts/clean.ts","check:types":"tsgo --noEmit --project tsconfig.app.json","check:format":"prettier --check --log-level warn .","check:test-types":"tsgo --noEmit --project tsconfig.test.json"},"_npmUser":{"name":"alteredconstants","email":"npm@alteredconstants.com"},"repository":{"url":"git+https://github.com/AlteredConstants/express-router.git","type":"git"},"_npmVersion":"10.8.2","description":"In Express 5, [there is currently no way](https://github.com/expressjs/express/discussions/5961) to get access to the route information of a router from within the app or router objects themselves. This makes it essentially impossible to inspect all the r","directories":{},"_nodeVersion":"20.18.3","_hasShrinkwrap":false,"devDependencies":{"prettier":"3.8.1","@types/bun":"latest","typescript":"^6.0.3","@types/express":"^5.0.6","@typescript/native-preview":"^7.0.0-dev.20260617.2","@trivago/prettier-plugin-sort-imports":"6.0.2"},"peerDependencies":{"express":"^5"},"_npmOperationalInternal":{"tmp":"tmp/express-router_0.1.1_1781752269913_0.04887718117623496","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@alteredconstants/express-router","version":"0.1.2","author":{"name":"Zeff Svoboda"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/AlteredConstants/express-router.git"},"type":"module","exports":{".":{"import":"./dist/exports.js","types":"./dist/exports.d.ts"}},"scripts":{"prepack":"bun run --sequential check test build","prebuild":"bun scripts/clean.ts","build":"tsgo --project tsconfig.app.json","test":"bun test --coverage","format":"prettier --write .","check:types":"tsgo --noEmit --project tsconfig.app.json","check:test-types":"tsgo --noEmit --project tsconfig.test.json","check:format":"prettier --check --log-level warn .","check":"bun run --parallel 'check:*'"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"6.0.2","@types/bun":"latest","@types/express":"^5.0.6","@typescript/native-preview":"^7.0.0-dev.20260617.2","prettier":"3.8.1","typescript":"^6.0.3"},"peerDependencies":{"express":"^5"},"engines":{"bun":">=1.3.9"},"_id":"@alteredconstants/express-router@0.1.2","gitHead":"7ab048e4becd84f4113f72525347face4dbb002a","description":"In Express 5, [there is currently no way](https://github.com/expressjs/express/discussions/5961) to get access to the route information of a router from within the app or router objects themselves. This makes it essentially impossible to inspect all the r","bugs":{"url":"https://github.com/AlteredConstants/express-router/issues"},"homepage":"https://github.com/AlteredConstants/express-router#readme","_nodeVersion":"20.18.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-SjfZrH/qg282L8YwVUIDCuyRkKPYAZtf4YIPVsyZWcFksW7gZ/dlycX4uZ8AZncUu2uG+/mHO2CxMHGmpdZFlQ==","shasum":"136405cec7ba83e5076ac6b5c8f64c79599cc8f4","tarball":"https://registry.npmjs.org/@alteredconstants/express-router/-/express-router-0.1.2.tgz","fileCount":33,"unpackedSize":30042,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDD8cJktEGYt2zsaLB/y1yf74Bu+H6xqduDaTj6WfpFrAiBRRkvCxgH+rrjiMiDXnfyToVuOD/bv9W3VnmJTOve4Cg=="}]},"_npmUser":{"name":"alteredconstants","email":"npm@alteredconstants.com"},"directories":{},"maintainers":[{"name":"alteredconstants","email":"npm@alteredconstants.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/express-router_0.1.2_1781753440644_0.7050620980040956"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-11T22:09:31.328Z","modified":"2026-06-18T03:30:40.851Z","0.1.0":"2026-03-11T22:09:31.535Z","0.1.1":"2026-06-18T03:11:10.054Z","0.1.2":"2026-06-18T03:30:40.767Z"},"bugs":{"url":"https://github.com/AlteredConstants/express-router/issues"},"author":{"name":"Zeff Svoboda"},"license":"MIT","homepage":"https://github.com/AlteredConstants/express-router#readme","repository":{"type":"git","url":"git+https://github.com/AlteredConstants/express-router.git"},"description":"In Express 5, [there is currently no way](https://github.com/expressjs/express/discussions/5961) to get access to the route information of a router from within the app or router objects themselves. This makes it essentially impossible to inspect all the r","maintainers":[{"name":"alteredconstants","email":"npm@alteredconstants.com"}],"readme":"# Express Router With Route Inspection\n\nIn Express 5, [there is currently no way](https://github.com/expressjs/express/discussions/5961) to get access to the route information of a router from within the app or router objects themselves. This makes it essentially impossible to inspect all the routes in one place which is especially frustrating if they are spread across many nested routers and/or files.\n\nThis library provides a thin wrapper over the `Router` constructor from Express which makes it possible to track the route configuration for later logging.\n\n## Installation\n\n```shell\nnpm install @alteredconstants/express-router\n```\n\nYou will also have to install Express if you haven't already.\n\n```shell\nnpm install express\n```\n\n## Example\n\n```javascript\n// routes.js\nimport {\n\tcreateRouter,\n\tsetRouteRequestHandlerName,\n} from \"@alteredconstants/express-router\";\n\n// Define your middleware however you'd like.\nconst users = [{ id: 1, name: \"Steve\" }];\nconst products = [{ id: 1, name: \"Golden Apple\" }];\nconst authUser = (req, res, next) => next();\nconst authProducts = (type) =>\n\t// Use this function to set a dynamic handler name in the output.\n\tsetRouteRequestHandlerName(\n\t\t(req, res, next) => next(),\n\t\t`authProducts(${type})`,\n\t);\nconst canViewProducts = authProducts(\"view\");\nconst canAddProduct = authProducts(\"add\");\nconst getUsers = (req, res) => res.send(users);\nconst getProducts = (req, res) => res.send(products);\nconst getProduct = (req, res) => res.send(product[0]);\nconst addProduct = (req, res) => res.send({ message: \"Added!\" });\n\n// Create and compose routers together.\nconst productsRouter = createRouter({\n\tmiddleware: [canViewProducts],\n\troutes: [\n\t\t[\"get\", \"/\", getProducts],\n\t\t[\"post\", \"/\", canAddProduct, addProduct],\n\t\t[\"get\", \"/:id\", getProduct],\n\t],\n});\nexport const appRouter = createRouter({\n\tmiddleware: [authUser],\n\troutes: [\n\t\t[\"get\", \"/api/users\", getUsers],\n\t\t[\"use\", \"/api/products\", productsRouter],\n\t],\n});\n```\n\n```javascript\n// index.js\nimport express from \"express\";\nimport { appRouter } from \"./routes.js\";\n\n// Add the routers to your app.\nconst app = express();\napp.use(appRouter);\n```\n\nThen, if you ever want to inspect your routes, you can write a simple script like:\n\n```javascript\n// print-routes.js\nimport { getRoutesGenerator } from \"@alteredconstants/express-router\";\nimport { appRouter } from \"./routes.js\";\n\n// Or use `getRoutes` if you'd prefer an array.\nfor (const { method, path, handlerNames } of getRoutesGenerator(appRouter)) {\n\tconsole.log(method, path, `[${handlerNames.join(\", \")}]`);\n}\n```\n\nThen run the script with the `AC_EXPRESS_ROUTER_TRACKING` environment variable set to a non-empty value to enable the tracking (disabled by default):\n\n```shell\nAC_EXPRESS_ROUTER_TRACKING=true node print-routes.js\n```\n\nIt will generate this output for this example:\n\n```\nGET /api/users [authUser, getUsers]\nGET /api/products [authUser, authProducts(view), getProducts]\nPOST /api/products [authUser, authProducts(view), authProducts(add), addProduct]\nGET /api/products/:id [authUser, authProducts(view), getProduct]\n```\n","readmeFilename":"README.md"}