@vercube/core 0.0.1-alpha.15

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 (74) hide show
  1. package/dist/Common/App.d.ts +56 -0
  2. package/dist/Common/Container.d.ts +8 -0
  3. package/dist/Common/CreateApp.d.ts +8 -0
  4. package/dist/Config/Config.d.ts +7 -0
  5. package/dist/Config/DefaultConfig.d.ts +6 -0
  6. package/dist/Config/Loader.d.ts +7 -0
  7. package/dist/Decorators/Hooks/Listen.d.ts +9 -0
  8. package/dist/Decorators/Http/Body.d.ts +15 -0
  9. package/dist/Decorators/Http/Connect.d.ts +10 -0
  10. package/dist/Decorators/Http/Controller.d.ts +10 -0
  11. package/dist/Decorators/Http/Delete.d.ts +10 -0
  12. package/dist/Decorators/Http/Get.d.ts +10 -0
  13. package/dist/Decorators/Http/Head.d.ts +10 -0
  14. package/dist/Decorators/Http/Header.d.ts +11 -0
  15. package/dist/Decorators/Http/Headers.d.ts +9 -0
  16. package/dist/Decorators/Http/Middleware.d.ts +27 -0
  17. package/dist/Decorators/Http/MultipartFormData.d.ts +15 -0
  18. package/dist/Decorators/Http/Options.d.ts +10 -0
  19. package/dist/Decorators/Http/Param.d.ts +12 -0
  20. package/dist/Decorators/Http/Patch.d.ts +10 -0
  21. package/dist/Decorators/Http/Post.d.ts +10 -0
  22. package/dist/Decorators/Http/Put.d.ts +10 -0
  23. package/dist/Decorators/Http/QueryParam.d.ts +16 -0
  24. package/dist/Decorators/Http/QueryParams.d.ts +15 -0
  25. package/dist/Decorators/Http/Redirect.d.ts +13 -0
  26. package/dist/Decorators/Http/Request.d.ts +9 -0
  27. package/dist/Decorators/Http/Response.d.ts +9 -0
  28. package/dist/Decorators/Http/Session.d.ts +9 -0
  29. package/dist/Decorators/Http/SetHeader.d.ts +7 -0
  30. package/dist/Decorators/Http/Status.d.ts +11 -0
  31. package/dist/Decorators/Http/Trace.d.ts +10 -0
  32. package/dist/Errors/Http/BadRequestError.d.ts +17 -0
  33. package/dist/Errors/Http/ForbiddenError.d.ts +17 -0
  34. package/dist/Errors/Http/InternalServerError.d.ts +17 -0
  35. package/dist/Errors/Http/MethodNotAllowedError.d.ts +17 -0
  36. package/dist/Errors/Http/NotAcceptableError.d.ts +17 -0
  37. package/dist/Errors/Http/NotFoundError.d.ts +17 -0
  38. package/dist/Errors/Http/UnauthorizedError.d.ts +17 -0
  39. package/dist/Errors/HttpError.d.ts +17 -0
  40. package/dist/Hooks/Router/RouterAfterInitHook.d.ts +1 -0
  41. package/dist/Hooks/Router/RouterBeforeInitHook.d.ts +1 -0
  42. package/dist/Middleware/ValidationMiddleware.d.ts +23 -0
  43. package/dist/Resolvers/Body.d.ts +22 -0
  44. package/dist/Resolvers/Headers.d.ts +14 -0
  45. package/dist/Resolvers/Query.d.ts +14 -0
  46. package/dist/Resolvers/RouterParam.d.ts +13 -0
  47. package/dist/Services/Config/RuntimeConfig.d.ts +22 -0
  48. package/dist/Services/ErrorHandler/DefaultErrorHandlerProvider.d.ts +16 -0
  49. package/dist/Services/ErrorHandler/ErrorHandlerProvider.d.ts +16 -0
  50. package/dist/Services/Hooks/HooksService.d.ts +76 -0
  51. package/dist/Services/HttpServer/HttpServer.d.ts +51 -0
  52. package/dist/Services/Metadata/MetadataResolver.d.ts +42 -0
  53. package/dist/Services/Middleware/BaseMiddleware.d.ts +31 -0
  54. package/dist/Services/Middleware/GlobalMiddlewareRegistry.d.ts +31 -0
  55. package/dist/Services/Plugins/BasePlugin.d.ts +16 -0
  56. package/dist/Services/Plugins/PluginsRegistry.d.ts +26 -0
  57. package/dist/Services/Router/RequestHandler.d.ts +65 -0
  58. package/dist/Services/Router/Router.d.ts +40 -0
  59. package/dist/Services/Router/StaticRequestHandler.d.ts +38 -0
  60. package/dist/Services/Validation/StandardSchemaValidationProvider.d.ts +17 -0
  61. package/dist/Services/Validation/ValidationProvider.d.ts +17 -0
  62. package/dist/Types/CommonTypes.d.ts +6 -0
  63. package/dist/Types/ConfigTypes.d.ts +120 -0
  64. package/dist/Types/HooksTypes.d.ts +17 -0
  65. package/dist/Types/HttpTypes.d.ts +63 -0
  66. package/dist/Types/MetadataTypes.d.ts +54 -0
  67. package/dist/Types/ValidationTypes.d.ts +6 -0
  68. package/dist/Utils/InternalUtils.d.ts +5 -0
  69. package/dist/Utils/Mine.d.ts +3 -0
  70. package/dist/Utils/Utils.d.ts +22 -0
  71. package/dist/index.cjs +2018 -0
  72. package/dist/index.d.ts +46 -0
  73. package/dist/index.mjs +1944 -0
  74. package/package.json +35 -0
