refactor: remove unused DISPATCHER interface and related code
This commit is contained in:
@@ -2,12 +2,7 @@ export interface FetcherLike {
|
||||
fetch(request: Request): Promise<Response>;
|
||||
}
|
||||
|
||||
export interface DispatchNamespaceLike {
|
||||
get(name: string, scriptArgs?: Record<string, unknown>, options?: Record<string, unknown>): FetcherLike;
|
||||
}
|
||||
|
||||
export interface Env {
|
||||
AUTH: FetcherLike;
|
||||
DISPATCHER?: DispatchNamespaceLike;
|
||||
DEFAULT_WORKER_NAME: string;
|
||||
}
|
||||
|
||||
17
src/index.ts
17
src/index.ts
@@ -18,21 +18,10 @@ app.all("*", async (c) => {
|
||||
return c.env.AUTH.fetch(c.req.raw);
|
||||
}
|
||||
|
||||
if (!c.env.DISPATCHER) {
|
||||
return c.json({
|
||||
ok: true,
|
||||
routedTo: target.workerName,
|
||||
});
|
||||
}
|
||||
|
||||
const worker = c.env.DISPATCHER.get(target.workerName, {}, {
|
||||
limits: {
|
||||
cpuMs: 20,
|
||||
subRequests: 20,
|
||||
},
|
||||
return c.json({
|
||||
ok: true,
|
||||
routedTo: target.workerName,
|
||||
});
|
||||
|
||||
return worker.fetch(c.req.raw);
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user