hack workaround that might not even work, thanks jsr for being unusable
This commit is contained in:
parent
5de39d8573
commit
3b1a969145
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@bearmetal/router",
|
||||
"description": "A simple router for Deno",
|
||||
"version": "0.2.3-a",
|
||||
"version": "0.2.3-b",
|
||||
"stable": true,
|
||||
"files": [
|
||||
"mod.ts",
|
||||
|
@ -25,7 +25,7 @@ function crawl(dir: string, callback: (path: string) => void) {
|
||||
* ```
|
||||
*/
|
||||
export class FileRouter extends Router {
|
||||
constructor(root: string) {
|
||||
constructor(root: string, _import?: (path: string) => Promise<unknown>) {
|
||||
super();
|
||||
crawl(root, async (path) => {
|
||||
let relativePath = path.replace(root, "").replace(/index\/?/, "");
|
||||
@ -36,7 +36,9 @@ export class FileRouter extends Router {
|
||||
: `${Deno.cwd()}/${path.replace(/^.?.?\//, "")}`;
|
||||
}
|
||||
relativePath = relativePath.replace(/\.[tj]s/, "");
|
||||
const handlers = await import("file://" + path);
|
||||
const handlers = _import
|
||||
? await _import(path)
|
||||
: await import("file://" + path);
|
||||
|
||||
if (handlers.default) {
|
||||
handlers.default instanceof Router
|
||||
|
Loading…
x
Reference in New Issue
Block a user