Skip to content

feat: add edgeone adapter#1693

Open
zhxycn wants to merge 1 commit intoelysiajs:mainfrom
zhxycn:main
Open

feat: add edgeone adapter#1693
zhxycn wants to merge 1 commit intoelysiajs:mainfrom
zhxycn:main

Conversation

@zhxycn
Copy link

@zhxycn zhxycn commented Jan 22, 2026

Add EdgeOne Pages adapter for deploying Elysia applications to Tencent Cloud EdgeOne Pages Node Functions.

Features

  • Extends WebStandardAdapter for EdgeOne compatibility
  • Exposes EdgeOne context (clientIp, geo, uuid, region) to route handlers
  • Provides createEdgeOneHandler() for exporting EdgeOne-compatible handlers
  • Plugin compatibility (tested with @elysiajs/swagger)

Usage

// node-functions/api/hello.js
import { Elysia } from 'elysia'
import { EdgeOneAdapter, createEdgeOneHandler } from 'elysia/adapter/edgeone'

const app = new Elysia({
  adapter: EdgeOneAdapter,
})
  .get('/api/hello', (context) => {
    return {
      message: 'Hello EdgeOne',
      clientIp: context.clientIp,
      geo: context.geo,
      uuid: context.uuid,
      edgeoneServer: context.edgeoneServer
    }
  })
  .compile()

export const onRequest = createEdgeOneHandler(app)

Documentation

https://pages.edgeone.ai/document/node-functions

If this PR is merged, I will create corresponding documentation at https://github.com/elysiajs/documentation.

Testing

Successfully tested on EdgeOne. Screenshots below.

image image image

Note: Without a custom domain, clientIp and geo are not available. I tested with my own domain, and the IP shown in the screenshot is from a proxy to demonstrate the geo-location feature.

image

Summary by CodeRabbit

  • New Features

    • Added EdgeOne adapter for Elysia, enabling applications to run on the EdgeOne edge computing platform with full access to EdgeOne-specific context and request properties.
  • Tests

    • Added comprehensive test suite for EdgeOne adapter covering core functionality and request handling scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Walkthrough

This pull request introduces EdgeOne adapter support for Elysia. It adds a new export in package.json, implements an EdgeOne adapter with context handling and handler creation, and includes comprehensive test coverage for the new adapter integration.

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Adds new export entry for ./adapter/edgeone with types, import, and require paths pointing to built distribution files.
EdgeOne Adapter Implementation
src/adapter/edgeone/index.ts
Introduces EdgeOneContext interface, EdgeOneAdapter constant, and createEdgeOneHandler function. Captures EdgeOne-specific request properties (uuid, params, env, clientIp, geo, server) and exposes them on Elysia context. Handler validates app compilation before delegating to app.fetch.
EdgeOne Adapter Tests
test/adapter/edgeone/index.test.ts
Comprehensive test suite covering basic request handling, route parameters, context properties, POST/GET/query operations, 404 behavior, HTTP method routing, and compilation validation.

Sequence Diagram

sequenceDiagram
    actor Client as EdgeOne Platform
    participant Handler as createEdgeOneHandler
    participant Adapter as EdgeOne Adapter
    participant App as Elysia App

    Client->>Handler: onRequest(edgeOneContext)
    Handler->>Adapter: Validate app compiled
    Adapter->>Adapter: Cast context to EdgeOneContext
    Adapter->>App: app.fetch(request, context)
    App->>App: Route & process request
    App-->>Adapter: Response
    Adapter-->>Handler: Response
    Handler-->>Client: HTTP Response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A new edge adapter hops in,
EdgeOne's context, now official spin,
Routes and handlers, all wired just right,
Tests prove the magic works day and night! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add edgeone adapter' directly and clearly summarizes the main change—adding a new EdgeOne adapter to the Elysia framework.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant