Add Web Worker Platform Adapter && Fix module path bug

This commit is contained in:
2022-06-29 20:00:52 +00:00
committed by GitHub
parent bdbb5deda9
commit b3552cb6a2
17 changed files with 4765 additions and 56 deletions

View File

@ -6,15 +6,18 @@ import {
ChainInterrupted,
AllMismatchInterrupted,
responder,
method,
} from "./interface/index";
import { defaultHeaders } from "./interface/response";
import route from "./route";
import { method, methodENUM } from "./interface/method";
import { methodENUM } from "./interface/method";
import {
createPlatformAdapater,
platformAdapaterConstructor,
platformAdapater,
} from "./platform";
} from "./platform/index";
import { platformAdapaterMapping } from "./platform/export";
import { platform } from "./lib";
export class router<K = any, V = any> {
public routes: route[];
@ -208,4 +211,15 @@ export class rootRouter<K = any, V = any> extends router<K, V> {
this.adapater = createPlatformAdapater(adapater, this);
return this;
}
useMappingAdapter(
mapping: { [platform: string]: platformAdapaterConstructor } = platformAdapaterMapping
): this {
if(mapping[platform] == undefined) throw new Error("Platform not found in mapping");
else this.useAdapater(mapping[platform]);
return this;
}
listen(port: number): void {
if (this.adapater == null) throw new Error("No platform adapter set");
this.adapater.listen(port);
}
}