A Bark push notification server implementation for EdgeOne Pages Edge Functions, enabling distributed push notification delivery on edge nodes worldwide.
Choose your preferred deployment method:
- Node.js 18+
- Git
# Clone the repository
git clone https://github.com/AkinoKaede/bark-edgeone.git
cd bark-edgeone
# Install dependencies
npm install# Login to your EdgeOne account
npx edgeone loginThis will open a browser window for authentication.
# Link to existing project or create new one
npx edgeone linkEnter your project name. If the project doesn't exist, you'll be prompted to create it.
KV namespace must be configured via the web dashboard:
- Go to EdgeOne → Service Overview (default page)
- Navigate to KV Storage → Create Namespace
- Name it
bark-kv(or any name you prefer) - Go to EdgeOne → Service Overview → Your Project Name
- Navigate to KV Storage → Bind Namespace
- Select
bark-kvand set binding name toKV_STORAGE - Save the binding
# Generate a secure proxy secret (HIGHLY RECOMMENDED)
export PROXY_SECRET=$(openssl rand -hex 32)
# Set proxy secret (highly recommended for security)
npx edgeone pages env set APNS_PROXY_SECRET "$PROXY_SECRET"
# Optional: Set authentication credentials
npx edgeone pages env set AUTH_CREDENTIALS "admin:your-secure-password"
# Optional: Set batch push limit
npx edgeone pages env set MAX_BATCH_PUSH_COUNT "64"
# Optional: Configure custom APNs credentials (only if you have your own)
# Most users don't need these - default values work for Bark app
# npx edgeone pages env set APNS_TOPIC "me.fin.bark"
# npx edgeone pages env set APNS_KEY_ID "YOUR_KEY_ID"
# npx edgeone pages env set APNS_TEAM_ID "YOUR_TEAM_ID"
# npx edgeone pages env set APNS_PRIVATE_KEY "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"Important:
- APNS_PROXY_SECRET is highly recommended for securing the proxy endpoint
- APNs credentials (APNS_TOPIC, APNS_KEY_ID, etc.) are optional - most users don't need them
- See docs/en/configuration/env.md for complete documentation
npx edgeone pages deploy- Go to https://github.com/AkinoKaede/bark-edgeone
- Click Fork button in the top-right corner
- Fork the repository to your GitHub account
- Go to EdgeOne Pages Dashboard
- Click Create Project
- Select GitHub Integration
- Connect your GitHub account (if not already connected)
- Select your forked
bark-edgeonerepository - Click Deploy
The build configuration is automatically loaded from edgeone.json in the repository.
- Go to EdgeOne → Service Overview (default page)
- Navigate to KV Storage → Create Namespace
- Name it
bark-kv(or any name you prefer) - Click Create
- Go to EdgeOne → Service Overview → Your Project Name
- Navigate to KV Storage → Bind Namespace
- Select
bark-kvand set binding name toKV_STORAGE - Save the binding
- In your project dashboard, navigate to Settings → Environment Variables
- Add the following variables:
Highly Recommended:
APNS_PROXY_SECRET = <generate using: openssl rand -hex 32>
Optional Variables:
AUTH_CREDENTIALS = admin:your-secure-password
MAX_BATCH_PUSH_COUNT = 64
Custom APNs Credentials (only if you have your own - most users don't need these):
APNS_TOPIC = me.fin.bark
APNS_KEY_ID = YOUR_KEY_ID
APNS_TEAM_ID = YOUR_TEAM_ID
APNS_PRIVATE_KEY = -----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----
- Click Save
Important:
- APNS_PROXY_SECRET is highly recommended for securing the proxy endpoint
- APNs credentials are optional - default values work for the Bark app
- See docs/en/configuration/env.md for complete documentation
Push to your forked repository to trigger automatic deployment.
- Go to your project's Domain Management page
- view your project's domain
- Test the health endpoint:
curl https://your-domain.edgeone.cool/api/healthz
# Expected response: ok- In your project page, navigate to Domain Management
- Click Add Custom Domain
- Enter your domain name
- Configure DNS records as instructed
- Wait for SSL certificate provisioning
Issue: EdgeOne Pages KV storage only guarantees eventual consistency. After device registration, there may be a delay before the device token becomes available for push notifications.
Impact:
- Typical delay: A few seconds
- Maximum delay: Up to 1 hour (in rare cases)
- During this period, push notifications to newly registered devices may fail
Workaround:
- Wait a few seconds after registration before sending the first push notification
- Implement retry logic in your client applications
- This is a platform limitation and cannot be avoided
Issue: EdgeOne Edge Functions Runtime currently does not support HTTP/2 in the fetch API, which is required by Apple Push Notification service (APNs).
Current Solution:
- We use Node Functions as an HTTP/2 reverse proxy (
/apns-proxy) - Edge Functions forward APNs requests to the Node Functions proxy
- The proxy handles HTTP/2 communication with Apple's servers
Routing Limitation:
- Due to EdgeOne routing constraints, all Edge Functions are placed under
/api/* - This prevents conflicts between Edge Functions catch-all routes and Node Functions
Future Changes (Breaking):
- Once EdgeOne Edge Functions Runtime supports HTTP/2 in
fetch:- The Node Functions proxy will be removed
- API paths will be moved from
/api/*to/*(breaking change) - Example:
/api/push→/push,/api/register→/register
Migration Plan:
- When HTTP/2 support is added, we will:
- Announce the breaking change with a migration period
- Provide redirect rules for backward compatibility
- Update documentation with new endpoints
# Start local development server
npx edgeone pages dev
# Server will be available at http://localhost:8088bark-edgeone/
├── edge-functions/ # EdgeOne Edge Functions
│ └── api/ # All API endpoints under /api
│ ├── push.ts # POST /api/push
│ ├── register/ # /api/register/*
│ ├── ping.ts # GET /api/ping
│ ├── healthz.ts # GET /api/healthz
│ ├── info.ts # GET /api/info
│ └── [[default]].ts # V1 API catch-all
├── node-functions/ # Node.js Functions
│ └── apns-proxy/ # HTTP/2 proxy for APNs
├── src/
│ ├── apns/ # APNs client and utilities
│ ├── handlers/ # Business logic handlers
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Helper functions
├── docs/ # Documentation
│ ├── en/ # English documentation
│ │ └── configuration/ # Configuration guides
│ │ └── env.md # Environment variables guide
│ └── zh-cn/ # Chinese documentation
│ └── configuration/ # Configuration guides
│ └── env.md # Environment variables guide
└── AGENTS.md # Development guidelines
Contributions are welcome! Please read Development Overview for development guidelines.
SPDX-License-Identifier: Apache-2.0