mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-16 10:53:40 +08:00
Create _worker.js
This commit is contained in:
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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user