summary refs log tree commit diff
path: root/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 12:35:46 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 12:35:46 +0200
commit3b4e026eadd1334f3f075774613ed7e8c4203b40 (patch)
tree1d3f04b27ecfb0a5bc3a1fbce1ee7aa77ff95199 /util
parent:bug: fix windows process.getuid (diff)
downloadserver-3b4e026eadd1334f3f075774613ed7e8c4203b40.tar.xz
:bug: fix tsc compiler
Diffstat (limited to 'util')
-rw-r--r--util/src/util/TraverseDirectory.ts10
-rw-r--r--util/src/util/index.ts1
2 files changed, 11 insertions, 0 deletions
diff --git a/util/src/util/TraverseDirectory.ts b/util/src/util/TraverseDirectory.ts
new file mode 100644
index 00000000..275b7dcc
--- /dev/null
+++ b/util/src/util/TraverseDirectory.ts
@@ -0,0 +1,10 @@
+import { Server, traverseDirectory } from "lambert-server";
+
+const DEFAULT_FILTER = /^([^\.].*)(?<!\.d)\.(js)$/;
+
+export function registerRoutes(server: Server, root: string) {
+	return traverseDirectory(
+		{ dirname: root, recursive: true, filter: DEFAULT_FILTER },
+		server.registerRoute.bind(server, root)
+	);
+}
diff --git a/util/src/util/index.ts b/util/src/util/index.ts
index 67583635..c5703468 100644
--- a/util/src/util/index.ts
+++ b/util/src/util/index.ts
@@ -17,3 +17,4 @@ export * from "./Rights";
 export * from "./Snowflake";
 export * from "./String";
 export * from "./Array";
+export * from "./TraverseDirectory";