From cfae87ba820532b7150b8ab0c6d678dde06c33d9 Mon Sep 17 00:00:00 2001 From: Dean Srebnik <49134864+load1n9@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:52:15 -0400 Subject: [PATCH] feat(WIP): move to jsr --- LICENSE | 2 +- README.md | 4 ++-- deno.json | 8 +++++++- import_map.json | 5 ----- mod.ts | 16 ++++++++-------- test.ts | 9 +++------ 6 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 import_map.json diff --git a/LICENSE b/LICENSE index 9a2d6c8..07294d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022-2023 the denosaurs team +Copyright (c) 2022-2024 the denosaurs team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e799bba..bf005e5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ the web-standard provide fast and easy route matching. ```ts -import { router } from "https://deno.land/x/rutt/mod.ts"; +import { router } from "jsr:@denosaurs/rutt"; await Deno.serve( router({ @@ -33,4 +33,4 @@ Pull request, issues and feedback are very welcome. Code style is formatted with ### Licence -Copyright 2022-2023, the denosaurs team. All rights reserved. MIT license. +Copyright 2022-2024, the denosaurs team. All rights reserved. MIT license. diff --git a/deno.json b/deno.json index 12a7930..623b871 100644 --- a/deno.json +++ b/deno.json @@ -1,3 +1,9 @@ { - "importMap": "./import_map.json" + "name": "@denosaurs/rutt", + "version": "0.1.0", + "imports": { + "https://deno.land/x/rutt/mod.ts": "./mod.ts" + }, + "exports": "./mod.ts" + } diff --git a/import_map.json b/import_map.json deleted file mode 100644 index b930a65..0000000 --- a/import_map.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "imports": { - "https://deno.land/x/rutt/mod.ts": "./mod.ts" - } -} diff --git a/mod.ts b/mod.ts index 6d18110..ef835db 100644 --- a/mod.ts +++ b/mod.ts @@ -81,10 +81,10 @@ export interface Routes { * {@link MatchHandler} is called. */ // deno-lint-ignore ban-types -export type InternalRoute = { +export interface InternalRoute { pattern: RegExp | URLPattern; methods: Record>; -}; +} /** * An array of {@link InternalRoute internal route} objects which the @@ -293,13 +293,13 @@ export function router( if (methods["any"]) { return await methods["any"](req, ctx, groups); - } else { - return await unknownMethodHandler!( - req, - ctx, - Object.keys(methods) as KnownMethod[], - ); } + + return await unknownMethodHandler!( + req, + ctx, + Object.keys(methods) as KnownMethod[], + ); } } diff --git a/test.ts b/test.ts index 9805ba1..51e4d68 100644 --- a/test.ts +++ b/test.ts @@ -1,10 +1,7 @@ -import { - assert, - assertEquals, - assertIsError, -} from "https://deno.land/std@0.200.0/assert/mod.ts"; -import { router } from "./mod.ts"; +import { assert, assertEquals, assertIsError } from "jsr:@std/assert@1.0.0"; +import { router } from "https://deno.land/x/rutt/mod.ts"; +/// @ts-ignore - Deno doesn't have this type const TEST_CONN_INFO: Deno.ServeHandlerInfo = { remoteAddr: { transport: "tcp",