summary refs log tree commit diff
path: root/util/src
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
commit4722dd5d978e39b203c4ded9c56697467b9f7ece (patch)
treef108c092ad2a41e34d5e715a58a56e9bebef912f /util/src
parent:bug: fix windows process.getuid (diff)
downloadserver-4722dd5d978e39b203c4ded9c56697467b9f7ece.tar.xz
:bug: fix tsc compiler
Diffstat (limited to 'util/src')
-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";