@vercube/core 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/index.d.mts +1193 -0
  2. package/dist/index.mjs +175 -174
  3. package/package.json +8 -23
  4. package/dist/Common/App.d.ts +0 -65
  5. package/dist/Common/Container.d.ts +0 -8
  6. package/dist/Common/CreateApp.d.ts +0 -8
  7. package/dist/Config/Config.d.ts +0 -7
  8. package/dist/Config/DefaultConfig.d.ts +0 -6
  9. package/dist/Config/Loader.d.ts +0 -7
  10. package/dist/Decorators/Hooks/Listen.d.ts +0 -9
  11. package/dist/Decorators/Http/Body.d.ts +0 -15
  12. package/dist/Decorators/Http/Connect.d.ts +0 -10
  13. package/dist/Decorators/Http/Controller.d.ts +0 -10
  14. package/dist/Decorators/Http/Delete.d.ts +0 -10
  15. package/dist/Decorators/Http/Get.d.ts +0 -10
  16. package/dist/Decorators/Http/Head.d.ts +0 -10
  17. package/dist/Decorators/Http/Header.d.ts +0 -11
  18. package/dist/Decorators/Http/Headers.d.ts +0 -9
  19. package/dist/Decorators/Http/Middleware.d.ts +0 -27
  20. package/dist/Decorators/Http/MultipartFormData.d.ts +0 -15
  21. package/dist/Decorators/Http/Options.d.ts +0 -10
  22. package/dist/Decorators/Http/Param.d.ts +0 -12
  23. package/dist/Decorators/Http/Patch.d.ts +0 -10
  24. package/dist/Decorators/Http/Post.d.ts +0 -10
  25. package/dist/Decorators/Http/Put.d.ts +0 -10
  26. package/dist/Decorators/Http/QueryParam.d.ts +0 -16
  27. package/dist/Decorators/Http/QueryParams.d.ts +0 -15
  28. package/dist/Decorators/Http/Redirect.d.ts +0 -13
  29. package/dist/Decorators/Http/Request.d.ts +0 -9
  30. package/dist/Decorators/Http/Response.d.ts +0 -9
  31. package/dist/Decorators/Http/Session.d.ts +0 -9
  32. package/dist/Decorators/Http/SetHeader.d.ts +0 -7
  33. package/dist/Decorators/Http/Status.d.ts +0 -11
  34. package/dist/Decorators/Http/Trace.d.ts +0 -10
  35. package/dist/Errors/Http/BadRequestError.d.ts +0 -17
  36. package/dist/Errors/Http/ForbiddenError.d.ts +0 -17
  37. package/dist/Errors/Http/InternalServerError.d.ts +0 -17
  38. package/dist/Errors/Http/MethodNotAllowedError.d.ts +0 -17
  39. package/dist/Errors/Http/NotAcceptableError.d.ts +0 -17
  40. package/dist/Errors/Http/NotFoundError.d.ts +0 -17
  41. package/dist/Errors/Http/UnauthorizedError.d.ts +0 -17
  42. package/dist/Errors/HttpError.d.ts +0 -17
  43. package/dist/Hooks/Router/RouterAfterInitHook.d.ts +0 -1
  44. package/dist/Hooks/Router/RouterBeforeInitHook.d.ts +0 -1
  45. package/dist/Middleware/ValidationMiddleware.d.ts +0 -23
  46. package/dist/Resolvers/Body.d.ts +0 -22
  47. package/dist/Resolvers/Headers.d.ts +0 -14
  48. package/dist/Resolvers/Query.d.ts +0 -14
  49. package/dist/Resolvers/RouterParam.d.ts +0 -13
  50. package/dist/Services/Config/RuntimeConfig.d.ts +0 -22
  51. package/dist/Services/ErrorHandler/DefaultErrorHandlerProvider.d.ts +0 -16
  52. package/dist/Services/ErrorHandler/ErrorHandlerProvider.d.ts +0 -16
  53. package/dist/Services/Hooks/HooksService.d.ts +0 -76
  54. package/dist/Services/HttpServer/HttpServer.d.ts +0 -57
  55. package/dist/Services/Metadata/MetadataResolver.d.ts +0 -42
  56. package/dist/Services/Middleware/BaseMiddleware.d.ts +0 -31
  57. package/dist/Services/Middleware/GlobalMiddlewareRegistry.d.ts +0 -31
  58. package/dist/Services/Plugins/BasePlugin.d.ts +0 -16
  59. package/dist/Services/Plugins/PluginsRegistry.d.ts +0 -26
  60. package/dist/Services/Router/RequestHandler.d.ts +0 -63
  61. package/dist/Services/Router/Router.d.ts +0 -40
  62. package/dist/Services/Router/StaticRequestHandler.d.ts +0 -38
  63. package/dist/Services/Validation/StandardSchemaValidationProvider.d.ts +0 -17
  64. package/dist/Services/Validation/ValidationProvider.d.ts +0 -17
  65. package/dist/Types/CommonTypes.d.ts +0 -7
  66. package/dist/Types/ConfigTypes.d.ts +0 -124
  67. package/dist/Types/HooksTypes.d.ts +0 -17
  68. package/dist/Types/HttpTypes.d.ts +0 -63
  69. package/dist/Types/MetadataTypes.d.ts +0 -56
  70. package/dist/Types/RouterTypes.d.ts +0 -37
  71. package/dist/Types/ValidationTypes.d.ts +0 -6
  72. package/dist/Utils/InternalUtils.d.ts +0 -1
  73. package/dist/Utils/Mine.d.ts +0 -3
  74. package/dist/Utils/Utils.d.ts +0 -22
  75. package/dist/index.cjs +0 -2704
  76. package/dist/index.d.ts +0 -52
