diff options
author | 2021-08-05 23:47:36 -0700 | |
---|---|---|
committer | 2021-08-05 23:47:36 -0700 | |
commit | 6e4da63abeb76540bfefa9efcb3d823f8b50eb61 (patch) | |
tree | f4167e1dffeb7c33d912ec3ad5bfab3fdff8e2f6 /src/javascript/jsc/javascript.zig | |
parent | 49929405df6f2bf15a6ea89e33782f237195393e (diff) | |
download | bun-6e4da63abeb76540bfefa9efcb3d823f8b50eb61.tar.gz bun-6e4da63abeb76540bfefa9efcb3d823f8b50eb61.tar.zst bun-6e4da63abeb76540bfefa9efcb3d823f8b50eb61.zip |
router almost works
Former-commit-id: a8b9d27bd0946f9c48bd8e4b5b5c2031aa434f28
Diffstat (limited to 'src/javascript/jsc/javascript.zig')
-rw-r--r-- | src/javascript/jsc/javascript.zig | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index b681a4cee..1de47d46e 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -18,8 +18,8 @@ usingnamespace @import("./webcore/response.zig"); usingnamespace @import("./config.zig"); usingnamespace @import("./bindings/exports.zig"); usingnamespace @import("./bindings/bindings.zig"); - const Runtime = @import("../../runtime.zig"); +const Router = @import("./api/router.zig"); pub const GlobalClasses = [_]type{ Request.Class, @@ -28,6 +28,34 @@ pub const GlobalClasses = [_]type{ EventListenerMixin.addEventListener(VirtualMachine), BuildError.Class, ResolveError.Class, + Wundle.Class, +}; + +pub const Wundle = struct { + top_level_dir: string, + + pub const Class = NewClass( + void, + .{ + .name = "Wundle", + .read_only = true, + .ts = .{ + .module = .{ + .path = "speedy.js/router", + .tsdoc = "Filesystem Router supporting dynamic routes, exact routes, catch-all routes, and optional catch-all routes. Implemented in native code and only available with Speedy.js.", + }, + }, + }, + .{ + .match = .{ + .rfn = Router.match, + .ts = Router.match_type_definition, + }, + }, + .{ + .Route = Router.Instance.GetClass(void){}, + }, + ); }; pub const LazyClasses = [_]type{}; @@ -317,6 +345,7 @@ pub const VirtualMachine = struct { pub fn resolve(res: *ErrorableZigString, global: *JSGlobalObject, specifier: ZigString, source: ZigString) void { var result = ResolveFunctionResult{ .path = "", .result = null }; + _resolve(&result, global, specifier.slice(), source.slice()) catch |err| { // This should almost always just apply to dynamic imports |