{"id":28898845,"url":"https://github.com/kne-union/fastify-shorten","last_synced_at":"2026-03-06T01:02:24.111Z","repository":{"id":291911425,"uuid":"979184868","full_name":"kne-union/fastify-shorten","owner":"kne-union","description":"Fastify Shorten 是一个专为 Fastify 框架设计的 URL 缩短服务插件，提供完整的短链接生成和管理功能","archived":false,"fork":false,"pushed_at":"2025-10-21T10:17:31.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-21T12:16:37.096Z","etag":null,"topics":["fastify","fastify-plugin","url-shortener"],"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/kne-union.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-07T06:06:33.000Z","updated_at":"2025-10-21T10:15:29.000Z","dependencies_parsed_at":"2025-05-07T07:25:03.398Z","dependency_job_id":"164c3e30-f7a6-47dd-9664-b8c34edfa381","html_url":"https://github.com/kne-union/fastify-shorten","commit_stats":null,"previous_names":["kne-union/fastify-shorten"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/kne-union/fastify-shorten","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kne-union%2Ffastify-shorten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kne-union%2Ffastify-shorten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kne-union%2Ffastify-shorten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kne-union%2Ffastify-shorten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kne-union","download_url":"https://codeload.github.com/kne-union/fastify-shorten/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kne-union%2Ffastify-shorten/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30156850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"ssl_error","status_checked_at":"2026-03-05T22:39:24.771Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["fastify","fastify-plugin","url-shortener"],"created_at":"2025-06-21T08:00:30.063Z","updated_at":"2026-03-06T01:02:24.088Z","avatar_url":"https://github.com/kne-union.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# fastify-shorten\n\n\n### 描述\n\nFastify Shorten 是一个专为 Fastify 框架设计的 URL 缩短服务插件，提供完整的短链接生成和管理功能\n\n\n### 安装\n\n```shell\nnpm i --save @kne/fastify-shorten\n```\n\n\n### 概述\n\n#### 功能概述\n\nFastify Shorten 是一个专为 Fastify 框架设计的 URL 缩短服务插件，提供完整的短链接生成和管理功能。\n\n#### 核心特性\n\n- 🚀 **高性能短链生成**：基于高效算法快速生成短码\n- 🔗 **URL 重定向**：自动将短链接重定向到原始 URL\n- 🛠️ **可配置选项**：支持自定义短码长度、重试机制等\n- 🗃️ **数据库集成**：自动管理短链接存储表\n#### 使用场景\n\n1. 营销活动链接追踪\n2. 社交媒体链接优化\n3. 企业内部链接管理\n4. 需要缩短长URL的任何应用\n\n#### 基本用法\n```javascript\nconst fastify = require('fastify')();\nconst shortenPlugin = require('@kne/fastify-shorten');\n\n// 注册插件\nfastify.register(shortenPlugin, {\n  // 此处填写配置项\n});\n\nfastify.listen({ port: 3000 }, (err) =\u003e {\n  if (err) throw err;\n  console.log('服务器运行在 3000 端口');\n});\n```\n\n#### 注意事项\n1. 需要预先配置好数据库连接\n2. 确保数据库用户有创建表的权限\n3. 生产环境建议修改默认表名前缀\n\n#### 许可证\n[MIT](https://opensource.org/licenses/MIT)\n\n### 示例\n\n#### 示例代码\n\n\n\n### API\n\n#### 配置选项\n\n| 选项 | 类型 | 默认值 | 说明 |\n|------|------|--------|------|\n| `maxAttempts` | number | `10` | 生成唯一短码的最大尝试次数 |\n| `length` | number | `6` | 生成的短码长度 |\n| `dbTableNamePrefix` | string | `'t_'` | 数据库表名前缀 |\n\n#### 命名空间注册\n本插件通过 `@kne/fastify-namespace` 自动注册到 `shorten` 命名空间下，所有相关方法可通过 `fastify.shorten` 访问。\n\n#### 自定义配置示例\n```javascript\nfastify.register(shortenPlugin, {\n  maxAttempts: 15,      // 增加尝试次数\n  length: 8,            // 生成长度8的短码\n  dbTableNamePrefix: 'short_' // 自定义表前缀\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkne-union%2Ffastify-shorten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkne-union%2Ffastify-shorten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkne-union%2Ffastify-shorten/lists"}