← 返回
未分类

Edgeone Pages Dev

This skill guides development of full-stack features on EdgeOne Pages — Edge Functions, Cloud Functions (Node.js / Go / Python runtimes), Middleware, KV Storage, and local dev workflows. It should be used when the user wants to create APIs, serverless functions, middleware, WebSocket endpoints, or full-stack features specifically on EdgeOne Pages — e.g. "create an API", "add a serverless function", "write middleware", "build a full-stack app", "add WebSocket support", "set up edge functions", "u
>-
edgeone-pages
未分类 community v1.0.8 5 版本 99224.8 Key: 无需
★ 0
Stars
📥 128
下载
💾 4
安装
5
版本
#latest

概述

EdgeOne Pages Development Guide

Develop full-stack applications on EdgeOne Pages — Edge Functions, Cloud Functions (Node.js / Go / Python), and Middleware.

When to use this skill

  • Creating APIs, serverless functions, or backend logic on EdgeOne Pages
  • Adding middleware for request interception, redirects, auth guards, or A/B testing
  • Building full-stack apps with static frontend + server-side functions
  • Using KV Storage for edge-side persistent data
  • Setting up WebSocket endpoints (Node.js runtime)
  • Integrating Express, Koa, Gin, Echo, Flask, FastAPI, or Django on EdgeOne Pages
  • Debugging EdgeOne Pages runtime errors (function failures, middleware issues, KV problems)

Do NOT use for:

  • Deployment → use edgeone-pages-deploy skill
  • Next.js / Nuxt middleware or API routes → use the framework's own API, NOT the platform middleware.js
  • Generic Express/Koa/Gin/Flask development outside an EdgeOne Pages project
  • Cloudflare Workers, Vercel Functions, or other platforms

How to use this skill (for a coding agent)

  1. Read the Decision Tree below to pick the correct runtime
  2. Follow the Routing table to load the relevant reference file
  3. Use the code patterns from that reference to implement the user's request

⛔ Critical Rules (never skip)

  1. Choose the right runtime for the task. Follow the Decision Tree — never guess.
  2. Edge Functions run on V8, NOT Node.js. Never use Node.js built-in modules (fs, path, crypto from Node) or npm packages in Edge Functions.
  3. Cloud Functions support three runtimes: Node.js, Go, and Python. Place all function files under cloud-functions/ directory. The platform detects the language by file extension (.js/.ts → Node.js, .go → Go, .py → Python).
  4. Node.js functions return a standard Web Response object, not res.send() — unless using Express/Koa via the [[default]].js pattern.
  5. Go Handler mode requires http.HandlerFunc signature; Framework mode uses standard framework code with auto port/path adaptation.
  6. Python entry files are identified by class/app patterns (class handler(BaseHTTPRequestHandler), app = Flask(...), app = FastAPI(...)). Other .py files are treated as helper modules.
  7. Middleware is for lightweight request interception only. Never put heavy computation or database calls in middleware.
  8. Always use edgeone pages dev for local development. Never run a separate dev server for functions — the CLI handles everything on port 8088.
  9. Never configure edgeone pages dev as the devCommand in edgeone.json or as the dev script in package.json — this causes infinite recursion.
  10. For framework projects (Next.js, Nuxt, etc.), use the framework's own middleware — NOT the platform middleware.js.

Technology Decision Tree

Request interception / redirect / rewrite / auth guard / A/B test?
  → Middleware                                        → read references/middleware.md

Lightweight API with ultra-low latency (simple logic, no npm)?
  → Edge Functions                                    → read references/edge-functions.md

KV persistent storage? (⚠️ enable KV in console first)
  → Edge Functions + KV Storage                       → read references/kv-storage.md

Complex backend with npm packages / database / WebSocket?
  → Cloud Functions (Node.js)                         → read references/node-functions.md

Express or Koa framework?
  → Cloud Functions (Node.js) with [[default]].js     → read references/node-functions.md

High-performance API with Go (Gin / Echo / Chi / Fiber)?
  → Cloud Functions (Go)                              → read references/go-functions.md