@@ -0,0 +1,14 @@
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>;
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,76 @@
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
+ }
@@ -0,0 +1,51 @@
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
+ * Router service for resolving routes
13
+ */
14
+ private gRouter;
15
+ /**
16
+ * Handler for processing HTTP requests
17
+ */
18
+ private gRequestHandler;
19
+ /**
20
+ * Error handler provider for managing error responses
21
+ */
22
+ private gErrorHandlerProvider;
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
+ * Processes an incoming HTTP request
40
+ *
41
+ * This method:
42
+ * 1. Resolves the route for the request
43
+ * 2. Returns a 404 response if no route is found
44
+ * 3. Delegates to the request handler for matched routes
45
+ *
46
+ * @param {Request} request - The incoming HTTP request
47
+ * @returns {Promise<Response>} The HTTP response
48
+ * @private
49
+ */
50
+ private handleRequest;
51
+ }
@@ -0,0 +1,42 @@
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
+ }
@@ -0,0 +1,31 @@
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
+ }
@@ -0,0 +1,31 @@
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 {};
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,65 @@
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
+ /** Provider for handling errors during request processing */
27
+ private gErrorHandlerProvider;
28
+ private gGlobalMiddlewareRegistry;
29
+ /**
30
+ * Prepares a route handler by resolving its metadata and middlewares
31
+ *
32
+ * @param {RequestHandlerOptions} params - Configuration options for the handler
33
+ * @returns {RouterTypes.RouterHandler} A prepared handler with resolved metadata and middlewares
34
+ */
35
+ prepareHandler(params: RequestHandlerOptions): RouterTypes.RouterHandler;
36
+ /**
37
+ * Processes an HTTP request through the middleware chain and route handler
38
+ *
39
+ * The request handling lifecycle:
40
+ * 1. Execute "before" middlewares
41
+ * 2. Apply route actions (status codes, redirects, etc.)
42
+ * 3. Resolve handler arguments
43
+ * 4. Execute the route handler
44
+ * 5. Execute "after" middlewares
45
+ * 6. Format and return the final response
46
+ *
47
+ * @param {Request} request - The incoming HTTP request
48
+ * @param {RouterTypes.RouteMatched<RouterTypes.RouterHandler>} route - The matched route with handler data
49
+ * @returns {Promise<Response>} The HTTP response
50
+ */
51
+ handleRequest(request: Request, route: RouterTypes.RouteMatched<RouterTypes.RouterHandler>): Promise<Response>;
52
+ /**
53
+ * Processes and merges response overrides from middlewares or actions
54
+ *
55
+ * This method handles different response formats:
56
+ * - If a full Response object is provided, it's used directly
57
+ * - If ResponseInit is provided, it's merged with the base response
58
+ *
59
+ * @param {Response | ResponseInit} response - The response or response options to apply
60
+ * @param {Response} [base] - The base response to extend (optional)
61
+ * @returns {Response} The processed response with applied overrides
62
+ * @private
63
+ */
64
+ private processOverrideResponse;
65
+ }
@@ -0,0 +1,40 @@
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
+ init(): 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
+ }
@@ -0,0 +1,38 @@
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
+ }
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ import { MetadataTypes } from "./MetadataTypes.js";
2
+ export type MaybePromise<T> = T | Promise<T>;
3
+ export interface MiddlewareOptions<T = any> {
4
+ middlewareArgs?: T;
5
+ methodArgs?: MetadataTypes.Arg[];
6
+ }
@@ -0,0 +1,120 @@
1
+ import type { LoggerTypes } from "@vercube/logger";
2
+ /**
3
+ * Namespace containing configuration type definitions for the Vercube framework.
4
+ */
5
+ export declare namespace ConfigTypes {
6
+ interface RuntimeConfig {
7
+ /**
8
+ * Session configuration options.
9
+ */
10
+ session?: {
11
+ /**
12
+ * The secret used to sign the session ID cookie.
13
+ */
14
+ secret?: string
15
+ /**
16
+ * The name of the session ID cookie.
17
+ */
18
+ name?: string
19
+ /**
20
+ * The duration of time for the session to be active.
21
+ */
22
+ duration?: number
23
+ };
24
+ }
25
+ interface ExperimentalOptions {}
26
+ interface BuildOptions {
27
+ /**
28
+ * The root directory for the application.
29
+ */
30
+ root?: string;
31
+ /**
32
+ * The entry point file for the application build.
33
+ */
34
+ entry?: string;
35
+ /**
36
+ * Output configuration for build artifacts.
37
+ */
38
+ output?: {
39
+ /**
40
+ * The main output directory for build artifacts.
41
+ */
42
+ dir?: string
43
+ /**
44
+ * The directory for public/client-side build artifacts.
45
+ */
46
+ publicDir?: string
47
+ };
48
+ /**
49
+ * The bundler to use for the application build.
50
+ */
51
+ bundler?: "rolldown";
52
+ }
53
+ interface ServerOptions {
54
+ /**
55
+ * The runtime environment for the application.
56
+ */
57
+ runtime?: "node" | "bun" | "deno";
58
+ /**
59
+ * The hostname to bind the server to.
60
+ */
61
+ host?: string;
62
+ /**
63
+ * The port number to listen on.
64
+ */
65
+ port?: number;
66
+ /**
67
+ * HTTPS configuration options.
68
+ */
69
+ https?: false | {
70
+ /**
71
+ * Path to the SSL key file.
72
+ */
73
+ key: string
74
+ /**
75
+ * Path to the SSL certificate file.
76
+ */
77
+ cert: string
78
+ };
79
+ /**
80
+ * Static server options
81
+ */
82
+ static: {
83
+ dirs: string[]
84
+ maxAge?: number
85
+ immutable?: boolean
86
+ etag?: boolean
87
+ };
88
+ }
89
+ interface Config {
90
+ /**
91
+ * Flag indicating if the application is running in production mode.
92
+ */
93
+ production?: boolean;
94
+ /**
95
+ * Flag indicating if the application is running in development mode.
96
+ */
97
+ dev?: boolean;
98
+ /**
99
+ * The logging level for the application.
100
+ */
101
+ logLevel?: LoggerTypes.Level;
102
+ /**
103
+ * Server configuration options.
104
+ */
105
+ server?: ServerOptions;
106
+ /**
107
+ * Runtime configuration for the application.
108
+ */
109
+ runtime?: RuntimeConfig;
110
+ /**
111
+ * Experimental features configuration.
112
+ */
113
+ experimental?: ExperimentalOptions;
114
+ /**
115
+ * Build configuration options.
116
+ * This property is only used when using vercube cli.
117
+ */
118
+ build?: BuildOptions;
119
+ }
120
+ }