diff --git a/src/HttpKernel.ts b/src/HttpKernel.ts index 25ababb..26aefb8 100644 --- a/src/HttpKernel.ts +++ b/src/HttpKernel.ts @@ -1,4 +1,4 @@ -import { +import type { IContext, IHttpKernel, IHttpKernelConfig, @@ -7,14 +7,14 @@ import { IRouteDefinition, } from './Interfaces/mod.ts'; import { - DeepPartial, - Handler, + type DeepPartial, + type Handler, HTTP_404_NOT_FOUND, HTTP_500_INTERNAL_SERVER_ERROR, HttpStatusTextMap, isHandler, isMiddleware, - Middleware, + type Middleware, } from './Types/mod.ts'; import { RouteBuilder } from './RouteBuilder.ts'; import { createEmptyContext, normalizeError } from './Utils/mod.ts'; diff --git a/src/Interfaces/IContext.ts b/src/Interfaces/IContext.ts index 3b63d33..564fcd3 100644 --- a/src/Interfaces/IContext.ts +++ b/src/Interfaces/IContext.ts @@ -1,4 +1,4 @@ -import { Params, Query, State } from '../Types/mod.ts'; +import type { Params, Query, State } from '../Types/mod.ts'; /** * Represents the complete context for a single HTTP request, diff --git a/src/Interfaces/IHttpErrorHandlers.ts b/src/Interfaces/IHttpErrorHandlers.ts index fb1a9a4..935223d 100644 --- a/src/Interfaces/IHttpErrorHandlers.ts +++ b/src/Interfaces/IHttpErrorHandlers.ts @@ -1,5 +1,5 @@ -import { IContext } from '../Interfaces/mod.ts'; -import { HttpErrorHandler, validHttpErrorCodes } from '../Types/mod.ts'; +import type { IContext } from '../Interfaces/mod.ts'; +import type { HttpErrorHandler, validHttpErrorCodes } from '../Types/mod.ts'; /** * A mapping of HTTP status codes to their corresponding error handlers. diff --git a/src/Interfaces/IHttpKernel.ts b/src/Interfaces/IHttpKernel.ts index 3f28eea..371486a 100644 --- a/src/Interfaces/IHttpKernel.ts +++ b/src/Interfaces/IHttpKernel.ts @@ -1,6 +1,6 @@ -import { IContext } from './IContext.ts'; -import { IRouteBuilder } from './IRouteBuilder.ts'; -import { IRouteDefinition } from './IRouteDefinition.ts'; +import type { IContext } from './IContext.ts'; +import type { IRouteBuilder } from './IRouteBuilder.ts'; +import type { IRouteDefinition } from './IRouteDefinition.ts'; /** * The `IHttpKernel` interface defines the public API for a type-safe, middleware-driven HTTP dispatching system. diff --git a/src/Interfaces/IHttpKernelConfig.ts b/src/Interfaces/IHttpKernelConfig.ts index cd2cdc3..8a91e98 100644 --- a/src/Interfaces/IHttpKernelConfig.ts +++ b/src/Interfaces/IHttpKernelConfig.ts @@ -1,7 +1,7 @@ -import { ResponseDecorator } from '../Types/mod.ts'; -import { IContext } from './IContext.ts'; -import { IHttpErrorHandlers } from './IHttpErrorHandlers.ts'; -import { IRouteBuilderFactory } from './IRouteBuilder.ts'; +import type { ResponseDecorator } from '../Types/mod.ts'; +import type { IContext } from './IContext.ts'; +import type { IHttpErrorHandlers } from './IHttpErrorHandlers.ts'; +import type { IRouteBuilderFactory } from './IRouteBuilder.ts'; export interface IHttpKernelConfig { decorateResponse: ResponseDecorator; diff --git a/src/Interfaces/IInternalRoute.ts b/src/Interfaces/IInternalRoute.ts index 7565a4a..7fc7d66 100644 --- a/src/Interfaces/IInternalRoute.ts +++ b/src/Interfaces/IInternalRoute.ts @@ -1,5 +1,5 @@ -import { Handler, HttpMethod, Middleware } from '../Types/mod.ts'; -import { IContext, IRouteMatcher } from './mod.ts'; +import type { Handler, HttpMethod, Middleware } from '../Types/mod.ts'; +import type { IContext, IRouteMatcher } from './mod.ts'; /** * Represents an internally registered route within the HttpKernel. diff --git a/src/Interfaces/IRouteBuilder.ts b/src/Interfaces/IRouteBuilder.ts index 24ee1a4..9737ae0 100644 --- a/src/Interfaces/IRouteBuilder.ts +++ b/src/Interfaces/IRouteBuilder.ts @@ -1,7 +1,7 @@ -import { Handler, Middleware } from '../Types/mod.ts'; -import { IInternalRoute } from './IInternalRoute.ts'; -import { IRouteDefinition } from './IRouteDefinition.ts'; -import { IContext } from './mod.ts'; +import type { Handler, Middleware } from '../Types/mod.ts'; +import type { IInternalRoute } from './IInternalRoute.ts'; +import type { IRouteDefinition } from './IRouteDefinition.ts'; +import type { IContext } from './mod.ts'; export interface IRouteBuilderFactory { new ( diff --git a/src/Interfaces/IRouteDefinition.ts b/src/Interfaces/IRouteDefinition.ts index 43146cc..c2c41ff 100644 --- a/src/Interfaces/IRouteDefinition.ts +++ b/src/Interfaces/IRouteDefinition.ts @@ -1,5 +1,5 @@ -import { HttpMethod, isHttpMethod } from '../Types/mod.ts'; -import { IRouteMatcher } from './IRouteMatcher.ts'; +import { type HttpMethod, isHttpMethod } from '../Types/mod.ts'; +import type { IRouteMatcher } from './IRouteMatcher.ts'; /** * Defines a static route using a path pattern with optional parameters. diff --git a/src/Interfaces/IRouteMatch.ts b/src/Interfaces/IRouteMatch.ts index 06e1d7c..9ed1067 100644 --- a/src/Interfaces/IRouteMatch.ts +++ b/src/Interfaces/IRouteMatch.ts @@ -1,4 +1,4 @@ -import { Params, Query } from '../Types/mod.ts'; +import type { Params, Query } from '../Types/mod.ts'; export interface IRouteMatch { params?: Params; diff --git a/src/Interfaces/IRouteMatcher.ts b/src/Interfaces/IRouteMatcher.ts index 1cbd3a3..1dee7eb 100644 --- a/src/Interfaces/IRouteMatcher.ts +++ b/src/Interfaces/IRouteMatcher.ts @@ -1,6 +1,5 @@ -import { Params } from '../Types/mod.ts'; -import { IRouteDefinition } from './IRouteDefinition.ts'; -import { IRouteMatch } from './IRouteMatch.ts'; +import type { IRouteDefinition } from './IRouteDefinition.ts'; +import type { IRouteMatch } from './IRouteMatch.ts'; /** * Defines a route matcher function that evaluates whether a route applies to a given request. diff --git a/src/Interfaces/__tests__/routeDefinitionGuards.test.ts b/src/Interfaces/__tests__/routeDefinitionGuards.test.ts index c00b7c6..98cc0a0 100644 --- a/src/Interfaces/__tests__/routeDefinitionGuards.test.ts +++ b/src/Interfaces/__tests__/routeDefinitionGuards.test.ts @@ -1,6 +1,6 @@ import { assertEquals } from 'https://deno.land/std@0.204.0/assert/mod.ts'; import { - IRouteDefinition, + type IRouteDefinition, isDynamicRouteDefinition, isStaticRouteDefinition, } from '../IRouteDefinition.ts'; diff --git a/src/RouteBuilder.ts b/src/RouteBuilder.ts index c6e6e8d..d09a11a 100644 --- a/src/RouteBuilder.ts +++ b/src/RouteBuilder.ts @@ -1,6 +1,10 @@ -import { IRouteMatcherFactory } from './Interfaces/IRouteMatcher.ts'; -import { IContext, IRouteBuilder, IRouteDefinition } from './Interfaces/mod.ts'; -import { Handler, Middleware, RegisterRoute } from './Types/mod.ts'; +import type { IRouteMatcherFactory } from './Interfaces/IRouteMatcher.ts'; +import type { + IContext, + IRouteBuilder, + IRouteDefinition, +} from './Interfaces/mod.ts'; +import type { Handler, Middleware, RegisterRoute } from './Types/mod.ts'; import { createRouteMatcher } from './Utils/createRouteMatcher.ts'; /** diff --git a/src/Types/Handler.ts b/src/Types/Handler.ts index 0a67a6e..11f28f8 100644 --- a/src/Types/Handler.ts +++ b/src/Types/Handler.ts @@ -1,4 +1,4 @@ -import { IContext } from '../Interfaces/mod.ts'; +import type { IContext } from '../Interfaces/mod.ts'; /** * Represents a final request handler responsible for producing an HTTP response. diff --git a/src/Types/HttpErrorHandler.ts b/src/Types/HttpErrorHandler.ts index 5a7667f..8c62fae 100644 --- a/src/Types/HttpErrorHandler.ts +++ b/src/Types/HttpErrorHandler.ts @@ -1,4 +1,4 @@ -import { IContext } from '../Interfaces/mod.ts'; +import type { IContext } from '../Interfaces/mod.ts'; /** * Defines a handler function for errors that occur during the execution diff --git a/src/Types/Middleware.ts b/src/Types/Middleware.ts index 0001af4..08e13bb 100644 --- a/src/Types/Middleware.ts +++ b/src/Types/Middleware.ts @@ -1,4 +1,4 @@ -import { IContext } from '../Interfaces/IContext.ts'; +import type { IContext } from '../Interfaces/IContext.ts'; /** * Represents a middleware function in the HTTP request pipeline. diff --git a/src/Types/RegisterRoute.ts b/src/Types/RegisterRoute.ts index 21af1b3..c661e93 100644 --- a/src/Types/RegisterRoute.ts +++ b/src/Types/RegisterRoute.ts @@ -1,5 +1,5 @@ -import { IContext } from '../Interfaces/IContext.ts'; -import { IInternalRoute } from '../Interfaces/mod.ts'; +import type { IContext } from '../Interfaces/IContext.ts'; +import type { IInternalRoute } from '../Interfaces/mod.ts'; /** * A type alias for the internal route registration function used by the `HttpKernel`. diff --git a/src/Types/ResponseDecorator.ts b/src/Types/ResponseDecorator.ts index a027f4f..4291a6d 100644 --- a/src/Types/ResponseDecorator.ts +++ b/src/Types/ResponseDecorator.ts @@ -1,4 +1,4 @@ -import { IContext } from '../Interfaces/mod.ts'; +import type { IContext } from '../Interfaces/mod.ts'; /** * A function that modifies or enriches an outgoing HTTP response before it is returned to the client. diff --git a/src/Utils/__tests__/createEmptyContext.test.ts b/src/Utils/__tests__/createEmptyContext.test.ts index fe58fb2..2b3acfe 100644 --- a/src/Utils/__tests__/createEmptyContext.test.ts +++ b/src/Utils/__tests__/createEmptyContext.test.ts @@ -1,6 +1,6 @@ import { assertEquals } from 'https://deno.land/std/assert/mod.ts'; import { createEmptyContext } from '../createEmptyContext.ts'; -import { IContext } from '../../Interfaces/mod.ts'; +import type { IContext } from '../../Interfaces/mod.ts'; Deno.test('createEmptyContext: returns default-initialized context', () => { const request = new Request('http://localhost'); diff --git a/src/Utils/__tests__/createRouteMatcher.test.ts b/src/Utils/__tests__/createRouteMatcher.test.ts index 13a1eb7..8338014 100644 --- a/src/Utils/__tests__/createRouteMatcher.test.ts +++ b/src/Utils/__tests__/createRouteMatcher.test.ts @@ -3,7 +3,7 @@ import { assertEquals, assertStrictEquals, } from 'https://deno.land/std/assert/mod.ts'; -import { IRouteDefinition } from '../../Interfaces/mod.ts'; +import type { IRouteDefinition } from '../../Interfaces/mod.ts'; import { createRouteMatcher } from '../../mod.ts'; // Dummy request diff --git a/src/Utils/createEmptyContext.ts b/src/Utils/createEmptyContext.ts index e5d115a..18113dd 100644 --- a/src/Utils/createEmptyContext.ts +++ b/src/Utils/createEmptyContext.ts @@ -1,5 +1,5 @@ -import { IContext } from '../Interfaces/mod.ts'; -import { Params, Query, State } from '../Types/mod.ts'; +import type { IContext } from '../Interfaces/mod.ts'; +import type { Params, Query, State } from '../Types/mod.ts'; /** * Creates an empty request context suitable for fallback handlers (e.g., 404 or 500 errors). diff --git a/src/Utils/createRouteMatcher.ts b/src/Utils/createRouteMatcher.ts index ea3775f..dce9185 100644 --- a/src/Utils/createRouteMatcher.ts +++ b/src/Utils/createRouteMatcher.ts @@ -1,12 +1,12 @@ // createRouteMatcher.ts import { - IRouteDefinition, - IRouteMatch, - IRouteMatcher, + type IRouteDefinition, + type IRouteMatch, + type IRouteMatcher, isDynamicRouteDefinition, } from '../Interfaces/mod.ts'; -import { Params, Query } from '../Types/mod.ts'; +import type { Params, Query } from '../Types/mod.ts'; /** * Transforms a route definition into a matcher using Deno's URLPattern API. diff --git a/src/Utils/normalizeError.ts b/src/Utils/normalizeError.ts index e058ee7..71fac86 100644 --- a/src/Utils/normalizeError.ts +++ b/src/Utils/normalizeError.ts @@ -22,11 +22,9 @@ * ``` */ export function normalizeError(unknownError: unknown): Error { - return unknownError instanceof Error - ? unknownError - : new Error( - typeof unknownError === 'string' - ? unknownError - : JSON.stringify(unknownError), - ); + return unknownError instanceof Error ? unknownError : new Error( + typeof unknownError === 'string' + ? unknownError + : JSON.stringify(unknownError), + ); } diff --git a/src/__tests__/HttpKernel.test.ts b/src/__tests__/HttpKernel.test.ts index 214ce51..a9c32c3 100644 --- a/src/__tests__/HttpKernel.test.ts +++ b/src/__tests__/HttpKernel.test.ts @@ -1,6 +1,6 @@ import { assertEquals } from 'https://deno.land/std@0.204.0/assert/mod.ts'; import { HttpKernel } from '../HttpKernel.ts'; -import { IRouteDefinition } from '../Interfaces/mod.ts'; +import type { IRouteDefinition } from '../Interfaces/mod.ts'; Deno.test('HttpKernel: matches static route and executes handler', async () => { const kernel = new HttpKernel(); diff --git a/src/__tests__/RouteBuilder.test.ts b/src/__tests__/RouteBuilder.test.ts index 1e9cc77..afb5acd 100644 --- a/src/__tests__/RouteBuilder.test.ts +++ b/src/__tests__/RouteBuilder.test.ts @@ -4,9 +4,9 @@ import { assertNotEquals, assertThrows, } from 'https://deno.land/std@0.204.0/assert/mod.ts'; -import { IInternalRoute, IRouteDefinition } from '../Interfaces/mod.ts'; +import type { IInternalRoute, IRouteDefinition } from '../Interfaces/mod.ts'; import { RouteBuilder } from '../mod.ts'; -import { Handler, Middleware } from '../Types/mod.ts'; +import type { Handler, Middleware } from '../Types/mod.ts'; // Dummy objects // deno-lint-ignore require-await @@ -91,7 +91,7 @@ Deno.test('handle: works with no middleware', async () => { Deno.test('handle: uses custom matcher factory', () => { let called = false; - const factory = (def: IRouteDefinition) => { + const factory = (_def: IRouteDefinition) => { called = true; return dummyMatcher; };