{"id":15649403,"url":"https://github.com/azu/express-router-dependency-graph","last_synced_at":"2025-04-30T16:16:18.259Z","repository":{"id":52261519,"uuid":"359763877","full_name":"azu/express-router-dependency-graph","owner":"azu","description":"A static code analysis tool that creates a dependency graph for express routing.","archived":false,"fork":false,"pushed_at":"2023-07-22T04:17:27.000Z","size":152,"stargazers_count":40,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-25T09:13:42.022Z","etag":null,"topics":["dependency-graph","express","node","tool","visualize"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azu.png","metadata":{"funding":{"github":"azu"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-20T09:48:55.000Z","updated_at":"2025-02-22T14:41:24.000Z","dependencies_parsed_at":"2024-06-19T22:47:26.853Z","dependency_job_id":"72872622-a52d-4779-9668-ca9c94c2bf1e","html_url":"https://github.com/azu/express-router-dependency-graph","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fexpress-router-dependency-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fexpress-router-dependency-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fexpress-router-dependency-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fexpress-router-dependency-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azu","download_url":"https://codeload.github.com/azu/express-router-dependency-graph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242673795,"owners_count":20167294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-graph","express","node","tool","visualize"],"created_at":"2024-10-03T12:29:37.865Z","updated_at":"2025-03-09T09:30:29.932Z","avatar_url":"https://github.com/azu.png","language":"TypeScript","funding_links":["https://github.com/sponsors/azu"],"categories":[],"sub_categories":[],"readme":"# express-router-dependency-graph\n\nCreate dependency graph for express routing.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n    npx express-router-dependency-graph \"src/**/*.ts\"\n\n## Usage\n\n    Usage\n      $ express-router-dependency-graph [input]\n \n    Options\n      --cwd                   [Path:String] current working directory. Default: process.cwd()\n      --rootBaseUrl           [Path:String] if pass it, replace rootDir with rootDirBaseURL in output.\n      --format                [\"json\" | \"markdown\"] output format. Default: markdown\n\n    Examples\n      # analyze all ts files in src directory\n      $ express-router-dependency-graph \"src/**/*.ts\"\n      # analyze all ts files in src directory and output json\n      $ express-router-dependency-graph \"src/**/*.ts\" --format=json\n      # analyze all js and ts files in src directory\n      $ express-router-dependency-graph \"src/**/*.ts\" \"src/**/*.js\"\n      # change rootDir to rootDirBaseURL to output\n      $ express-router-dependency-graph \"src/**/*.ts\" --rootBaseUrl=\"https://github.com/owner/repo/tree/master/src\"\n      # include node_modules\n      # node_modules, dist, build, test, __tests__ are excluded by default\n      $ express-router-dependency-graph \"src/**/*.ts\" --noDefaultExcludes\n\n## Example\n\nExample output: `--format=markdown`\n\n- File: file path\n- Method: get | post | put | delete | `use`(express's use)\n- Routing: routing path name\n- Middlewares: used middlewares\n  - Note: `app.use(\"/test\", () =\u003e { ... })` is shown \"Anonymous Function\" middleware\n- FilePath: source code position\n\n| File         | Method | Routing         | Middlewares  | FilePath            |\n| ------------ | ------ | --------------- | ------------ |---------------------|\n| src/game.ts  |        |                 |              |                     |\n|              | get    | /getGameById    | requireRead  | src/game.ts#L11-L12 |\n|              | get    | /getGameList    | requireRead  | src/game.ts#L13-L14 |\n|              | post   | /updateGameById | requireWrite | src/game.ts#L15-L16 |\n|              | delete | /deleteGameById | requireWrite | src/game.ts#L17-L18 |\n| src/index.ts |        |                 |              |                     |\n|              | use    | /user           | user         | src/index.ts#L8-L8  |\n|              | use    | /game           | game         | src/index.ts#L9-L9  |\n| src/user.ts  |        |                 |              |                     |\n|              | get    | /getUserById    | requireRead  | src/user.ts#L10-L11 |\n|              | get    | /getUserList    | requireRead  | src/user.ts#L12-L13 |\n|              | post   | /updateUserById | requireWrite | src/user.ts#L14-L15 |\n|              | delete | /deleteUserById | requireWrite | src/user.ts#L16-L17 |`\n\nExample output: `--format=json`\n\n```json5\n[\n  {\n    filePath: \"\u003croot\u003e/src/game.ts\",\n    routers: [\n      {\n        method: \"get\",\n        path: \"/getGameById\",\n        middlewares: [\"requireRead\"],\n        range: [288, 338],\n        loc: { start: { line: 11, column: 0 }, end: { line: 12, column: 2 } }\n      },\n      {\n        method: \"get\",\n        path: \"/getGameList\",\n        middlewares: [\"requireRead\"],\n        range: [340, 390],\n        loc: { start: { line: 13, column: 0 }, end: { line: 14, column: 2 } }\n      },\n      {\n        method: \"post\",\n        path: \"/updateGameById\",\n        middlewares: [\"requireWrite\"],\n        range: [392, 447],\n        loc: { start: { line: 15, column: 0 }, end: { line: 16, column: 2 } }\n      },\n      {\n        method: \"delete\",\n        path: \"/deleteGameById\",\n        middlewares: [\"requireWrite\"],\n        range: [449, 506],\n        loc: { start: { line: 17, column: 0 }, end: { line: 18, column: 2 } }\n      }\n    ]\n  },\n  {\n    filePath: \"\u003croot\u003e/src/index.ts\",\n    routers: [\n      {\n        method: \"use\",\n        path: \"/user\",\n        middlewares: [\"user\"],\n        range: [140, 162],\n        loc: { start: { line: 8, column: 0 }, end: { line: 8, column: 22 } }\n      },\n      {\n        method: \"use\",\n        path: \"/game\",\n        middlewares: [\"game\"],\n        range: [164, 186],\n        loc: { start: { line: 9, column: 0 }, end: { line: 9, column: 22 } }\n      }\n    ]\n  },\n  {\n    filePath: \"\u003croot\u003e/src/user.ts\",\n    routers: [\n      {\n        method: \"get\",\n        path: \"/getUserById\",\n        middlewares: [\"requireRead\"],\n        range: [287, 337],\n        loc: { start: { line: 10, column: 0 }, end: { line: 11, column: 2 } }\n      },\n      {\n        method: \"get\",\n        path: \"/getUserList\",\n        middlewares: [\"requireRead\"],\n        range: [339, 389],\n        loc: { start: { line: 12, column: 0 }, end: { line: 13, column: 2 } }\n      },\n      {\n        method: \"post\",\n        path: \"/updateUserById\",\n        middlewares: [\"requireWrite\"],\n        range: [391, 446],\n        loc: { start: { line: 14, column: 0 }, end: { line: 15, column: 2 } }\n      },\n      {\n        method: \"delete\",\n        path: \"/deleteUserById\",\n        middlewares: [\"requireWrite\"],\n        range: [448, 505],\n        loc: { start: { line: 16, column: 0 }, end: { line: 17, column: 2 } }\n      }\n    ]\n  }\n]\n```\n\n## Changelog\n\nSee [Releases page](https://github.com/azu/express-router-dependency-graph/releases).\n\n## Related\n\n- [node.js - How to get all registered routes in Express? - Stack Overflow](https://stackoverflow.com/questions/14934452/how-to-get-all-registered-routes-in-express)\n    - Almost approach require runtime approach\n\n## Running tests\n\nInstall devDependencies and Run `npm test`:\n\n    npm test\n\n### Add test case\n\n1. Add test case to `test/snapshot/\u003ctest-name\u003e/app.ts`\n2. Run `npm run updateSnspahots`\n3. Check `test/snapshot/\u003ctest-name\u003e/output.{json,md}`\n4. Commit it!\n\n## Contributing\n\nPull requests and stars are always welcome.\n\nFor bugs and feature requests, [please create an issue](https://github.com/azu/express-router-dependency-graph/issues).\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Author\n\n- azu: [GitHub](https://github.com/azu), [Twitter](https://twitter.com/azu_re)\n\n## License\n\nMIT © azu\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Fexpress-router-dependency-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazu%2Fexpress-router-dependency-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Fexpress-router-dependency-graph/lists"}