@@ -1,23 +0,0 @@
1
- import { BaseMiddleware } from "../Services/Middleware/BaseMiddleware.js";
2
- import type { MiddlewareOptions } from "../Types/CommonTypes.js";
3
- /**
4
- * Middleware for validating request data against a schema
5
- * @class ValidationMiddleware
6
- * @implements {BaseMiddleware}
7
- * @description Validates incoming request data against a provided schema
8
- * @example
9
- * const middleware = new ValidationMiddleware();
10
- * await middleware.use(event, { schema: myValidationSchema });
11
- */
12
- export declare class ValidationMiddleware implements BaseMiddleware {
13
- private gValidationProvider;
14
- /**
15
- * Middleware function that processes the HTTP event
16
- * @param {Request} request - The HTTP request object
17
- * @param {Response} response - The HTTP response object
18
- * @param {MiddlewareOptions} args - Additional arguments for the middleware
19
- * @returns {Promise<void>} - A promise that resolves when the processing is complete
20
- * @throws {BadRequestError} - If validation fails
21
- */
22
- onRequest(request: Request, response: Response, args: MiddlewareOptions): Promise<void>;
23
- }
@@ -1,22 +0,0 @@
1
- import { RouterTypes } from "../Types/RouterTypes.js";
2
- /**
3
- * Resolves and parses the request body from a RouterEvent.
4
- *
5
- * @param {RouterTypes.RouterEvent} event - The router event containing the request to process
6
- * @returns {Promise<unknown>} A promise that resolves to:
7
- * - The parsed JSON body if the request contains valid JSON
8
- * - undefined if the request body is empty
9
- * @throws {BadRequestError} If the request body contains invalid JSON
10
- *
11
- * @example
12
- * const body = await resolveRequestBody(event);
13
- * if (body) {
14
- * // Process the parsed body
15
- * }
16
- *
17
- * @remarks
18
- * - Currently only supports JSON content type
19
- * - Returns undefined for empty request bodies
20
- * - Throws BadRequestError for malformed JSON
21
- */
22
- export declare function resolveRequestBody(event: RouterTypes.RouterEvent): Promise<unknown>;
@@ -1,14 +0,0 @@
1
- import { RouterTypes } from "../Types/RouterTypes.js";
2
- /**
3
- * Retrieves a specific header value from the request
4
- * @param {string} header - The name of the header to retrieve
5
- * @param {RouterTypes.RouterEvent} event - The router event containing the request
6
- * @returns {string | null} The header value if found, null otherwise
7
- */
8
- export declare function getRequestHeader(header: string, event: RouterTypes.RouterEvent): string | null;
9
- /**
10
- * Retrieves all headers from the request
11
- * @param {RouterTypes.RouterEvent} event - The router event containing the request
12
- * @returns {Headers} The complete Headers object from the request
13
- */
14
- export declare function getRequestHeaders(event: RouterTypes.RouterEvent): Headers;
@@ -1,14 +0,0 @@
1
- import { RouterTypes } from "../Types/RouterTypes.js";
2
- /**
3
- * Resolves a single query parameter from the URL of a router event
4
- * @param name - The name of the query parameter to resolve
5
- * @param event - The router event containing the request URL
6
- * @returns The value of the query parameter if found, null otherwise
7
- */
8
- export declare function resolveQueryParam(name: string, event: RouterTypes.RouterEvent): string | null;
9
- /**
10
- * Resolves all query parameters from the URL of a router event
11
- * @param event - The router event containing the request URL
12
- * @returns An object containing all query parameters as key-value pairs
13
- */
14
- export declare function resolveQueryParams(event: RouterTypes.RouterEvent): Record<string, string>;
@@ -1,13 +0,0 @@
1
- import { RouterTypes } from "../Types/RouterTypes.js";
2
- /**
3
- * Resolves a router parameter from the event object
4
- * @param param - The parameter name to resolve from the router event
5
- * @param event - The router event object containing parameters
6
- * @returns The resolved parameter value if it exists, null otherwise
7
- * @example
8
- * ```typescript
9
- * const value = resolveRouterParam('id', routerEvent);
10
- * // Returns the 'id' parameter value from routerEvent.params or null
11
- * ```
12
- */
13
- export declare function resolveRouterParam(param: string, event: RouterTypes.RouterEvent): string | null;
@@ -1,22 +0,0 @@
1
- import { ConfigTypes } from "../../Types/ConfigTypes.js";
2
- /**
3
- * RuntimeConfig class manages the runtime configuration for the Vercube application.
4
- * This class provides a centralized way to access and modify runtime configuration settings.
5
- */
6
- export declare class RuntimeConfig {
7
- /**
8
- * Private field to store the runtime configuration object.
9
- * @private
10
- */
11
- private fRuntimeConfig;
12
- /**
13
- * Gets the current runtime configuration.
14
- * @returns {ConfigTypes.RuntimeConfig} The current runtime configuration object.
15
- */
16
- get runtimeConfig(): ConfigTypes.RuntimeConfig;
17
- /**
18
- * Sets the runtime configuration.
19
- * @param {ConfigTypes.RuntimeConfig} value - The new runtime configuration object to set.
20
- */
21
- set runtimeConfig(value: ConfigTypes.RuntimeConfig);
22
- }
@@ -1,16 +0,0 @@
1
- import { ErrorHandlerProvider } from "./ErrorHandlerProvider.js";
2
- /**
3
- * Default error handler provider
4
- *
5
- * @class DefaultErrorHandlerProvider
6
- */
7
- export declare class DefaultErrorHandlerProvider extends ErrorHandlerProvider {
8
- private gLogger;
9
- /**
10
- * Handles an error that occurred during request processing
11
- *
12
- * @param error - The Error object containing error details
13
- * @returns Promise<Response> | Response - The response to be sent to the client
14
- */
15
- handleError(error: Error): Response;
16
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Abstract class representing an error handler provider
3
- * Provides a common interface for different error handler implementations
4
- *
5
- * @abstract
6
- * @class ErrorHandlerProvider
7
- */
8
- export declare abstract class ErrorHandlerProvider {
9
- /**
10
- * Handles an error that occurred during request processing
11
- *
12
- * @param error - The Error object containing error details
13
- * @returns Promise<Response> | Response - The response to be sent to the client
14
- */
15
- abstract handleError(error: Error): Promise<Response> | Response;
16
- }
@@ -1,76 +0,0 @@
1
- /**
2
- * This module is responsible for managing type-safe hooks observer pattern.
3
- *
4
- * You may create an Hook class that will function as single hook with some data,
5
- * eg:
6
- *
7
- * class ECylinderSelected {
8
- * public cylinder: ICylinder;
9
- * }
10
- *
11
- * And then you can trigger this hook at any time, passing proper payload:
12
- *
13
- * HooksService.trigger(ECylinderSelected, { cylinder: someCylinder });
14
- *
15
- * And you can also listen to this hook:
16
- *
17
- * HooksService.listen(ECylinderSelected, payload => console.log(payload.cylinder));
18
- *
19
- *
20
- * HooksService.on(ECylinderSelected, payload => console.log(payload.cylinder));
21
- *
22
- * Everything 100% typechecked.
23
- */
24
- import type { HooksTypes } from "../../Types/HooksTypes.js";
25
- /**
26
- * This class is responsible for managing events.
27
- */
28
- export declare class HooksService {
29
- private fLastId;
30
- private fHandlers;
31
- /**
32
- * Registers listener for event of particular type. Everytime event is called, the listener
33
- * will be executed.
34
- *
35
- * @param type type of event, simple class
36
- * @param callback callback fired when event is triggered
37
- * @returns unique ID for event listener, can be used to disable this listener
38
- */
39
- on<T>(type: HooksTypes.HookType<T>, callback: HooksTypes.HookCallback<T>): HooksTypes.HookID;
40
- /**
41
- * Waits for single event execution and removes the listener immediately after.
42
- *
43
- * @example
44
- * this.gCart.addItem(product);
45
- * await this.gEvents.waitFor(CartUpdatedEvent);
46
- * console.log('here cart updated event is already called');
47
- *
48
- * @param type type of event to wait for
49
- * @param timeout timeout param in ms - if event is not thrown until this time, it'll reject. passing null disables the timeout
50
- * @returns promise with event data that resolves when event is finally called
51
- */
52
- waitFor<T>(type: HooksTypes.HookType<T>, timeout?: number | null): Promise<T>;
53
- /**
54
- * Removes listener from particular event.
55
- * @param eventId eventId returned from .on() method.
56
- * @throws Error if event was not registered
57
- */
58
- off<T>(eventId: HooksTypes.HookID): void;
59
- /**
60
- * Triggers event, calling all listener callbacks. Will return Promise of number,
61
- * that is resolved when all asynchronous listeners are called.
62
- * @param type type of trigger, simple class
63
- * @param data data which will be passed to listeners, based on event class
64
- * @return number of listeners that were notified
65
- */
66
- trigger<T>(type: HooksTypes.HookType<T>, data?: HooksTypes.HookData<T>): Promise<number>;
67
- /**
68
- * Converts plain object to it's class equivalent.
69
- * It's NOT class-transformer, it performs basic key assigment.
70
- *
71
- * @param ClassConstructor event constructor
72
- * @param data event data to be mapped to constructor
73
- * @return class type of event
74
- */
75
- private objectToClass;
76
- }
@@ -1,57 +0,0 @@
1
- import { ConfigTypes } from "@vercube/core";
2
- /**
3
- * HTTP server implementation for handling incoming web requests
4
- *
5
- * This class is responsible for:
6
- * - Initializing and managing the HTTP server
7
- * - Routing incoming requests to appropriate handlers
8
- * - Processing HTTP responses
9
- */
10
- export declare class HttpServer {
11
- /**
12
- * DI container for resolving dependencies
13
- */
14
- private gContainer;
15
- /**
16
- * Router service for resolving routes
17
- */
18
- private gRouter;
19
- /**
20
- * Handler for processing HTTP requests
21
- */
22
- private gRequestHandler;
23
- /**
24
- * Static server for serving static files
25
- */
26
- private gStaticRequestHandler;
27
- /**
28
- * Underlying server instance
29
- * @private
30
- */
31
- private fServer;
32
- /**
33
- * Initializes the HTTP server and starts listening for requests
34
- *
35
- * @returns {Promise<void>} A promise that resolves when the server is ready
36
- */
37
- initialize(config: ConfigTypes.Config): Promise<void>;
38
- /**
39
- * Listens for incoming requests on the HTTP server
40
- *
41
- * @returns {Promise<void>} A promise that resolves when the server is ready to listen
42
- */
43
- listen(): Promise<void>;
44
- /**
45
- * Processes an incoming HTTP request
46
- *
47
- * This method:
48
- * 1. Resolves the route for the request
49
- * 2. Returns a 404 response if no route is found
50
- * 3. Delegates to the request handler for matched routes
51
- *
52
- * @param {Request} request - The incoming HTTP request
53
- * @returns {Promise<Response>} The HTTP response
54
- * @private
55
- */
56
- handleRequest(request: Request): Promise<Response>;
57
- }
@@ -1,42 +0,0 @@
1
- import type { MetadataTypes } from "../../Types/MetadataTypes.js";
2
- import { RouterTypes } from "../../Types/RouterTypes.js";
3
- /**
4
- * Class responsible for resolving metadata for route handlers.
5
- */
6
- export declare class MetadataResolver {
7
- /**
8
- * Resolves the URL for a given instance and path.
9
- *
10
- * @param {MetadataTypes.ResolveUrlParams} params - The parameters for resolving the URL.
11
- * @return {string} The resolved URL.
12
- */
13
- resolveUrl(params: MetadataTypes.ResolveUrlParams): string;
14
- resolveMethod(ctx: MetadataTypes.Metadata, propertyName: string): MetadataTypes.Method;
15
- /**
16
- * Resolves arguments for a given event.
17
- *
18
- * @param {MetadataTypes.Arg[]} args - The arguments to resolve.
19
- * @param {RouterTypes.RouterEvent} event - The event to resolve arguments for.
20
- * @return {unknown[]} The resolved arguments.
21
- * @public
22
- */
23
- resolveArgs(args: MetadataTypes.Arg[], event: RouterTypes.RouterEvent): Promise<MetadataTypes.Arg[]>;
24
- /**
25
- * Resolves an argument for a given event.
26
- *
27
- * @param {MetadataTypes.Arg} arg - The argument to resolve.
28
- *
29
- * @return {unknown} The resolved argument.
30
- * @private
31
- */
32
- private resolveArg;
33
- /**
34
- * Resolves middleware functions for a given context and property name.
35
- *
36
- * @param {MetadataTypes.Ctx} ctx - The metadata context object
37
- * @param {string} propertyName - The name of the property to resolve middlewares for
38
- * @returns {MetadataTypes.Middleware[]} Array of middleware functions that apply globally or to the specific property
39
- * @public
40
- */
41
- resolveMiddlewares(ctx: MetadataTypes.Metadata, propertyName: string): MetadataTypes.Middleware[];
42
- }
@@ -1,31 +0,0 @@
1
- import type { MaybePromise, MiddlewareOptions } from "../../Types/CommonTypes.js";
2
- /**
3
- * BaseMiddleware class that serves as a base for all middleware implementations.
4
- */
5
- export declare class BaseMiddleware<
6
- T = any,
7
- U = any
8
- > {
9
- /**
10
- * Middleware function that processes the HTTP event.
11
- * This method should be overridden by subclasses to implement specific middleware logic.
12
- * WARNING: This method cannot return a value, it will be ignored.
13
- * Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
14
- *
15
- * @param {Request} request - The HTTP Request to process
16
- * @param {T[]} args - Additional arguments for the middleware.
17
- * @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
18
- */
19
- onRequest?(request: Request, response: Response, args: MiddlewareOptions<T>): MaybePromise<void | Response>;
20
- /**
21
- * Middleware function that processes the response.
22
- * This method should be overridden by subclasses to implement specific middleware logic.
23
- * WARNING: This method cannot return a value, it will be ignored.
24
- * Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
25
- *
26
- * @param {Request} request - The HTTP Request to process
27
- * @param {Response} response - The HTTP Response to process
28
- * @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
29
- */
30
- onResponse?(request: Request, response: Response, payload: U): MaybePromise<void | Response>;
31
- }
@@ -1,31 +0,0 @@
1
- import { MetadataTypes } from "../../Types/MetadataTypes.js";
2
- import { BaseMiddleware } from "./BaseMiddleware.js";
3
- interface GlobalMiddlewareParams<T> extends Omit<MetadataTypes.Middleware<T>, "middleware"> {}
4
- /**
5
- * Manages global middleware registration and retrieval
6
- *
7
- * This class provides functionality to register and retrieve global middleware
8
- * configurations. It allows for adding middleware with specific options and
9
- * retrieving them in a standardized format.
10
- */
11
- export declare class GlobalMiddlewareRegistry {
12
- private fMiddlewares;
13
- /**
14
- * Retrieves all registered global middleware configurations
15
- *
16
- * @returns {MetadataTypes.Middleware[]} An array of middleware configurations
17
- */
18
- get middlewares(): MetadataTypes.Middleware[];
19
- /**
20
- * Registers a global middleware configuration
21
- *
22
- * @param {typeof BaseMiddleware<T, U>} middleware - The middleware class to register
23
- * @param {GlobalMiddlewareParams<T>} opts - The middleware options
24
- * @returns {void}
25
- */
26
- registerGlobalMiddleware<
27
- T = unknown,
28
- U = unknown
29
- >(middleware: typeof BaseMiddleware<T, U>, opts?: GlobalMiddlewareParams<T>): void;
30
- }
31
- export {};
@@ -1,16 +0,0 @@
1
- import type { App } from "../../Common/App.js";
2
- /**
3
- * Represents a Plugin.
4
- */
5
- export declare class BasePlugin<T = unknown> {
6
- /**
7
- * The name of the plugin.
8
- */
9
- name: string;
10
- /**
11
- * Uses the plugin with the given app.
12
- * @param {App} app - The application instance.
13
- * @returns {void | Promise<void>} - A void or a promise that resolves to void.
14
- */
15
- use(app: App, options?: T): void | Promise<void>;
16
- }
@@ -1,26 +0,0 @@
1
- import type { App } from "../../Common/App.js";
2
- import { BasePlugin } from "./BasePlugin.js";
3
- export declare class PluginsRegistry {
4
- private gContainer;
5
- /** Holds the list of plugins */
6
- private fPlugins;
7
- /**
8
- * Registers a plugin.
9
- *
10
- * @param {Plugin} plugin - The plugin to register.
11
- * @param {unknown} options - The options to pass to the plugin.
12
- */
13
- register<T = unknown>(plugin: typeof BasePlugin<T>, options?: T): void;
14
- /**
15
- * Gets the list of registered plugins.
16
- *
17
- * @returns {Plugin[]} The list of registered plugins.
18
- */
19
- get plugins(): BasePlugin[];
20
- /**
21
- * Resolves the plugins.
22
- *
23
- * @param {App} app - The application instance.
24
- */
25
- init(app: App): Promise<void>;
26
- }
@@ -1,63 +0,0 @@
1
- import { RouterTypes } from "../../Types/RouterTypes.js";
2
- /**
3
- * Options for configuring a request handler
4
- * @interface RequestHandlerOptions
5
- */
6
- export interface RequestHandlerOptions {
7
- /** The controller instance that contains the handler method */
8
- instance: any;
9
- /** The name of the method to be used as the handler */
10
- propertyName: string;
11
- }
12
- /**
13
- * Handles HTTP requests by preparing and executing route handlers with their associated middlewares
14
- *
15
- * The RequestHandler is responsible for:
16
- * - Preparing route handlers with their metadata
17
- * - Executing middleware chains (before and after)
18
- * - Processing request/response lifecycle
19
- * - Error handling during request processing
20
- */
21
- export declare class RequestHandler {
22
- /** Resolver for extracting metadata from controller classes and methods */
23
- private gMetadataResolver;
24
- /** DI container for resolving dependencies */
25
- private gContainer;
26
- private gGlobalMiddlewareRegistry;
27
- /**
28
- * Prepares a route handler by resolving its metadata and middlewares
29
- *
30
- * @param {RequestHandlerOptions} params - Configuration options for the handler
31
- * @returns {RouterTypes.RouterHandler} A prepared handler with resolved metadata and middlewares
32
- */
33
- prepareHandler(params: RequestHandlerOptions): RouterTypes.RouterHandler;
34
- /**
35
- * Processes an HTTP request through the middleware chain and route handler
36
- *
37
- * The request handling lifecycle:
38
- * 1. Execute "before" middlewares
39
- * 2. Apply route actions (status codes, redirects, etc.)
40
- * 3. Resolve handler arguments
41
- * 4. Execute the route handler
42
- * 5. Execute "after" middlewares
43
- * 6. Format and return the final response
44
- *
45
- * @param {Request} request - The incoming HTTP request
46
- * @param {RouterTypes.RouteMatched<RouterTypes.RouterHandler>} route - The matched route with handler data
47
- * @returns {Promise<Response>} The HTTP response
48
- */
49
- handleRequest(request: Request, route: RouterTypes.RouteMatched<RouterTypes.RouterHandler>): Promise<Response>;
50
- /**
51
- * Processes and merges response overrides from middlewares or actions
52
- *
53
- * This method handles different response formats:
54
- * - If a full Response object is provided, it's used directly
55
- * - If ResponseInit is provided, it's merged with the base response
56
- *
57
- * @param {Response | ResponseInit} response - The response or response options to apply
58
- * @param {Response} [base] - The base response to extend (optional)
59
- * @returns {Response} The processed response with applied overrides
60
- * @private
61
- */
62
- private processOverrideResponse;
63
- }
@@ -1,40 +0,0 @@
1
- import { RouterTypes } from "../../Types/RouterTypes.js";
2
- /**
3
- * Router service responsible for managing application routes
4
- *
5
- * This class provides functionality to initialize the router,
6
- * register routes, and resolve incoming requests to their
7
- * appropriate handlers.
8
- */
9
- export declare class Router {
10
- /**
11
- * Service for triggering application hooks
12
- */
13
- private gHooksService;
14
- /**
15
- * Internal router context that stores all registered routes
16
- * @private
17
- */
18
- private fRouterContext;
19
- /**
20
- * Registers a new route in the router
21
- *
22
- * @param {RouterTypes.Route} route - The route configuration to add
23
- * @throws {Error} If router is not initialized
24
- */
25
- addRoute(route: RouterTypes.Route): void;
26
- /**
27
- * Initializes the router and triggers related hooks
28
- *
29
- * This method creates a new router context and triggers
30
- * the before and after initialization hooks.
31
- */
32
- initialize(): void;
33
- /**
34
- * Resolves a route based on the HTTP method and path
35
- *
36
- * @param {RouterTypes.RouteFind} route - The route to resolve
37
- * @returns {RouterTypes.RouteMatched<RouterTypes.RouterHandler> | undefined} The matched route or undefined if no match found
38
- */
39
- resolve(route: RouterTypes.RouteFind): RouterTypes.RouteMatched<RouterTypes.RouterHandler> | undefined;
40
- }
@@ -1,38 +0,0 @@
1
- import { ConfigTypes } from "../../Types/ConfigTypes.js";
2
- /**
3
- * Handles serving static files over HTTP
4
- *
5
- * The StaticRequestHandler is responsible for:
6
- * - Serving static files from configured directories
7
- * - Setting appropriate content types and headers
8
- * - Handling caching and ETags
9
- * - Processing GET requests for static assets
10
- */
11
- export declare class StaticRequestHandler {
12
- /**
13
- * The options for the static server
14
- */
15
- private fOptions;
16
- /**
17
- * Initializes the static server with the given options
18
- *
19
- * @param {ConfigTypes.ServerOptions['static']} options - The options for the static server
20
- * @returns {void}
21
- */
22
- initialize(options: ConfigTypes.ServerOptions["static"]): void;
23
- /**
24
- * Handles HTTP requests for static files
25
- *
26
- * @param {Request} request - The incoming HTTP request
27
- * @returns {Promise<void | Response>} A promise that resolves to void or a Response object
28
- */
29
- handleRequest(request: Request): Promise<void | Response>;
30
- /**
31
- * Serves a static file and returns a Response object
32
- *
33
- * @param {string} path - The path to the file to serve
34
- * @param {any} stats - The stats object for the file
35
- * @returns {Promise<Response>} A promise that resolves to a Response object
36
- */
37
- private serveFile;
38
- }
@@ -1,17 +0,0 @@
1
- import { ValidationProvider } from "./ValidationProvider.js";
2
- import { ValidationTypes } from "../../Types/ValidationTypes.js";
3
- /**
4
- * StandardSchemaValidationProvider implements validation using StandardSchema schema validation
5
- * @see https://github.com/standard-schema/standard-schema
6
- * @class
7
- * @implements {ValidationProvider}
8
- */
9
- export declare class StandardSchemaValidationProvider implements ValidationProvider {
10
- /**
11
- * Validates data against a schema
12
- * @param {ValidationTypes.Schema} schema - The schema to validate against
13
- * @param {ValidationTypes.Input} data - The data to validate
14
- * @return {ValidationTypes.Result | Promise<ValidationTypes.Result>} The validation result
15
- */
16
- validate(schema: ValidationTypes.Schema, data: ValidationTypes.Input): ValidationTypes.Result | Promise<ValidationTypes.Result>;
17
- }
@@ -1,17 +0,0 @@
1
- import { ValidationTypes } from "../../Types/ValidationTypes.js";
2
- /**
3
- * Abstract class representing a validation provider
4
- * Provides a common interface for different validation implementations
5
- *
6
- * @abstract
7
- * @class ValidationProvider
8
- */
9
- export declare abstract class ValidationProvider {
10
- /**
11
- * Validates data against a given schema
12
- * @param schema - The validation schema to check against
13
- * @param data - The data to validate
14
- * @returns A validation result object or Promise of validation result
15
- */
16
- abstract validate(schema: ValidationTypes.Schema, data: ValidationTypes.Input): ValidationTypes.Result | Promise<ValidationTypes.Result>;
17
- }
@@ -1,7 +0,0 @@
1
- import { MetadataTypes } from "./MetadataTypes.js";
2
- export { FastResponse } from "srvx";
3
- export type MaybePromise<T> = T | Promise<T>;
4
- export interface MiddlewareOptions<T = any> {
5
- middlewareArgs?: T;
6
- methodArgs?: MetadataTypes.Arg[];
7
- }