Create _worker.js

This commit is contained in:
eaglehhha 2025-09-17 14:36:02 +08:00 committed by GitHub
parent 5f1c5945f8
commit 1e3f14bc1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

23
_worker.js Normal file
View File

@ -0,0 +1,23 @@
// /_worker.js
// --- 适配器部分 ---
import { Buffer } from 'node:buffer';
import { connect } from 'node:net';
import { ReadableStream, TransformStream } from 'node:stream/web';
import { fetch } from 'undici';
globalThis.Buffer = Buffer;
globalThis.fetch = fetch;
globalThis.connect = connect;
globalThis.ReadableStream = ReadableStream;
globalThis.TransformStream = TransformStream;
// --- 适配器部分结束 ---
// --- 启动 new-api 应用 ---
import app from './build/app.js';
export default {
async fetch(request, env, ctx) {
return app.fetch(request, env, ctx);
}
};