Python API with Flask / FastAPI / Django / Sanic?
  → Cloud Functions (Python)                          → read references/python-functions.md

Pure static site with no server-side logic?
  → No functions needed — just deploy static files

Need a project structure template?
  → read references/recipes.md

Runtime Comparison

FeatureEdge FunctionsCloud Functions (Node.js)Cloud Functions (Go)Cloud Functions (Python)Middleware
----------------------------------------------------------------------------------------------------------
RuntimeV8 (like CF Workers)Node.js v20.xGo 1.26+Python 3.10V8 (edge)
npm/packages❌ Not supported✅ Full npm ecosystem✅ Go modules✅ pip (auto-detect)❌ Not supported
Max code size5 MB128 MB128 MB128 MB (incl. deps)Part of edge bundle
Max request body1 MB6 MB6 MB6 MBN/A (passes through)
Max CPU / wall time200 ms CPU120 s wall clock120 s wall clock120 s wall clockLightweight only
KV Storage✅ Yes (global variable)❌ No❌ No❌ No❌ No
WebSocket❌ No✅ Yes❌ No❌ No❌ No
Framework supportExpress, KoaGin, Echo, Chi, FiberFlask, FastAPI, Django, Sanic
Use caseLightweight APIs, edge computeComplex APIs, full-stackHigh-perf APIs, compiled speedData science, ML, rapid prototypingRequest preprocessing

Cloud Functions — Language Comparison

FeatureNode.jsGoPython
-------------------------------
File extension.js / .ts.go.py
Handler styleexport function onRequest(ctx)Responsefunc Handler(w, r) (Handler) or func main() (Framework)class handler(BaseHTTPRequestHandler) or framework app instance
Framework modeExpress/Koa via [[default]].jsGin/Echo/Chi/Fiber via entry .go fileFlask/FastAPI/Django via entry .py file
Dependency managementpackage.json (npm)go.mod (auto)requirements.txt + auto-detect
Dev modesHandler / FrameworkHandler / FrameworkHandler / WSGI / ASGI

Routing

TaskRead
------------
Edge Functions (lightweight APIs, V8 runtime, KV Storage)references/edge-functions.md
KV Storage (persistent key-value storage on edge)references/kv-storage.md
Cloud Functions — Node.js (npm, database, Express/Koa, WebSocket)references/node-functions.md
Cloud Functions — Go (Gin, Echo, Chi, Fiber, net/http)references/go-functions.md
Cloud Functions — Python (Flask, FastAPI, Django, Sanic, Handler)references/python-functions.md
Middleware (redirects, rewrites, auth guards, A/B testing)references/middleware.md
Project structure templates and common recipesreferences/recipes.md
Debugging and troubleshootingreferences/troubleshooting.md

Environment Setup

Before executing any edgeone CLI command (pages init, pages dev, pages link, pages env pull, etc.), set the following environment variable in the current shell session:

export PAGES_SOURCE=skills

Or prefix each command inline:

PAGES_SOURCE=skills edgeone pages dev

This tells the platform that the command is triggered from an AI skill context.


Project Setup (Quick Start)

Initialize the project:

export PAGES_SOURCE=skills   # Required before any edgeone command
edgeone pages init

Start local development:

edgeone pages dev            # Serves everything on http://localhost:8088/

Link project (required for KV & env vars):

edgeone pages link

Manage environment variables:

edgeone pages env pull       # Pull from console to local .env

Access env vars in functions via context.env.KEY (Node.js), os.Getenv("KEY") (Go), or os.environ.get("KEY") (Python).

For detailed project structures and recipes, see references/recipes.md.

版本历史

共 5 个版本

  • v1.0.8 更新图标 当前
    2026-05-22 15:13 安全 安全
  • v1.0.7 更新图标和描述
    2026-05-22 15:04 安全 安全
  • v1.0.6 Initial release
    2026-05-22 14:57 安全 安全
  • v1.0.5 新增设置环境变量
    2026-05-08 11:41 安全 安全
  • v1.0.0 Initial release
    2026-04-24 14:17 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,350 📥 317,723
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 667 📥 323,821
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,056 📥 796,196