Skip to content
Agentmart
Submit a tool

backend-patterns

后端架构模式、API 设计、数据库优化和 Node.js、Express 和 Next.js API 路由的服务端最佳实践。

Skill by aaione

IndexedMIT★ 29
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/aaione-backend-patterns

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

后端架构模式、API 设计、数据库优化和 Node.js、Express 和 Next.js API 路由的服务端最佳实践。

Use cases: frontend, backend

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/backend-patterns

What's inside

Skill name
backend-patterns
Description
后端架构模式、API 设计、数据库优化和 Node.js、Express 和 Next.js API 路由的服务端最佳实践。
License
MIT
Instructions
594 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Agent Skills spec issues

  • body: 594 lines (spec recommends under 500)

Files (2)

  • SKILL.md
  • openai.yaml · agents/

SKILL.md (first lines)

# 后端开发模式

可扩展服务器端应用的后端架构模式和最佳实践。

## 何时激活

- 设计 REST 或 GraphQL API 端点
- 实现存储库、服务或控制器层
- 优化数据库查询(N+1、索引、连接池)
- 添加缓存(Redis、内存、HTTP 缓存头)
- 设置后台作业或异步处理
- 构建 API 的错误处理和验证结构
- 构建中间件(身份验证、日志记录、速率限制)

## API 设计模式

### RESTful API 结构

```typescript
// PASS:基于资源的 URL
GET    /api/markets                 # 列出资源
GET    /api/markets/:id             # 获取单个资源
POST   /api/markets                 # 创建资源
PUT    /api/markets/:id             # 替换资源
PATCH  /api/markets/:id             # 更新资源
DELETE /api/markets/:id             # 删除资源

// PASS:用于过滤、排序、分页的查询参数
GET /api/markets?status=active&sort=volume&limit=20&offset=0
```

### 存储库模式

```typescript
// 抽象数据访问逻辑
interface MarketRepository {
  findAll(filters?: MarketFilters): Promise<Market[]>
  findById(id: string): Promise<Market | null>
  create(data: CreateMarketDto): Promise<Market>
  update(id: string, data: UpdateMarketDto): Promise<Market>
  delete(id: string): Promise<void>
}

class SupabaseMarketRepository implements MarketRepository {
  async findAll(filters?: MarketFilters): Promise<Market[]> {
    let query = supabase.from('markets').select('*')

    if (filters?.status) {
      query = query.eq('status', filters.status)
    }

    if (filters?.limit) {
      query = query.limit(filters.limit)
    }

    const { data, error } = await query

    if (error) throw new Error(error.message)
    return data
  }

  // 其他方法...
}
```

### 服务层模式

```typescript
// 与数据访问分离的业务逻辑
class MarketService {
  constructor(private marketRepo: MarketRepository) {}

  async searchMarkets(query: string, limit: number = 10): Promise<Market[]> {
    // 业务逻辑
    const embedding = await generateEmbedding(query)
    const results = await this.vectorSearch(embedding, limit)

    // 获取完整数据
    const markets = await this.marketRepo.findByIds(results.map(r => r.id))

    // 按相似度排序
    return markets.sort((a, b) => {
      const scoreA = results.find(r => r.id === a.id)?.score || 0
      const scoreB = results.find(r => r.id === b.id)?.score || 0
      return scoreA - scoreB
    })
  }

  private async vectorSearch(embedding: number[], limit: number) {
    // 向量搜索实现
  }
}
```

### 中间件模式

```typescript
// 请求/响应处理管道
export function withAuth(handler: NextApiHandler): NextApiHandler {
  return async (req, res) => {
    const token = req.headers.authorization?.replace('Bearer ', '')

    if (!token) {
      return res.status(401).json({ error: 'Unauthorized' })
    }

    try {
      const user = await verifyToken(token)
      req.user = user
      return handler(req, res)
    } catch (error) {
      return res.status(401).json({ error: 'Invalid token' })
    }
  }
}

// 使用
export default withAuth(async (req, res) => {
  // 处理程序可以访问 req.user

From aaione/everything-claude-code-zh, MIT.

More from aaione/everything-claude-code-zh

Signals

Stars
29
Forks
14
Open issues
1
Last commit (this folder)
May 31, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from aaione

Cite this page

backend-patterns skill. Agent Mart. https://agentmart.dev/skills/aaione-backend-patterns (last updated 2026-10-24)