{"id":19153379,"url":"https://github.com/leetcode-opensource/typed-path-generator","last_synced_at":"2025-05-07T06:26:26.280Z","repository":{"id":48295026,"uuid":"174118102","full_name":"LeetCode-OpenSource/typed-path-generator","owner":"LeetCode-OpenSource","description":"🏇 A more effective way to handle path parameters, which works perfectly with Typescript","archived":false,"fork":false,"pushed_at":"2023-04-07T09:50:57.000Z","size":1004,"stargazers_count":7,"open_issues_count":13,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-18T21:41:42.604Z","etag":null,"topics":[],"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/LeetCode-OpenSource.png","metadata":{"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":"2019-03-06T09:53:12.000Z","updated_at":"2024-05-14T15:26:03.000Z","dependencies_parsed_at":"2024-11-09T08:35:08.950Z","dependency_job_id":null,"html_url":"https://github.com/LeetCode-OpenSource/typed-path-generator","commit_stats":{"total_commits":372,"total_committers":4,"mean_commits":93.0,"dds":"0.11290322580645162","last_synced_commit":"86e1b7121c26f7c55b0ebc158579c24a71656279"},"previous_names":["leetcode-opensource/typed-route-generator"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeetCode-OpenSource%2Ftyped-path-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeetCode-OpenSource%2Ftyped-path-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeetCode-OpenSource%2Ftyped-path-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeetCode-OpenSource%2Ftyped-path-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeetCode-OpenSource","download_url":"https://codeload.github.com/LeetCode-OpenSource/typed-path-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252826017,"owners_count":21810032,"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":[],"created_at":"2024-11-09T08:22:54.954Z","updated_at":"2025-05-07T06:26:26.249Z","avatar_url":"https://github.com/LeetCode-OpenSource.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003e🏇 typed-path-generator\u003c/h1\u003e\n\u003cp align=\"center\"\u003eConvert path \u003ccode\u003e/user/:userID\u003c/code\u003e to \u003ccode\u003e(params: { userID: string | number }) =\u003e string\u003c/code\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/LeetCode-OpenSource/typed-path-generator/blob/master/LICENSE\"\u003e\n    \u003cimg alt=\"GitHub license\" src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/LeetCode-OpenSource/typed-path-generator/pulls\"\u003e\n    \u003cimg alt=\"PRs Welcome\" src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/prettier/prettier\"\u003e\n    \u003cimg alt=\"code style: prettier\" src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/typed-path-generator\"\u003e\n    \u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/typed-path-generator.svg?style=flat\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nWith [Typescript](https://typescriptlang.org/), handling [path parameters](https://github.com/pillarjs/path-to-regexp#parameters) could be very frustrating. Because there is no type checking for path parameters which is only a `string` type, we have to define it manually in an error-prone way. To free us from those work, `typed-path-generator` was created. By pre-processing the path string, `typed-path-generator` will extract the type info from path parameters and generate a well defined Typescript file.\n\n## Quick Start\n\n### Install\n\nusing [yarn](https://yarnpkg.com/):\n\n```bash\nyarn add typed-path-generator\n```\n\nor via [npm](https://docs.npmjs.com):\n\n```bash\nnpm install typed-path-generator\n```\n\n### Config paths\n\n`typed-path-generator` using [YAML](https://yaml.org) as configuration file. Here's an example:\n\n```yaml\noptions:\n  variableName:\n    # Used to customize the export variables of generated file.\n    # import { path, to } from './generated-file.ts'\n\n    # Optional, default is `staticPath`\n    staticPath: path\n    # Optional, default is `pathFactory`\n    pathFactory: to\n    # Optional, default is `ParamsInterface`\n    ParamsInterface: Params\n\npaths:\n  # type URL = string // any valid URL path that path-to-regexp understands. see https://github.com/pillarjs/path-to-regexp for more details.\n  # interface Paths {\n  #   [key: string]: URL | Paths\n  # }\n  user: /user/:userID\n  settings:\n    emails: /settings/emails\n  discuss:\n    list: /discuss\n    detail: /discuss/:discussID\n```\n\n### Generate code\n\nrun `typed-path-generator` to generate a relative typescript file:\n\n```bash\ntyped-path-generator ./your-config-file.yaml\n```\n\nfurthermore, you can use **[glob patterns](\u003chttps://en.wikipedia.org/wiki/Glob_(programming)\u003e)** to specify a group of configuration files:\n\n```bash\ntyped-path-generator ./packages/**/route.yaml\n```\n\n##### Options:\n\n```\n  -V, --version          output the version number\n  -P, --prettier [path]  specify the config path of Prettier\n  -h, --help             output usage information\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleetcode-opensource%2Ftyped-path-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleetcode-opensource%2Ftyped-path-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleetcode-opensource%2Ftyped-path-generator/lists"}