Skip to content

Commit 7ecd559

Browse files
committed
fix(templates): update guide
1 parent 81951b6 commit 7ecd559

4 files changed

Lines changed: 450 additions & 264 deletions

File tree

external/api-vercel/guide.en.md

Lines changed: 67 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,91 @@
1-
# API Vercel Template
1+
# API Vercel Template Guide
22

3-
An API template optimized for Vercel serverless deployment.
3+
## Overview
44

5-
## Features
5+
jzero deeply integrates with Vercel ecosystem, bringing Go developers a frontend-level deployment experience! Automatically generate Vercel-compliant serverless functions from `.api` definitions, no need to deploy to your own servers.
66

7-
- **RESTful API Structure**: Clean and organized API design
8-
- **Vercel Serverless Deployment**: Optimized for Vercel's serverless functions
9-
- **Built-in Middleware**: Common middleware included out of the box
10-
- **Example Endpoints**: Ready-to-use example API endpoints
7+
### Core Value
118

12-
## Getting Started
9+
-**Zero-Config Deployment**: Deploy directly from Git repository, no extra configuration needed, no servers required, no CI/CD pipeline
10+
-**Global Edge Network**: Deploy Go functions to edge nodes nearest to users using Vercel's global infrastructure, achieving millisecond-level response
11+
-**Free Domain & HTTPS**: Automatically get `.vercel.app` production-grade domain with built-in CDN acceleration and SSL certificates
12+
-**Preview Environments**: Automatically generate independent preview URLs for each PR
1313

14-
```bash
15-
jzero new simpleapi-vercel --branch api-vercel
16-
cd simpleapi-vercel
17-
```
14+
## Quick Start
1815

19-
## Project Structure
16+
### Install jzero
2017

21-
```
22-
.
23-
├── api/ # API endpoints
24-
│ ├── handlers/ # Request handlers
25-
│ ├── logic/ # Business logic
26-
│ └── middleware/ # Middleware functions
27-
├── internal/ # Internal packages
28-
├── go.mod # Go module file
29-
└── vercel.json # Vercel configuration
18+
```bash
19+
# Install jzero
20+
go install github.com/jzero-io/jzero@latest
21+
22+
# Install related tools
23+
jzero check
24+
go install github.com/jzero-io/gorename@latest
3025
```
3126

32-
## Usage Examples
27+
### Create Vercel Project
3328

34-
### Create a New Endpoint
29+
```bash
30+
# Create new Vercel serverless project from remote template
31+
jzero new jzero-api-vercel-example --remote https://github.com/jzero-io/templates --branch api-vercel
3532

36-
```go
37-
// api/hello/hello.go
38-
package hello
33+
# Add new api
34+
jzero add api test
3935

40-
import (
41-
"net/http"
42-
43-
"github.com/zeromicro/go-zero/rest/httpx"
44-
)
36+
# Generate code
37+
jzero gen
38+
```
39+
40+
## Project Structure
4541

46-
func Handler(w http.ResponseWriter, r *http.Request) {
47-
httpx.OkJson(w, map[string]string{
48-
"message": "Hello from Vercel!",
49-
})
50-
}
5142
```
43+
jzero-api-vercel-example/
44+
├── vercel/
45+
│ └── client.go # Vercel Go runtime entry
46+
├── desc/ # API definitions
47+
│ └── api/ # .api files
48+
├── server/ # Server side
49+
│ ├── handler/ # HTTP handlers
50+
│ ├── logic/ # Business logic
51+
│ └── types/ # Type definitions
52+
├── vercel.json # Vercel platform configuration
53+
├── main.go # Local runtime entry
54+
└── go.mod # Go module file
55+
```
56+
57+
## Deploy to Vercel
5258

53-
### Deploy to Vercel
59+
### Git Push to Deploy
60+
61+
jzero-generated projects are fully compatible with Vercel's Git workflow for automatic deployment:
5462

5563
```bash
56-
# Install Vercel CLI
57-
npm i -g vercel
64+
cd jzero-api-vercel-example
65+
66+
# Initialize git
67+
git init
68+
git add .
69+
git commit -m "Initial commit"
5870

59-
# Deploy
60-
vercel
71+
# Create repository on GitHub and push
72+
git remote add origin https://github.com/your-username/jzero-api-vercel-example.git
73+
git push -u origin main
6174
```
6275

63-
## Configuration
76+
### Vercel Platform Auto-Detection
6477

