@forklaunch/hyper-express 0.2.9 → 0.3.1

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.
package/lib/index.d.mts CHANGED
@@ -1,15 +1,18 @@
1
+ import * as _forklaunch_hyper_express_fork from '@forklaunch/hyper-express-fork';
2
+ import { Server, MiddlewareHandler, Request, Response, MiddlewareNext, Router as Router$1 } from '@forklaunch/hyper-express-fork';
3
+ export { MiddlewareNext as NextFunction, Request, Response } from '@forklaunch/hyper-express-fork';
4
+ import * as _forklaunch_core_http from '@forklaunch/core/http';
5
+ import { ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
1
6
  import { AnySchemaValidator } from '@forklaunch/validator';
2
- import { ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition, ParamsDictionary, ForklaunchRequest, ForklaunchResponse, ForklaunchStatusResponse, ForklaunchSendableData } from '@forklaunch/core/http';
3
- import { Server, MiddlewareHandler, Router as Router$1, Request as Request$1, Response as Response$1 } from '@forklaunch/hyper-express-fork';
4
7
  import * as uWebsockets from 'uWebSockets.js';
5
- import { ParsedQs } from 'qs';
8
+ export { ParsedQs } from 'qs';
6
9
 
7
10
  /**
8
11
  * Represents an application built on top of Hyper-Express and Forklaunch.
9
12
  *
10
13
  * @template SV - A type that extends AnySchemaValidator.
11
14
  */
12
- declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Server, MiddlewareHandler> {
15
+ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Server, MiddlewareHandler, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext> {
13
16
  /**
14
17
  * Creates an instance of the Application class.
15
18
  *
@@ -28,49 +31,11 @@ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpre
28
31
  listen(unix_path: string, callback?: (listen_socket: uWebsockets.us_listen_socket) => void): Promise<uWebsockets.us_listen_socket>;
29
32
  }
30
33
 
31
- declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`> extends ForklaunchExpressLikeRouter<SV, BasePath, MiddlewareHandler, Router$1> implements ForklaunchRouter<SV> {
34
+ declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`> extends ForklaunchExpressLikeRouter<SV, BasePath, MiddlewareHandler, Router$1, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext> implements ForklaunchRouter<SV> {
32
35
  basePath: BasePath;
33
36
  constructor(basePath: BasePath, schemaValidator: SV);
34
37
  route(path: string): this;
35
- any: TypedMiddlewareDefinition<this, SV>;
36
- }
37
-
38
- /**
39
- * Extends the Forklaunch request interface with properties from Hyper-Express's request interface.
40
- *
41
- * @template SV - A type that extends AnySchemaValidator.
42
- * @template P - A type for request parameters, defaulting to ParamsDictionary.
43
- * @template _ResBody - A type for the response body, defaulting to unknown.
44
- * @template ReqBody - A type for the request body, defaulting to unknown.
45
- * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
46
- * @template LocalsObj - A type for local variables, defaulting to an empty object.
47
- */
48
- interface Request<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>> extends ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, Omit<Request$1<LocalsObj>, 'method' | 'params' | 'query' | 'headers'> {
49
- /** The request body */
50
- body: ReqBody;
51
- /** The request query parameters */
52
- query: ReqQuery;
53
- /** The request parameters */
54
- params: P;
55
- }
56
- /**
57
- * Extends the Forklaunch response interface with properties from Hyper-Express's response interface.
58
- *
59
- * @template ResBody - A type for the response body, defaulting to unknown.
60
- * @template LocalsObj - A type for local variables, defaulting to an empty object.
61
- * @template StatusCode - A type for the status code, defaulting to number.
62
- */
63
- interface Response<ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>> extends ForklaunchResponse<ResBodyMap, ResHeaders, LocalsObj>, Omit<Response$1<LocalsObj>, 'getHeaders' | 'setHeader' | 'headersSent' | 'send' | 'status' | 'statusCode' | 'json' | 'jsonp' | 'end'>, ForklaunchStatusResponse<ForklaunchSendableData> {
64
- /** The body data of the response */
65
- bodyData: unknown;
66
- /** If cors are applied to the response */
67
- cors: boolean;
68
- /** The status code of the response */
69
- _status_code: number;
70
- /** Whether the response is corked */
71
- _cork: boolean;
72
- /** Whether the response is currently corked */
73
- _corked: boolean;
38
+ any: TypedMiddlewareDefinition<this, SV, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext>;
74
39
  }
75
40
 
76
41
  type App<SV extends AnySchemaValidator> = Application<SV>;
@@ -92,4 +57,17 @@ declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidato
92
57
  */
93
58
  declare function forklaunchRouter<SV extends AnySchemaValidator, BasePath extends `/${string}`>(basePath: BasePath, schemaValidator: SV): Router<SV, BasePath>;
94
59
 
95
- export { type App, Application, type Request, type Response, Router, forklaunchExpress, forklaunchRouter };
60
+ declare const handlers: {
61
+ any: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
62
+ delete: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "delete", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "delete", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
63
+ get: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "get", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "get", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
64
+ head: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "head", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "head", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
65
+ middleware: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
66
+ options: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "options", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "options", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
67
+ patch: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "patch", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "patch", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
68
+ post: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "post", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "post", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
69
+ put: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "put", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "put", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
70
+ trace: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "trace", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "trace", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
71
+ };
72
+
73
+ export { type App, Application, Router, forklaunchExpress, forklaunchRouter, handlers };
package/lib/index.d.ts CHANGED
@@ -1,15 +1,18 @@
1
+ import * as _forklaunch_hyper_express_fork from '@forklaunch/hyper-express-fork';
2
+ import { Server, MiddlewareHandler, Request, Response, MiddlewareNext, Router as Router$1 } from '@forklaunch/hyper-express-fork';
3
+ export { MiddlewareNext as NextFunction, Request, Response } from '@forklaunch/hyper-express-fork';
4
+ import * as _forklaunch_core_http from '@forklaunch/core/http';
5
+ import { ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
1
6
  import { AnySchemaValidator } from '@forklaunch/validator';
2
- import { ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition, ParamsDictionary, ForklaunchRequest, ForklaunchResponse, ForklaunchStatusResponse, ForklaunchSendableData } from '@forklaunch/core/http';
3
- import { Server, MiddlewareHandler, Router as Router$1, Request as Request$1, Response as Response$1 } from '@forklaunch/hyper-express-fork';
4
7
  import * as uWebsockets from 'uWebSockets.js';
5
- import { ParsedQs } from 'qs';
8
+ export { ParsedQs } from 'qs';
6
9
 
7
10
  /**
8
11
  * Represents an application built on top of Hyper-Express and Forklaunch.
9
12
  *
10
13
  * @template SV - A type that extends AnySchemaValidator.
11
14
  */
12
- declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Server, MiddlewareHandler> {
15
+ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Server, MiddlewareHandler, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext> {
13
16
  /**
14
17
  * Creates an instance of the Application class.
15
18
  *
@@ -28,49 +31,11 @@ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpre
28
31
  listen(unix_path: string, callback?: (listen_socket: uWebsockets.us_listen_socket) => void): Promise<uWebsockets.us_listen_socket>;
29
32
  }
30
33
 
31
- declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`> extends ForklaunchExpressLikeRouter<SV, BasePath, MiddlewareHandler, Router$1> implements ForklaunchRouter<SV> {
34
+ declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`> extends ForklaunchExpressLikeRouter<SV, BasePath, MiddlewareHandler, Router$1, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext> implements ForklaunchRouter<SV> {
32
35
  basePath: BasePath;
33
36
  constructor(basePath: BasePath, schemaValidator: SV);
34
37
  route(path: string): this;
35
- any: TypedMiddlewareDefinition<this, SV>;
36
- }
37
-
38
- /**
39
- * Extends the Forklaunch request interface with properties from Hyper-Express's request interface.
40
- *
41
- * @template SV - A type that extends AnySchemaValidator.
42
- * @template P - A type for request parameters, defaulting to ParamsDictionary.
43
- * @template _ResBody - A type for the response body, defaulting to unknown.
44
- * @template ReqBody - A type for the request body, defaulting to unknown.
45
- * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
46
- * @template LocalsObj - A type for local variables, defaulting to an empty object.
47
- */
48
- interface Request<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>> extends ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, Omit<Request$1<LocalsObj>, 'method' | 'params' | 'query' | 'headers'> {
49
- /** The request body */
50
- body: ReqBody;
51
- /** The request query parameters */
52
- query: ReqQuery;
53
- /** The request parameters */
54
- params: P;
55
- }
56
- /**
57
- * Extends the Forklaunch response interface with properties from Hyper-Express's response interface.
58
- *
59
- * @template ResBody - A type for the response body, defaulting to unknown.
60
- * @template LocalsObj - A type for local variables, defaulting to an empty object.
61
- * @template StatusCode - A type for the status code, defaulting to number.
62
- */
63
- interface Response<ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>> extends ForklaunchResponse<ResBodyMap, ResHeaders, LocalsObj>, Omit<Response$1<LocalsObj>, 'getHeaders' | 'setHeader' | 'headersSent' | 'send' | 'status' | 'statusCode' | 'json' | 'jsonp' | 'end'>, ForklaunchStatusResponse<ForklaunchSendableData> {
64
- /** The body data of the response */
65
- bodyData: unknown;
66
- /** If cors are applied to the response */
67
- cors: boolean;
68
- /** The status code of the response */
69
- _status_code: number;
70
- /** Whether the response is corked */
71
- _cork: boolean;
72
- /** Whether the response is currently corked */
73
- _corked: boolean;
38
+ any: TypedMiddlewareDefinition<this, SV, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext>;
74
39
  }
75
40
 
76
41
  type App<SV extends AnySchemaValidator> = Application<SV>;
@@ -92,4 +57,17 @@ declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidato
92
57
  */
93
58
  declare function forklaunchRouter<SV extends AnySchemaValidator, BasePath extends `/${string}`>(basePath: BasePath, schemaValidator: SV): Router<SV, BasePath>;
94
59
 
95
- export { type App, Application, type Request, type Response, Router, forklaunchExpress, forklaunchRouter };
60
+ declare const handlers: {
61
+ any: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
62
+ delete: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "delete", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "delete", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
63
+ get: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "get", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "get", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
64
+ head: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "head", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "head", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
65
+ middleware: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
66
+ options: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "options", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "options", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
67
+ patch: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "patch", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "patch", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
68
+ post: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "post", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "post", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
69
+ put: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "put", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "put", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
70
+ trace: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends _forklaunch_core_http.ParamsObject<SV>, ResBodyMap extends _forklaunch_core_http.ResponsesObject<SV>, ReqBody extends _forklaunch_core_http.Body<SV>, ReqQuery extends _forklaunch_core_http.QueryObject<SV>, ReqHeaders extends _forklaunch_core_http.HeadersObject<SV>, ResHeaders extends _forklaunch_core_http.HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: _forklaunch_core_http.ContractDetails<SV, "trace", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, _forklaunch_hyper_express_fork.Request<LocalsObj>>, ...handlers: _forklaunch_core_http.ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "trace", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, _forklaunch_hyper_express_fork.Request<LocalsObj>, _forklaunch_hyper_express_fork.Response<LocalsObj>, _forklaunch_hyper_express_fork.MiddlewareNext>;
71
+ };
72
+
73
+ export { type App, Application, Router, forklaunchExpress, forklaunchRouter, handlers };
package/lib/index.js CHANGED
@@ -31,12 +31,73 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  forklaunchExpress: () => forklaunchExpress,
34
- forklaunchRouter: () => forklaunchRouter
34
+ forklaunchRouter: () => forklaunchRouter,
35
+ handlers: () => handlers
35
36
  });
36
37
  module.exports = __toCommonJS(index_exports);
37
38
 
38
- // src/hyperExpressApplication.ts
39
+ // src/handlers/any.ts
39
40
  var import_http = require("@forklaunch/core/http");
41
+ var any = (schemaValidator, path, contractDetails, ...handlers2) => {
42
+ return (0, import_http.typedHandler)(schemaValidator, path, "middleware", contractDetails, ...handlers2);
43
+ };
44
+
45
+ // src/handlers/delete.ts
46
+ var import_http2 = require("@forklaunch/core/http");
47
+ var delete_ = (schemaValidator, path, contractDetails, ...handlers2) => {
48
+ return (0, import_http2.delete_)(schemaValidator, path, contractDetails, ...handlers2);
49
+ };
50
+
51
+ // src/handlers/get.ts
52
+ var import_http3 = require("@forklaunch/core/http");
53
+ var get = (schemaValidator, path, contractDetails, ...handlers2) => {
54
+ return (0, import_http3.get)(schemaValidator, path, contractDetails, ...handlers2);
55
+ };
56
+
57
+ // src/handlers/head.ts
58
+ var import_http4 = require("@forklaunch/core/http");
59
+ var head = (schemaValidator, path, contractDetails, ...handlers2) => {
60
+ return (0, import_http4.head)(schemaValidator, path, contractDetails, ...handlers2);
61
+ };
62
+
63
+ // src/handlers/middleware.ts
64
+ var import_http5 = require("@forklaunch/core/http");
65
+ var middleware = (schemaValidator, path, contractDetails, ...handlers2) => {
66
+ return (0, import_http5.middleware)(schemaValidator, path, contractDetails, ...handlers2);
67
+ };
68
+
69
+ // src/handlers/options.ts
70
+ var import_http6 = require("@forklaunch/core/http");
71
+ var options = (schemaValidator, path, contractDetails, ...handlers2) => {
72
+ return (0, import_http6.options)(schemaValidator, path, contractDetails, ...handlers2);
73
+ };
74
+
75
+ // src/handlers/patch.ts
76
+ var import_http7 = require("@forklaunch/core/http");
77
+ var patch = (schemaValidator, path, contractDetails, ...handlers2) => {
78
+ return (0, import_http7.patch)(schemaValidator, path, contractDetails, ...handlers2);
79
+ };
80
+
81
+ // src/handlers/post.ts
82
+ var import_http8 = require("@forklaunch/core/http");
83
+ var post = (schemaValidator, path, contractDetails, ...handlers2) => {
84
+ return (0, import_http8.post)(schemaValidator, path, contractDetails, ...handlers2);
85
+ };
86
+
87
+ // src/handlers/put.ts
88
+ var import_http9 = require("@forklaunch/core/http");
89
+ var put = (schemaValidator, path, contractDetails, ...handlers2) => {
90
+ return (0, import_http9.put)(schemaValidator, path, contractDetails, ...handlers2);
91
+ };
92
+
93
+ // src/handlers/trace.ts
94
+ var import_http10 = require("@forklaunch/core/http");
95
+ var trace = (schemaValidator, path, contractDetails, ...handlers2) => {
96
+ return (0, import_http10.trace)(schemaValidator, path, contractDetails, ...handlers2);
97
+ };
98
+
99
+ // src/hyperExpressApplication.ts
100
+ var import_http11 = require("@forklaunch/core/http");
40
101
  var import_hyper_express_fork = require("@forklaunch/hyper-express-fork");
41
102
 
42
103
  // src/middleware/swagger.middleware.ts
@@ -44,14 +105,14 @@ var import_live_directory = __toESM(require("live-directory"));
44
105
  var import_absolute_path = __toESM(require("swagger-ui-dist/absolute-path"));
45
106
  var import_swagger_ui_express = __toESM(require("swagger-ui-express"));
46
107
  function swaggerRedirect(path) {
47
- return (req, res, next) => {
108
+ return function swaggerHosting(req, res, next) {
48
109
  if (req.path === path) {
49
110
  res.redirect(`${path}/`);
50
111
  }
51
112
  return next?.();
52
113
  };
53
114
  }
54
- function swagger(path, document, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
115
+ function swagger(path, document, opts, options2, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
55
116
  const LiveAssets = new import_live_directory.default((0, import_absolute_path.default)(), {
56
117
  filter: {
57
118
  keep: {
@@ -88,7 +149,7 @@ function swagger(path, document, opts, options, customCss, customfavIcon, swagge
88
149
  const ui = import_swagger_ui_express.default.setup(
89
150
  document,
90
151
  opts,
91
- options,
152
+ options2,
92
153
  customCss,
93
154
  customfavIcon,
94
155
  swaggerUrl,
@@ -98,7 +159,7 @@ function swagger(path, document, opts, options, customCss, customfavIcon, swagge
98
159
  }
99
160
 
100
161
  // src/hyperExpressApplication.ts
101
- var Application = class extends import_http.ForklaunchExpressLikeApplication {
162
+ var Application = class extends import_http11.ForklaunchExpressLikeApplication {
102
163
  /**
103
164
  * Creates an instance of the Application class.
104
165
  *
@@ -107,25 +168,44 @@ var Application = class extends import_http.ForklaunchExpressLikeApplication {
107
168
  constructor(schemaValidator) {
108
169
  super(schemaValidator, new import_hyper_express_fork.Server());
109
170
  }
110
- listen(arg0, arg1, arg2) {
171
+ async listen(arg0, arg1, arg2) {
111
172
  if (typeof arg0 === "number") {
112
173
  const port = arg0 || Number(process.env.PORT);
113
- this.internal.set_error_handler((_req, res, err) => {
174
+ this.internal.set_error_handler((req, res, err) => {
114
175
  res.locals.errorMessage = err.message;
115
- console.error(err);
116
176
  res.status(
117
177
  res.statusCode && res.statusCode >= 400 ? res.statusCode : 500
118
- ).send(`Internal server error:
178
+ ).send(
179
+ `Internal server error:
119
180
 
120
- ${err.message}`);
181
+ ${(0, import_http11.isForklaunchRequest)(req) ? req.context.correlationId : "No correlation ID"}`
182
+ );
183
+ (0, import_http11.logger)("error").error(err.stack ?? err.message, {
184
+ [import_http11.ATTR_HTTP_RESPONSE_STATUS_CODE]: res.statusCode ?? 500
185
+ });
121
186
  });
122
- const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`;
187
+ const { apiReference } = await import("@scalar/express-api-reference");
188
+ this.internal.use(
189
+ `/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`,
190
+ apiReference({
191
+ spec: {
192
+ content: (0, import_http11.generateSwaggerDocument)(
193
+ this.schemaValidator,
194
+ port,
195
+ this.routers
196
+ )
197
+ },
198
+ theme: "deepSpace",
199
+ layout: "modern"
200
+ })
201
+ );
202
+ const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${"/swagger"}`;
123
203
  this.internal.use(swaggerPath, swaggerRedirect(swaggerPath));
124
204
  this.internal.get(
125
205
  `${swaggerPath}/*`,
126
206
  swagger(
127
207
  swaggerPath,
128
- (0, import_http.generateSwaggerDocument)(this.schemaValidator, port, this.routers)
208
+ (0, import_http11.generateSwaggerDocument)(this.schemaValidator, port, this.routers)
129
209
  )
130
210
  );
131
211
  if (arg1 && typeof arg1 === "string") {
@@ -142,12 +222,11 @@ ${err.message}`);
142
222
  };
143
223
 
144
224
  // src/hyperExpressRouter.ts
145
- var import_http3 = require("@forklaunch/core/http");
225
+ var import_http13 = require("@forklaunch/core/http");
146
226
  var import_hyper_express_fork2 = require("@forklaunch/hyper-express-fork");
147
227
 
148
228
  // src/middleware/contentParse.middleware.ts
149
229
  async function contentParse(req) {
150
- console.debug("[MIDDLEWARE] contentParse started");
151
230
  switch (req.headers["content-type"] && req.headers["content-type"].split(";")[0]) {
152
231
  case "application/json":
153
232
  req.body = await req.json();
@@ -161,6 +240,24 @@ async function contentParse(req) {
161
240
  case "application/octet-stream":
162
241
  req.body = await req.buffer();
163
242
  break;
243
+ case "multipart/form-data":
244
+ req.body = {};
245
+ await req.multipart(async (field) => {
246
+ if (field.file) {
247
+ const fileBuffer = Buffer.from(
248
+ await field.file.stream.read(),
249
+ field.encoding
250
+ );
251
+ req.body[field.name] = {
252
+ buffer: fileBuffer,
253
+ name: field.file.name ?? field.name,
254
+ type: field.mime_type
255
+ };
256
+ } else {
257
+ req.body[field.name] = field.value;
258
+ }
259
+ });
260
+ break;
164
261
  default:
165
262
  req.body = await req.json();
166
263
  break;
@@ -168,23 +265,30 @@ async function contentParse(req) {
168
265
  }
169
266
 
170
267
  // src/middleware/enrichResponseTransmission.middleware.ts
171
- var import_http2 = require("@forklaunch/core/http");
268
+ var import_http12 = require("@forklaunch/core/http");
172
269
  function enrichResponseTransmission(req, res, next) {
173
- console.debug("[MIDDLEWARE] enrichResponseTransmission");
174
270
  const originalSend = res.send;
175
271
  const originalJson = res.json;
176
272
  const originalSetHeader = res.setHeader;
177
273
  res.json = function(data) {
178
274
  res.bodyData = data;
179
- const result = originalJson.call(this, data);
180
- return result;
275
+ res.statusCode = res._status_code;
276
+ (0, import_http12.enrichExpressLikeSend)(
277
+ this,
278
+ req,
279
+ res,
280
+ originalJson,
281
+ data,
282
+ !res.cors && (res._cork && !res._corked || !res._cork)
283
+ );
284
+ return data;
181
285
  };
182
286
  res.send = function(data) {
183
287
  if (!res.bodyData) {
184
288
  res.bodyData = data;
185
289
  res.statusCode = res._status_code;
186
290
  }
187
- return (0, import_http2.enrichExpressLikeSend)(
291
+ return (0, import_http12.enrichExpressLikeSend)(
188
292
  this,
189
293
  req,
190
294
  res,
@@ -209,7 +313,6 @@ function enrichResponseTransmission(req, res, next) {
209
313
 
210
314
  // src/middleware/polyfillGetHeaders.middleware.ts
211
315
  function polyfillGetHeaders(_req, res, next) {
212
- console.debug("[MIDDLEWARE] polyfillGetHeaders started");
213
316
  res.getHeaders = () => {
214
317
  return res._headers;
215
318
  };
@@ -217,7 +320,7 @@ function polyfillGetHeaders(_req, res, next) {
217
320
  }
218
321
 
219
322
  // src/hyperExpressRouter.ts
220
- var Router = class extends import_http3.ForklaunchExpressLikeRouter {
323
+ var Router = class extends import_http13.ForklaunchExpressLikeRouter {
221
324
  constructor(basePath, schemaValidator) {
222
325
  super(basePath, schemaValidator, new import_hyper_express_fork2.Router());
223
326
  this.basePath = basePath;
@@ -252,8 +355,21 @@ function forklaunchRouter(basePath, schemaValidator) {
252
355
  const router = new Router(basePath, schemaValidator);
253
356
  return router;
254
357
  }
358
+ var handlers = {
359
+ any,
360
+ delete: delete_,
361
+ get,
362
+ head,
363
+ middleware,
364
+ options,
365
+ patch,
366
+ post,
367
+ put,
368
+ trace
369
+ };
255
370
  // Annotate the CommonJS export names for ESM import in node:
256
371
  0 && (module.exports = {
257
372
  forklaunchExpress,
258
- forklaunchRouter
373
+ forklaunchRouter,
374
+ handlers
259
375
  });
package/lib/index.mjs CHANGED
@@ -1,23 +1,108 @@
1
+ // src/handlers/any.ts
2
+ import {
3
+ typedHandler
4
+ } from "@forklaunch/core/http";
5
+ var any = (schemaValidator, path, contractDetails, ...handlers2) => {
6
+ return typedHandler(schemaValidator, path, "middleware", contractDetails, ...handlers2);
7
+ };
8
+
9
+ // src/handlers/delete.ts
10
+ import {
11
+ delete_ as innerDelete
12
+ } from "@forklaunch/core/http";
13
+ var delete_ = (schemaValidator, path, contractDetails, ...handlers2) => {
14
+ return innerDelete(schemaValidator, path, contractDetails, ...handlers2);
15
+ };
16
+
17
+ // src/handlers/get.ts
18
+ import {
19
+ get as innerGet
20
+ } from "@forklaunch/core/http";
21
+ var get = (schemaValidator, path, contractDetails, ...handlers2) => {
22
+ return innerGet(schemaValidator, path, contractDetails, ...handlers2);
23
+ };
24
+
25
+ // src/handlers/head.ts
26
+ import {
27
+ head as innerHead
28
+ } from "@forklaunch/core/http";
29
+ var head = (schemaValidator, path, contractDetails, ...handlers2) => {
30
+ return innerHead(schemaValidator, path, contractDetails, ...handlers2);
31
+ };
32
+
33
+ // src/handlers/middleware.ts
34
+ import {
35
+ middleware as innerMiddleware
36
+ } from "@forklaunch/core/http";
37
+ var middleware = (schemaValidator, path, contractDetails, ...handlers2) => {
38
+ return innerMiddleware(schemaValidator, path, contractDetails, ...handlers2);
39
+ };
40
+
41
+ // src/handlers/options.ts
42
+ import {
43
+ options as innerOptions
44
+ } from "@forklaunch/core/http";
45
+ var options = (schemaValidator, path, contractDetails, ...handlers2) => {
46
+ return innerOptions(schemaValidator, path, contractDetails, ...handlers2);
47
+ };
48
+
49
+ // src/handlers/patch.ts
50
+ import {
51
+ patch as innerPatch
52
+ } from "@forklaunch/core/http";
53
+ var patch = (schemaValidator, path, contractDetails, ...handlers2) => {
54
+ return innerPatch(schemaValidator, path, contractDetails, ...handlers2);
55
+ };
56
+
57
+ // src/handlers/post.ts
58
+ import {
59
+ post as innerPost
60
+ } from "@forklaunch/core/http";
61
+ var post = (schemaValidator, path, contractDetails, ...handlers2) => {
62
+ return innerPost(schemaValidator, path, contractDetails, ...handlers2);
63
+ };
64
+
65
+ // src/handlers/put.ts
66
+ import {
67
+ put as innerPut
68
+ } from "@forklaunch/core/http";
69
+ var put = (schemaValidator, path, contractDetails, ...handlers2) => {
70
+ return innerPut(schemaValidator, path, contractDetails, ...handlers2);
71
+ };
72
+
73
+ // src/handlers/trace.ts
74
+ import {
75
+ trace as innerTrace
76
+ } from "@forklaunch/core/http";
77
+ var trace = (schemaValidator, path, contractDetails, ...handlers2) => {
78
+ return innerTrace(schemaValidator, path, contractDetails, ...handlers2);
79
+ };
80
+
1
81
  // src/hyperExpressApplication.ts
2
82
  import {
83
+ ATTR_HTTP_RESPONSE_STATUS_CODE,
3
84
  ForklaunchExpressLikeApplication,
4
- generateSwaggerDocument
85
+ generateSwaggerDocument,
86
+ isForklaunchRequest,
87
+ logger
5
88
  } from "@forklaunch/core/http";
6
- import { Server } from "@forklaunch/hyper-express-fork";
89
+ import {
90
+ Server
91
+ } from "@forklaunch/hyper-express-fork";
7
92
 
8
93
  // src/middleware/swagger.middleware.ts
9
94
  import LiveDirectory from "live-directory";
10
95
  import getAbsoluteSwaggerFsPath from "swagger-ui-dist/absolute-path";
11
96
  import swaggerUi from "swagger-ui-express";
12
97
  function swaggerRedirect(path) {
13
- return (req, res, next) => {
98
+ return function swaggerHosting(req, res, next) {
14
99
  if (req.path === path) {
15
100
  res.redirect(`${path}/`);
16
101
  }
17
102
  return next?.();
18
103
  };
19
104
  }
20
- function swagger(path, document, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
105
+ function swagger(path, document, opts, options2, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
21
106
  const LiveAssets = new LiveDirectory(getAbsoluteSwaggerFsPath(), {
22
107
  filter: {
23
108
  keep: {
@@ -54,7 +139,7 @@ function swagger(path, document, opts, options, customCss, customfavIcon, swagge
54
139
  const ui = swaggerUi.setup(
55
140
  document,
56
141
  opts,
57
- options,
142
+ options2,
58
143
  customCss,
59
144
  customfavIcon,
60
145
  swaggerUrl,
@@ -73,19 +158,38 @@ var Application = class extends ForklaunchExpressLikeApplication {
73
158
  constructor(schemaValidator) {
74
159
  super(schemaValidator, new Server());
75
160
  }
76
- listen(arg0, arg1, arg2) {
161
+ async listen(arg0, arg1, arg2) {
77
162
  if (typeof arg0 === "number") {
78
163
  const port = arg0 || Number(process.env.PORT);
79
- this.internal.set_error_handler((_req, res, err) => {
164
+ this.internal.set_error_handler((req, res, err) => {
80
165
  res.locals.errorMessage = err.message;
81
- console.error(err);
82
166
  res.status(
83
167
  res.statusCode && res.statusCode >= 400 ? res.statusCode : 500
84
- ).send(`Internal server error:
168
+ ).send(
169
+ `Internal server error:
85
170
 
86
- ${err.message}`);
171
+ ${isForklaunchRequest(req) ? req.context.correlationId : "No correlation ID"}`
172
+ );
173
+ logger("error").error(err.stack ?? err.message, {
174
+ [ATTR_HTTP_RESPONSE_STATUS_CODE]: res.statusCode ?? 500
175
+ });
87
176
  });
88
- const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`;
177
+ const { apiReference } = await import("@scalar/express-api-reference");
178
+ this.internal.use(
179
+ `/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`,
180
+ apiReference({
181
+ spec: {
182
+ content: generateSwaggerDocument(
183
+ this.schemaValidator,
184
+ port,
185
+ this.routers
186
+ )
187
+ },
188
+ theme: "deepSpace",
189
+ layout: "modern"
190
+ })
191
+ );
192
+ const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${"/swagger"}`;
89
193
  this.internal.use(swaggerPath, swaggerRedirect(swaggerPath));
90
194
  this.internal.get(
91
195
  `${swaggerPath}/*`,
@@ -117,7 +221,6 @@ import {
117
221
 
118
222
  // src/middleware/contentParse.middleware.ts
119
223
  async function contentParse(req) {
120
- console.debug("[MIDDLEWARE] contentParse started");
121
224
  switch (req.headers["content-type"] && req.headers["content-type"].split(";")[0]) {
122
225
  case "application/json":
123
226
  req.body = await req.json();
@@ -131,6 +234,24 @@ async function contentParse(req) {
131
234
  case "application/octet-stream":
132
235
  req.body = await req.buffer();
133
236
  break;
237
+ case "multipart/form-data":
238
+ req.body = {};
239
+ await req.multipart(async (field) => {
240
+ if (field.file) {
241
+ const fileBuffer = Buffer.from(
242
+ await field.file.stream.read(),
243
+ field.encoding
244
+ );
245
+ req.body[field.name] = {
246
+ buffer: fileBuffer,
247
+ name: field.file.name ?? field.name,
248
+ type: field.mime_type
249
+ };
250
+ } else {
251
+ req.body[field.name] = field.value;
252
+ }
253
+ });
254
+ break;
134
255
  default:
135
256
  req.body = await req.json();
136
257
  break;
@@ -142,14 +263,21 @@ import {
142
263
  enrichExpressLikeSend
143
264
  } from "@forklaunch/core/http";
144
265
  function enrichResponseTransmission(req, res, next) {
145
- console.debug("[MIDDLEWARE] enrichResponseTransmission");
146
266
  const originalSend = res.send;
147
267
  const originalJson = res.json;
148
268
  const originalSetHeader = res.setHeader;
149
269
  res.json = function(data) {
150
270
  res.bodyData = data;
151
- const result = originalJson.call(this, data);
152
- return result;
271
+ res.statusCode = res._status_code;
272
+ enrichExpressLikeSend(
273
+ this,
274
+ req,
275
+ res,
276
+ originalJson,
277
+ data,
278
+ !res.cors && (res._cork && !res._corked || !res._cork)
279
+ );
280
+ return data;
153
281
  };
154
282
  res.send = function(data) {
155
283
  if (!res.bodyData) {
@@ -181,7 +309,6 @@ function enrichResponseTransmission(req, res, next) {
181
309
 
182
310
  // src/middleware/polyfillGetHeaders.middleware.ts
183
311
  function polyfillGetHeaders(_req, res, next) {
184
- console.debug("[MIDDLEWARE] polyfillGetHeaders started");
185
312
  res.getHeaders = () => {
186
313
  return res._headers;
187
314
  };
@@ -224,7 +351,20 @@ function forklaunchRouter(basePath, schemaValidator) {
224
351
  const router = new Router(basePath, schemaValidator);
225
352
  return router;
226
353
  }
354
+ var handlers = {
355
+ any,
356
+ delete: delete_,
357
+ get,
358
+ head,
359
+ middleware,
360
+ options,
361
+ patch,
362
+ post,
363
+ put,
364
+ trace
365
+ };
227
366
  export {
228
367
  forklaunchExpress,
229
- forklaunchRouter
368
+ forklaunchRouter,
369
+ handlers
230
370
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/hyper-express",
3
- "version": "0.2.9",
3
+ "version": "0.3.1",
4
4
  "description": "Forklaunch framework for hyper-express.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -25,34 +25,35 @@
25
25
  "lib/**"
26
26
  ],
27
27
  "dependencies": {
28
- "@forklaunch/hyper-express-fork": "6.17.3",
28
+ "@forklaunch/hyper-express-fork": "^6.17.30",
29
+ "@scalar/express-api-reference": "^0.4.192",
29
30
  "cors": "^2.8.5",
30
31
  "live-directory": "^3.0.3",
31
32
  "openapi3-ts": "^4.4.0",
32
33
  "qs": "^6.14.0",
33
- "swagger-ui-dist": "^5.18.3",
34
+ "swagger-ui-dist": "^5.20.0",
34
35
  "swagger-ui-express": "^5.0.1",
35
36
  "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.44.0",
36
- "@forklaunch/common": "0.2.1",
37
- "@forklaunch/core": "0.3.6",
38
- "@forklaunch/validator": "0.4.4"
37
+ "@forklaunch/core": "0.5.0",
38
+ "@forklaunch/validator": "0.4.4",
39
+ "@forklaunch/common": "0.2.1"
39
40
  },
40
41
  "devDependencies": {
41
- "@eslint/js": "^9.20.0",
42
+ "@eslint/js": "^9.21.0",
42
43
  "@types/cors": "^2.8.17",
43
44
  "@types/jest": "^29.5.14",
44
45
  "@types/qs": "^6.9.18",
45
46
  "@types/swagger-ui-dist": "^3.30.5",
46
- "@types/swagger-ui-express": "^4.1.7",
47
+ "@types/swagger-ui-express": "^4.1.8",
47
48
  "jest": "^29.7.0",
48
49
  "kill-port-process": "^3.2.1",
49
- "prettier": "^3.5.1",
50
- "ts-jest": "^29.2.5",
50
+ "prettier": "^3.5.3",
51
+ "ts-jest": "^29.2.6",
51
52
  "ts-node": "^10.9.2",
52
- "tsup": "^8.3.6",
53
- "tsx": "^4.19.2",
54
- "typescript": "^5.7.3",
55
- "typescript-eslint": "^8.24.0"
53
+ "tsup": "^8.4.0",
54
+ "tsx": "^4.19.3",
55
+ "typescript": "^5.8.2",
56
+ "typescript-eslint": "^8.26.0"
56
57
  },
57
58
  "scripts": {
58
59
  "build": "tsc --noEmit && tsup index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean",