{"id":29142225,"url":"https://github.com/ethanz-code/typescript-elysia-prisma-starter","last_synced_at":"2026-03-10T20:05:43.550Z","repository":{"id":260590951,"uuid":"880584277","full_name":"ethanz-code/TypeScript-Elysia-Prisma-Starter","owner":"ethanz-code","description":"NodeJS/Bun + Elysia 方向的后端通用模版","archived":false,"fork":false,"pushed_at":"2025-06-18T02:51:07.000Z","size":101,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-08T01:59:58.348Z","etag":null,"topics":["bun","elysia","hash-password","nodejs","payment-integration"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ethanz-code.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}},"created_at":"2024-10-30T01:23:16.000Z","updated_at":"2025-06-18T02:51:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"cc7556a5-b805-4144-b590-3dc71d059426","html_url":"https://github.com/ethanz-code/TypeScript-Elysia-Prisma-Starter","commit_stats":null,"previous_names":["yassine-zhang/typescript-elysia-prisma-starter","ethanz-code/typescript-elysia-prisma-starter"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/ethanz-code/TypeScript-Elysia-Prisma-Starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2FTypeScript-Elysia-Prisma-Starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2FTypeScript-Elysia-Prisma-Starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2FTypeScript-Elysia-Prisma-Starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2FTypeScript-Elysia-Prisma-Starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethanz-code","download_url":"https://codeload.github.com/ethanz-code/TypeScript-Elysia-Prisma-Starter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2FTypeScript-Elysia-Prisma-Starter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30351926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["bun","elysia","hash-password","nodejs","payment-integration"],"created_at":"2025-06-30T19:10:20.152Z","updated_at":"2026-03-10T20:05:43.532Z","avatar_url":"https://github.com/ethanz-code.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 typescript-elysia-prisma-starter\n\n这是一个基于 Bun + Elysia + Prisma 的后端项目框架。\n\n***\n\n## 📁 主要目录结构\n\n```markdown\n.\n├── src/ # 源代码目录\n│ ├── bootstrap/ # 启动相关配置\n│ ├── controllers/ # 控制器层\n│ ├── emails/ # 邮件模板\n│ ├── hooks/ # 中间件钩子\n│ ├── models/ # 数据模型定义\n│ ├── routes/ # 路由定义\n│ ├── types/ # TypeScript 类型定义\n│ └── utils/ # 工具函数\n│   └── pay/ # 支付相关工具函数\n│       └── ltzf/ # 蓝兔支付接口实现\n│           ├── sign.ts # 签名验证\n│           ├── notify.ts # 支付通知处理\n│           └── wx.ts # 微信支付实现\n├── prisma/ # Prisma ORM 相关\n└── public/ # 静态资源目录\n```\n\n## ✨ 核心功能模块\n\n***\n\n1. **认证系统** 🔐\n\n- JWT 认证实现 (`@elysiajs/jwt`)\n- 路由白名单机制 (`auth-whitelist.ts`)\n- 验证码功能:\n  - 图形验证码 (`captcha.ts`)\n  - 邮箱验证码 (`emailCaptcha.ts`)\n\n2. **数据库集成** 🗄️\n\n- 使用 Prisma ORM\n- PostgreSQL 数据库支持\n- 自动时区设置为上海时区\n\n3. **邮件系统** 📧\n\n- 基于 ZeptoMail 的邮件发送\n- HTML 邮件模板支持\n- 验证码邮件功能\n\n4. **支付系统** 💸\n\n- 蓝兔付接口集成\n- 微信支付支持\n- 支付通知处理\n- 签名验证机制\n\n5. **API 路由** 🛣️\n\n- RESTful API 设计\n- 路由前缀管理\n- 统一的错误处理\n\n6. **开发工具链** 🛠️\n\n- Prettier 代码格式化\n- Husky Git hooks\n- dotenvx 环境变量管理\n- TypeScript 支持\n\n## 💡 特色功能\n\n***\n\n1. **环境变量管理** ⚙️\n\n- 支持开发和生产环境配置\n- 环境变量加密功能\n- dotenvx 集成\n\n2. **定时任务** ⏰\n\n- 使用 `@elysiajs/cron` 实现\n- 验证码清理等维护任务\n\n3. **Docker 支持** 🐳\n\n- 完整的 Dockerfile 配置\n- 多平台构建支持\n\n4. **统一响应格式** 📄\n\n```typescript\ninterface ApiResponse\u003cT\u003e {\n  success: boolean;\n  data: T;\n  message?: string;\n  errorCode?: number;\n}\n```\n\n## 🌟 技术栈亮点\n\n***\n\n1. **现代化运行时** ⚡\n\n- 使用 Bun 作为 JavaScript/TypeScript 运行时\n- 高性能特性\n\n2. **类型安全** 🛡️\n\n- 完整的 TypeScript 支持\n- 自定义类型定义\n\n3. **开发体验** 👩‍💻\n\n- 热重载支持\n- 完整的开发工具链\n- 统一的代码风格\n\n4. **安全性** 🔐\n\n- JWT 认证\n- 验证码机制\n- 环境变量加密\n- 支付签名验证\n\n这是一个结构完善的后端项目框架，适合作为中小型项目的起点。它提供了常见的基础设施和最佳实践，同时保持了良好的可扩展性。\n\n## 📖 使用说明\n\n***\n\n### 📦 安装依赖\n\n\u003e 本项目使用 bun v1.1.21 通过 `bun init` 创建。[Bun](https://bun.sh) 是一个快速的全能 JavaScript 运行时。\n\n```bash\nbun install\n```\n\n### 🔒 环境变量\n\n***\n\n项目采用dotenvx管理环境变量，你在拉取此项目后，请先修改`.env.development`和`.env.production`文件，添加你的环境变量。\n\n1. DATABASE_URL： 数据库连接字符串，请根据你的数据库类型，修改此字符串，他在`prisma/schema.prisma`中被引用。\n2. SERVER_PORT： 服务端口，请根据你的需要，修改此端口。\n3. EMAIL：发送功能依赖于ZeptoMail，请先在ZeptoMail注册账号，并添加你的API Token以及其他信息。你也可以移除此模块，使用你自己的邮件发送服务，文件位置：`src/utils/email-sender.ts`。\n4. 支付相关配置：\n   - LTZF_MCH_ID：蓝兔支付商户ID\n   - LTZF_MCH_SECRET：蓝兔支付商户密钥\n   - LTZF_NOTIFY_URL：支付通知回调地址\n   - LTZF_QUIT_URL：支付取消回调地址\n   - LTZF_RETURN_URL：支付完成返回地址\n\n### 🔑 加密和解密说明\n\n***\n\n注意：请不要将环境变量以明文的形式上传到公开仓库，你可使用`bun run encrypt-dev/encrypt-prod`命令，加密`.env.development/.env.production`文件。\n\n另外，请不要将生成的`.env.keys`文件上传到公开仓库，此文件包含你的加密私钥，请妥善保管。\n\n[dotenvx文档](https://dotenvx.com/)\n\n### 📝 Git 提交代码格式化\n\n***\n\n运行以下命令安装husky\n\n```bash\nbun run prepare:fallback\n```\n\n### 🐘 Prisma 配置\n\n***\n\n请先在`prisma/schema.prisma`中创建model，如下：\n\n```prisma\nmodel User {\n  id    Int     @id @default(autoincrement())\n  email String  @unique\n  name  String?\n}\n```\n\n现在你还要留意环境变量`DATABASE_URL`，他需要配置你的数据库连接字符串，请根据你的数据库类型，修改此字符串。\n\n当你每次配置完`schema.prisma`，都要运行命令`bun run migrate-[dev/depl]`，一个是开发环境一个是生产环境。在运行后他会自动执行`bun run generate`这样就可以通过@prisma/client获取到类型提示信息。\n\n\u003e 关于binaryTargets的更多信息，请参考[Prisma文档](https://www.prisma.io/docs/orm/overview/prisma-schema-file-structure/prisma-schema-file-structure#binarytargets)。\n\n### ▶️ 运行项目\n\n***\n\n```bash\nbun run dev\n```\n\n### 🐳 构建 Docker 镜像\n\n***\n\n构建Docker镜像：\n\n```bash\ndocker buildx build --push --platform linux/amd64 -t domain/project-name:latest .\n```\n\n运行镜像：\n\n```bash\ndocker run -d -e DOTENV_PRIVATE_KEY_PRODUCTION=\"***\" -v volume-name:/usr/src/app/media --restart unless-stopped --privileged -p 10010:7777 --name image-name  domain/project-name:latest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanz-code%2Ftypescript-elysia-prisma-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethanz-code%2Ftypescript-elysia-prisma-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanz-code%2Ftypescript-elysia-prisma-starter/lists"}