{"id":21937418,"url":"https://github.com/packingjs/packing-urlrewrite","last_synced_at":"2025-06-18T23:36:45.558Z","repository":{"id":57317857,"uuid":"62116527","full_name":"packingjs/packing-urlrewrite","owner":"packingjs","description":"一个用来做代理和转发URL的express中间件","archived":false,"fork":false,"pushed_at":"2019-12-20T10:43:02.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-31T09:14:56.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/packingjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-28T06:38:57.000Z","updated_at":"2019-12-20T10:43:05.000Z","dependencies_parsed_at":"2022-08-25T20:40:25.694Z","dependency_job_id":null,"html_url":"https://github.com/packingjs/packing-urlrewrite","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/packingjs/packing-urlrewrite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Fpacking-urlrewrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Fpacking-urlrewrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Fpacking-urlrewrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Fpacking-urlrewrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/packingjs","download_url":"https://codeload.github.com/packingjs/packing-urlrewrite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Fpacking-urlrewrite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260653880,"owners_count":23042645,"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-29T01:19:43.706Z","updated_at":"2025-06-18T23:36:40.539Z","avatar_url":"https://github.com/packingjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# packing-urlrewrite\n\n\u003e一个用来做代理和转发URL的 express 中间件\n\n[![NPM](https://nodei.co/npm/packing-urlrewrite.png)](https://nodei.co/npm/packing-urlrewrite/)\n\n## 安装\n```\nnpm install packing-urlrewrite --save-dev\n```\n\n## 使用\n\n```javascript\nimport Express from 'express';\nimport urlrewrite from 'packing-urlrewrite';\n\nconst rules = {\n  // 1.用json模拟数据，标示符为 `require!`\n  '^/api/*': 'require!/mock/api/$0.js',\n  // 2.转发\n  '^/test/*': 'http://test.xxx.com/test/$0'\n};\nconst app = new Express();\napp.use(urlrewrite(rules));\n```\n\n```javascript\n// /mock/api/$0.js\nexport default (req, res) =\u003e {\n  // maybe get parameters from request\n  const data = {\n    name: 'Joe'\n  };\n  res.setHeader('Content-Type', 'application/json');\n  res.end(JSON.stringify(data));\n};\n```\n\n## 参数\n`rules` - {object} 转发规则\n`options` - {object} 可选参数\n`options.mockRoot` - {string} 存放模拟数据的目录在工程中的位置，默认值：`mock`\n`options.useFileMock` - {boolean} 是否启用本地文件模拟数据功能\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpackingjs%2Fpacking-urlrewrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpackingjs%2Fpacking-urlrewrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpackingjs%2Fpacking-urlrewrite/lists"}