65-
### vercel.json
78+
1. Visit [Vercel Dashboard](https://vercel.com/dashboard)
79+
2. Click "Add New Project"
80+
3. Import your GitHub repository
81+
4. `vercel.json` configuration lets Vercel automatically recognize it as a Go project
82+
5. Click "Deploy"
6683

67-
```json
68-
{
69-
"functions": {
70-
"api/**/*.go": {
71-
"runtime": "go1.x"
72-
}
73-
}
74-
}
75-
```
84+
**🎉 Deployment complete! Your Go API is now connected to Vercel's global network**
7685

77-
## Learn More
86+
## Related Resources
7887

79-
- [Vercel Documentation](https://vercel.com/docs)
80-
- [Go-Zero Documentation](https://go-zero.dev/)
88+
- [jzero GitHub](https://github.com/jzero-io/jzero)
89+
- [jzero Official Site](https://jzero.io)
90+
- [Vercel Template Repository](https://github.com/jzero-io/templates/tree/api-vercel)
91+
- [Example Code Repository](https://github.com/jaronnie/jzero-api-vercel-example)

external/api-vercel/guide.zh.md

Lines changed: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,91 @@
1-
# Vercel API 模板
1+
# API Vercel 模板指南
22

3-
专为 Vercel 无服务器部署优化的 API 模板。
3+
## 概述
44

5-
## 特性
5+
jzero 深度打通 Vercel 生态,让 Go 开发者享受前端级别的部署体验!通过 `.api` 定义自动生成符合 Vercel 规范的无服务器函数,无需再部署到自己的服务器上。
66

7-
- **RESTful API 结构**:清晰有序的 API 设计
8-
- **Vercel 无服务器部署**:专为 Vercel 无服务器函数优化
9-
- **内置中间件**:开箱即用的常用中间件
10-
- **示例端点**:现成可用的 API 示例端点
7+
### 核心价值
8+
9+
-**零配置部署**:从 Git 仓库直接部署,无需额外配置,无需自己的服务器,无需 ci/cd 流程
10+
-**全球边缘网络**:借助 Vercel 的全球基础设施,将 Go 函数部署到离用户最近的边缘节点,实现毫秒级响应
11+
-**免费域名与 HTTPS**:自动获得 `.vercel.app` 生产级域名,内置 CDN 加速和 SSL 证书
12+
-**预览环境**:每次提交 PR 自动生成独立预览 URL
1113

1214
## 快速开始
1315

14-
```bash
15-
jzero new simpleapi-vercel --branch api-vercel
16-
cd simpleapi-vercel
17-
```
16+
### 安装 jzero
1817

19-
## 项目结构
18+
```bash
19+
# 安装 jzero
20+
go install github.com/jzero-io/jzero@latest
2021

21-
```
22-
.
23-
├── api/ # API 端点
24-
│ ├── handlers/ # 请求处理器
25-
│ ├── logic/ # 业务逻辑
26-
│ └── middleware/ # 中间件函数
27-
├── internal/ # 内部包
28-
├── go.mod # Go 模块文件
29-
└── vercel.json # Vercel 配置
22+
# 安装相关工具
23+
jzero check
24+
go install github.com/jzero-io/gorename@latest
3025
```
3126

32-
## 使用示例
27+
### 创建 Vercel 项目
3328

34-
### 创建新端点
29+
```bash
30+
# 从远程模板创建新的 Vercel 无服务器项目
31+
jzero new jzero-api-vercel-example --remote https://github.com/jzero-io/templates --branch api-vercel
3532

36-
```go
37-
// api/hello/hello.go
38-
package hello
33+
# 添加新的 api
34+
jzero add api test
3935

40-
import (
41-
"net/http"
42-
43-
"github.com/zeromicro/go-zero/rest/httpx"
44-
)
36+
# 生成代码
37+
jzero gen
38+
```
39+
40+
## 项目结构
4541

46-
func Handler(w http.ResponseWriter, r *http.Request) {
47-
httpx.OkJson(w, map[string]string{
48-
"message": "Hello from Vercel!",
49-
})
50-
}
5142
```
43+
jzero-api-vercel-example/
44+
├── vercel/
45+
│ └── client.go # Vercel Go 运行时入口
46+
├── desc/ # API 定义
47+
│ └── api/ # .api 文件
48+
├── server/ # 服务端
49+
│ ├── handler/ # HTTP 处理器
50+
│ ├── logic/ # 业务逻辑
51+
│ └── types/ # 类型定义
52+
├── vercel.json # Vercel 平台配置
53+
├── main.go # 本地运行入口
54+
└── go.mod # Go 模块文件
55+
```
56+
57+
## 部署到 Vercel
5258

53-
### 部署到 Vercel
59+
### Git 推送即部署
60+
61+
jzero 生成的项目完全兼容 Vercel 的 Git 工作流,实现代码推送自动部署:
5462

5563
```bash
56-
# 安装 Vercel CLI
57-
npm i -g vercel
64+
cd jzero-api-vercel-example
65+
66+
# 初始化 git
67+
git init
68+
git add .
69+
git commit -m "Initial commit"
5870

59-
# 部署
60-
vercel
71+
# 在 GitHub 上创建仓库并推送
72+
git remote add origin https://github.com/your-username/jzero-api-vercel-example.git
73+
git push -u origin main
6174
```
6275

63-
## 配置
76+
### Vercel 平台自动识别
6477

65-
### vercel.json
78+
1. 访问 [Vercel 控制台](https://vercel.com/dashboard)
79+
2. 点击 "Add New Project"
80+
3. 导入您的 GitHub 仓库
81+
4. `vercel.json` 配置让 Vercel 自动识别为 Go 项目
82+
5. 点击 "Deploy"
6683

67-
```json
68-
{
69-
"functions": {
70-
"api/**/*.go": {
71-
"runtime": "go1.x"
72-
}
73-
}
74-
}
75-
```
84+
**🎉 部署完成!您的 Go API 已接入 Vercel 全球网络**
7685

77-
## 更多信息
86+
## 相关资源
7887

79-
- [Vercel 文档](https://vercel.com/docs)
80-
- [Go-Zero 文档](https://go-zero.dev/)
88+
- [jzero GitHub](https://github.com/jzero-io/jzero)
89+
- [jzero 官网](https://jzero.io)
90+
- [Vercel 模板仓库](https://github.com/jzero-io/templates/tree/api-vercel)
91+
- [示例代码仓库](https://github.com/jaronnie/jzero-api-vercel-example)

0 commit comments

Comments
 (0)