mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-26 11:56:38 +08:00
Create _worker.js
This commit is contained in:
parent
5f1c5945f8
commit
1e3f14bc1d
23
_worker.js
Normal file
23
_worker.js
Normal 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);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user