@forklaunch/express 1.2.31 → 1.2.33
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.ts +48 -2062
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -2
- package/lib/index.mjs +9 -2
- package/lib/src/cluster/bun.cluster.d.ts +4 -0
- package/lib/src/cluster/bun.cluster.d.ts.map +1 -0
- package/lib/src/cluster/bun.serve.shim.d.ts +55 -0
- package/lib/src/cluster/bun.serve.shim.d.ts.map +1 -0
- package/lib/src/cluster/bun.socket.shim.d.ts +81 -0
- package/lib/src/cluster/bun.socket.shim.d.ts.map +1 -0
- package/lib/src/cluster/node.cluster.d.ts +4 -0
- package/lib/src/cluster/node.cluster.d.ts.map +1 -0
- package/lib/src/expressApplication.d.ts +59 -0
- package/lib/src/expressApplication.d.ts.map +1 -0
- package/lib/src/expressRouter.d.ts +51 -0
- package/lib/src/expressRouter.d.ts.map +1 -0
- package/lib/src/handlers/checkout.d.ts +40 -0
- package/lib/src/handlers/checkout.d.ts.map +1 -0
- package/lib/src/handlers/copy.d.ts +89 -0
- package/lib/src/handlers/copy.d.ts.map +1 -0
- package/lib/src/handlers/delete.d.ts +59 -0
- package/lib/src/handlers/delete.d.ts.map +1 -0
- package/lib/src/handlers/get.d.ts +46 -0
- package/lib/src/handlers/get.d.ts.map +1 -0
- package/lib/src/handlers/head.d.ts +69 -0
- package/lib/src/handlers/head.d.ts.map +1 -0
- package/lib/src/handlers/link.d.ts +91 -0
- package/lib/src/handlers/link.d.ts.map +1 -0
- package/lib/src/handlers/lock.d.ts +90 -0
- package/lib/src/handlers/lock.d.ts.map +1 -0
- package/lib/src/handlers/m-search.d.ts +85 -0
- package/lib/src/handlers/m-search.d.ts.map +1 -0
- package/lib/src/handlers/merge.d.ts +101 -0
- package/lib/src/handlers/merge.d.ts.map +1 -0
- package/lib/src/handlers/middleware.d.ts +67 -0
- package/lib/src/handlers/middleware.d.ts.map +1 -0
- package/lib/src/handlers/mkcactivity.d.ts +76 -0
- package/lib/src/handlers/mkcactivity.d.ts.map +1 -0
- package/lib/src/handlers/mkcol.d.ts +76 -0
- package/lib/src/handlers/mkcol.d.ts.map +1 -0
- package/lib/src/handlers/move.d.ts +78 -0
- package/lib/src/handlers/move.d.ts.map +1 -0
- package/lib/src/handlers/notify.d.ts +75 -0
- package/lib/src/handlers/notify.d.ts.map +1 -0
- package/lib/src/handlers/options.d.ts +67 -0
- package/lib/src/handlers/options.d.ts.map +1 -0
- package/lib/src/handlers/patch.d.ts +86 -0
- package/lib/src/handlers/patch.d.ts.map +1 -0
- package/lib/src/handlers/post.d.ts +50 -0
- package/lib/src/handlers/post.d.ts.map +1 -0
- package/lib/src/handlers/propfind.d.ts +84 -0
- package/lib/src/handlers/propfind.d.ts.map +1 -0
- package/lib/src/handlers/proppatch.d.ts +84 -0
- package/lib/src/handlers/proppatch.d.ts.map +1 -0
- package/lib/src/handlers/purge.d.ts +63 -0
- package/lib/src/handlers/purge.d.ts.map +1 -0
- package/lib/src/handlers/put.d.ts +73 -0
- package/lib/src/handlers/put.d.ts.map +1 -0
- package/lib/src/handlers/report.d.ts +70 -0
- package/lib/src/handlers/report.d.ts.map +1 -0
- package/lib/src/handlers/search.d.ts +83 -0
- package/lib/src/handlers/search.d.ts.map +1 -0
- package/lib/src/handlers/subscribe.d.ts +75 -0
- package/lib/src/handlers/subscribe.d.ts.map +1 -0
- package/lib/src/handlers/trace.d.ts +59 -0
- package/lib/src/handlers/trace.d.ts.map +1 -0
- package/lib/src/handlers/unlink.d.ts +70 -0
- package/lib/src/handlers/unlink.d.ts.map +1 -0
- package/lib/src/handlers/unlock.d.ts +70 -0
- package/lib/src/handlers/unlock.d.ts.map +1 -0
- package/lib/src/handlers/unsubscribe.d.ts +71 -0
- package/lib/src/handlers/unsubscribe.d.ts.map +1 -0
- package/lib/src/middleware/async.middleware.d.ts +16 -0
- package/lib/src/middleware/async.middleware.d.ts.map +1 -0
- package/lib/src/middleware/content.parse.middleware.d.ts +13 -0
- package/lib/src/middleware/content.parse.middleware.d.ts.map +1 -0
- package/lib/src/middleware/enrichResponseTransmission.middleware.d.ts +27 -0
- package/lib/src/middleware/enrichResponseTransmission.middleware.d.ts.map +1 -0
- package/lib/src/types/export.types.d.ts +9 -0
- package/lib/src/types/export.types.d.ts.map +1 -0
- package/lib/src/types/express.types.d.ts +84 -0
- package/lib/src/types/express.types.d.ts.map +1 -0
- package/lib/src/types/expressOptions.types.d.ts +17 -0
- package/lib/src/types/expressOptions.types.d.ts.map +1 -0
- package/package.json +35 -34
- package/LICENSE +0 -21
- package/lib/index.d.mts +0 -2112
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Body, ContractDetails, ExpressLikeSchemaHandler, HeadersObject, ParamsObject, QueryObject, ResolvedSessionObject, ResponsesObject, SchemaAuthMethods, SessionObject, VersionSchema } from '@forklaunch/core/http';
|
|
2
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
3
|
+
import { NextFunction, Request, Response } from 'express';
|
|
4
|
+
import express from 'express-serve-static-core';
|
|
5
|
+
import { ParsedQs } from 'qs';
|
|
6
|
+
/**
|
|
7
|
+
* Creates an UNSUBSCRIBE route handler with schema validation and type safety.
|
|
8
|
+
*
|
|
9
|
+
* @template SV - The schema validator type
|
|
10
|
+
* @template Name - The name of the route
|
|
11
|
+
* @template Path - The route path type
|
|
12
|
+
* @template P - The path parameters type
|
|
13
|
+
* @template ResBodyMap - The response body map type
|
|
14
|
+
* @template ReqBody - The request body type
|
|
15
|
+
* @template ReqQuery - The request query parameters type
|
|
16
|
+
* @template ReqHeaders - The request headers type
|
|
17
|
+
* @template ResHeaders - The response headers type
|
|
18
|
+
* @template LocalsObj - The locals object type
|
|
19
|
+
* @template Auth - The authentication methods base type
|
|
20
|
+
*
|
|
21
|
+
* @param {SV} schemaValidator - The schema validator instance
|
|
22
|
+
* @param {Path} path - The route path
|
|
23
|
+
* @param {ContractDetails<SV, 'middleware', Name, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request, Auth>} contractDetails - The contract details for the route
|
|
24
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Auth>} handlers - The route handlers
|
|
25
|
+
*
|
|
26
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* unsubscribe(
|
|
31
|
+
* schemaValidator,
|
|
32
|
+
* '/subscriptions/:id',
|
|
33
|
+
* {
|
|
34
|
+
* summary: 'Unsubscribe from updates',
|
|
35
|
+
* description: 'Removes a subscription to resource updates',
|
|
36
|
+
* tags: ['subscriptions'],
|
|
37
|
+
* pathParams: {
|
|
38
|
+
* id: { type: 'string' }
|
|
39
|
+
* },
|
|
40
|
+
* responses: {
|
|
41
|
+
* 200: {
|
|
42
|
+
* description: 'Subscription removed successfully',
|
|
43
|
+
* content: {
|
|
44
|
+
* 'application/json': {
|
|
45
|
+
* schema: {
|
|
46
|
+
* type: 'object',
|
|
47
|
+
* properties: {
|
|
48
|
+
* id: { type: 'string' },
|
|
49
|
+
* status: { type: 'string' }
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* },
|
|
57
|
+
* async (req, res) => {
|
|
58
|
+
* const { id } = req.params;
|
|
59
|
+
* // Unsubscribe logic
|
|
60
|
+
* res.json({ id, status: 'unsubscribed' });
|
|
61
|
+
* }
|
|
62
|
+
* );
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare const unsubscribe: <SV extends AnySchemaValidator, Name extends string, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>, const VersionedApi extends VersionSchema<SV, 'middleware'>, const Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, Request>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, VersionedApi, Request, Auth>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, ResolvedSessionObject<SV, Auth, SessionObject<SV>>, Request, Response, NextFunction>[]) => {
|
|
66
|
+
_typedHandler: true;
|
|
67
|
+
_path: Path;
|
|
68
|
+
contractDetails: import("@forklaunch/core/http").MiddlewareContractDetails<SV, Name, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, VersionedApi, Request<express.ParamsDictionary, any, any, ParsedQs, Record<string, any>>, Auth>;
|
|
69
|
+
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, ResolvedSessionObject<SV, Auth, SessionObject<SV>>, Request<express.ParamsDictionary, any, any, ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=unsubscribe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsubscribe.d.ts","sourceRoot":"","sources":["../../../src/handlers/unsubscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,eAAe,EACf,wBAAwB,EACxB,aAAa,EAEb,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,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,QAAQ,EACR,YAAY,CACb,EAAE;;;;;CAmBJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an asynchronous middleware function to handle errors and pass them to the next middleware.
|
|
4
|
+
*
|
|
5
|
+
* @template SV - A type that extends AnySchemaValidator.
|
|
6
|
+
* @template P - A type for request parameters, defaulting to ParamsDictionary.
|
|
7
|
+
* @template ResBodyMap - A type for the response body, defaulting to unknown.
|
|
8
|
+
* @template ReqBody - A type for the request body, defaulting to unknown.
|
|
9
|
+
* @template ReqQuery - A type for the request query, defaulting to ParsedQs.
|
|
10
|
+
* @template LocalsObj - A type for local variables, defaulting to an empty object.
|
|
11
|
+
* @template StatusCode - A type for the status code, defaulting to number.
|
|
12
|
+
* @param {RequestHandler} fn - The asynchronous middleware function to wrap.
|
|
13
|
+
* @returns {RequestHandler} - The wrapped middleware function.
|
|
14
|
+
*/
|
|
15
|
+
export declare function asyncMiddleware(fn: RequestHandler): RequestHandler;
|
|
16
|
+
//# sourceMappingURL=async.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/async.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CAKlE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { Options, OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
|
|
3
|
+
import { BusboyConfig } from 'busboy';
|
|
4
|
+
import { NextFunction, Request, Response } from 'express';
|
|
5
|
+
declare function contentParse<SV extends AnySchemaValidator>(options?: {
|
|
6
|
+
busboy?: BusboyConfig;
|
|
7
|
+
text?: OptionsText;
|
|
8
|
+
json?: OptionsJson;
|
|
9
|
+
urlencoded?: OptionsUrlencoded;
|
|
10
|
+
raw?: Options;
|
|
11
|
+
}): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
12
|
+
export { contentParse };
|
|
13
|
+
//# sourceMappingURL=content.parse.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.parse.middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/content.parse.middleware.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,OAAO,EACP,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAe,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMnE,iBAAS,YAAY,CAAC,EAAE,SAAS,kBAAkB,EAAE,OAAO,CAAC,EAAE;IAC7D,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,SASoB,OAAO,OAAO,QAAQ,QAAQ,YAAY,mBAoF9D;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ParamsDictionary } from '@forklaunch/core/http';
|
|
2
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
3
|
+
import { NextFunction } from 'express';
|
|
4
|
+
import { ParsedQs } from 'qs';
|
|
5
|
+
import { MiddlewareRequest, MiddlewareResponse } from '../types/express.types';
|
|
6
|
+
/**
|
|
7
|
+
* Middleware to enrich the response transmission by intercepting and parsing responses before they are sent.
|
|
8
|
+
* This middleware enhances Express's response handling by adding additional functionality to the send, json,
|
|
9
|
+
* and setHeader methods.
|
|
10
|
+
*
|
|
11
|
+
* @template SV - A type that extends AnySchemaValidator for schema validation
|
|
12
|
+
* @param {MiddlewareRequest} req - The Express request object with additional type information
|
|
13
|
+
* @param {MiddlewareResponse} res - The Express response object with additional type information
|
|
14
|
+
* @param {NextFunction} [next] - The next middleware function in the chain
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* app.use(enrichResponseTransmission);
|
|
19
|
+
*
|
|
20
|
+
* app.get('/users', (req, res) => {
|
|
21
|
+
* // Response will be automatically enriched
|
|
22
|
+
* res.json({ users: [] });
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function enrichResponseTransmission<SV extends AnySchemaValidator>(req: MiddlewareRequest<SV, ParamsDictionary, Record<number, unknown>, Record<string, unknown>, ParsedQs, Record<string, string>, Record<string, unknown>, 'middleware', Record<string, unknown>>, res: MiddlewareResponse<Record<number, unknown>, Record<string, string>, Record<string, unknown>>, next?: NextFunction): void;
|
|
27
|
+
//# sourceMappingURL=enrichResponseTransmission.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichResponseTransmission.middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/enrichResponseTransmission.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,SAAS,kBAAkB,EACtE,GAAG,EAAE,iBAAiB,CACpB,EAAE,EACF,gBAAgB,EAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,QAAQ,EACR,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,YAAY,EACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxB,EACD,GAAG,EAAE,kBAAkB,CACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxB,EACD,IAAI,CAAC,EAAE,YAAY,QA+HpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Express } from 'express-serve-static-core';
|
|
2
|
+
import { ParsedQs } from 'qs';
|
|
3
|
+
import { Range } from 'range-parser';
|
|
4
|
+
export type SetExportTypes<T extends ParsedQs, U extends Express, V extends Range> = {
|
|
5
|
+
qs: T;
|
|
6
|
+
express: U;
|
|
7
|
+
rangeParser: V;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=export.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.types.d.ts","sourceRoot":"","sources":["../../../src/types/export.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,MAAM,cAAc,CACxB,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,KAAK,IACb;IACF,EAAE,EAAE,CAAC,CAAC;IACN,OAAO,EAAE,CAAC,CAAC;IACX,WAAW,EAAE,CAAC,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ForklaunchRequest, ForklaunchResponse, ForklaunchSendableData, ForklaunchStatusResponse, ParamsDictionary, ParsedQs } from '@forklaunch/core/http';
|
|
2
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
3
|
+
import { Request as ExpressRequest, Response as ExpressResponse } from 'express';
|
|
4
|
+
import { NextFunction } from 'express-serve-static-core';
|
|
5
|
+
import { IncomingHttpHeaders } from 'http';
|
|
6
|
+
/**
|
|
7
|
+
* Extends the Forklaunch request interface with properties from Express's request interface.
|
|
8
|
+
* This interface combines the functionality of both Forklaunch and Express request objects
|
|
9
|
+
* while avoiding property conflicts through strategic omission.
|
|
10
|
+
*
|
|
11
|
+
* @template SV - Schema validator type extending AnySchemaValidator
|
|
12
|
+
* @template P - Request parameters type extending ParamsDictionary
|
|
13
|
+
* @template ResBodyMap - Response body map type as a record with numeric keys
|
|
14
|
+
* @template ReqBody - Request body type as a record with string keys
|
|
15
|
+
* @template ReqQuery - Request query type extending ParsedQs
|
|
16
|
+
* @template ReqHeaders - Request headers type as a record with string keys
|
|
17
|
+
* @template LocalsObj - Local variables type as a record with string keys
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* interface UserRequest extends MiddlewareRequest<
|
|
22
|
+
* SchemaValidator,
|
|
23
|
+
* { id: string },
|
|
24
|
+
* { 200: { name: string } },
|
|
25
|
+
* { name: string },
|
|
26
|
+
* { filter: string },
|
|
27
|
+
* { 'content-type': string },
|
|
28
|
+
* { user: User }
|
|
29
|
+
* > {}
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export interface MiddlewareRequest<SV extends AnySchemaValidator, P extends ParamsDictionary, ResBodyMap extends Record<number, unknown>, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, Versions extends string, SessionSchema extends Record<string, unknown>> extends ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Versions, SessionSchema>, Omit<ExpressRequest<P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>, 'method' | 'body' | 'params' | 'query' | 'headers' | 'path'> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Extends the Forklaunch response interface with properties from Express's response interface.
|
|
36
|
+
* This interface combines the functionality of both Forklaunch and Express response objects
|
|
37
|
+
* while avoiding property conflicts through strategic omission. It also includes status response
|
|
38
|
+
* functionality and CORS support.
|
|
39
|
+
*
|
|
40
|
+
* @template ResBodyMap - Response body map type as a record with numeric keys
|
|
41
|
+
* @template ResHeaders - Response headers type as a record with string keys
|
|
42
|
+
* @template LocalsObj - Local variables type as a record with string keys
|
|
43
|
+
*
|
|
44
|
+
* @property {boolean} cors - Indicates whether CORS headers are applied to the response
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* interface UserResponse extends MiddlewareResponse<
|
|
49
|
+
* { 200: { name: string }, 404: { error: string } },
|
|
50
|
+
* { 'content-type': string },
|
|
51
|
+
* { user: User }
|
|
52
|
+
* > {}
|
|
53
|
+
*
|
|
54
|
+
* // Usage in a route handler
|
|
55
|
+
* app.get('/users/:id', (req, res: UserResponse) => {
|
|
56
|
+
* res.cors = true; // Enable CORS
|
|
57
|
+
* res.json({ name: 'John' });
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export interface MiddlewareResponse<ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown> = Record<string, unknown>, Versions extends string = string> extends ForklaunchResponse<ExpressResponse, ResBodyMap, ResHeaders, LocalsObj, Versions>, Omit<ExpressResponse<ResBodyMap, LocalsObj>, 'status' | 'statusCode' | 'sendStatus' | 'getHeaders' | 'getHeader' | 'setHeader' | 'send' | 'json' | 'jsonp' | 'end' | 'locals' | 'type' | 'on'>, ForklaunchStatusResponse<ForklaunchSendableData> {
|
|
62
|
+
/** Whether CORS headers are applied to the response */
|
|
63
|
+
cors: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Express-compatible request handler type for Forklaunch.
|
|
67
|
+
*
|
|
68
|
+
* @param req - The incoming request object, with `query` and `headers` properties normalized to either `ParsedQs` or a generic record.
|
|
69
|
+
* @param res - The response object for sending data back to the client.
|
|
70
|
+
* @param next - The next middleware function in the Express stack.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* const handler: ExpressRequestHandler = (req, res, next) => {
|
|
74
|
+
* // Access normalized query and headers
|
|
75
|
+
* const userId = req.query.userId;
|
|
76
|
+
* const customHeader = req.headers['x-custom-header'];
|
|
77
|
+
* res.json({ userId, customHeader });
|
|
78
|
+
* };
|
|
79
|
+
*/
|
|
80
|
+
export type ExpressRequestHandler = (req: Omit<ExpressRequest, 'query' | 'headers'> & {
|
|
81
|
+
query: ParsedQs | Record<string, unknown>;
|
|
82
|
+
headers: IncomingHttpHeaders | Record<string, unknown>;
|
|
83
|
+
}, res: ExpressResponse, next: NextFunction) => void;
|
|
84
|
+
//# sourceMappingURL=express.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.types.d.ts","sourceRoot":"","sources":["../../../src/types/express.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,QAAQ,IAAI,eAAe,EAC5B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;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,WAAW,GACX,WAAW,GACX,MAAM,GACN,MAAM,GACN,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,IAAI,CACP,EACD,wBAAwB,CAAC,sBAAsB,CAAC;IAClD,uDAAuD;IACvD,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC,GAAG;IAC/C,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxD,EACD,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,YAAY,KACf,IAAI,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExpressLikeApplicationOptions, ExpressLikeRouterOptions, SessionObject } from '@forklaunch/core/http';
|
|
2
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
3
|
+
import { OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
|
|
4
|
+
import { BusboyConfig } from 'busboy';
|
|
5
|
+
export type ExpressApplicationOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = ExpressLikeApplicationOptions<SV, SessionSchema> & {
|
|
6
|
+
busboy?: BusboyConfig;
|
|
7
|
+
text?: OptionsText;
|
|
8
|
+
json?: OptionsJson;
|
|
9
|
+
urlencoded?: OptionsUrlencoded;
|
|
10
|
+
};
|
|
11
|
+
export type ExpressRouterOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = ExpressLikeRouterOptions<SV, SessionSchema> & {
|
|
12
|
+
busboy?: BusboyConfig;
|
|
13
|
+
text?: OptionsText;
|
|
14
|
+
json?: OptionsJson;
|
|
15
|
+
urlencoded?: OptionsUrlencoded;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=expressOptions.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressOptions.types.d.ts","sourceRoot":"","sources":["../../../src/types/expressOptions.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,yBAAyB,CACnC,EAAE,SAAS,kBAAkB,EAC7B,aAAa,SAAS,aAAa,CAAC,EAAE,CAAC,IACrC,6BAA6B,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG;IACrD,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAC9B,EAAE,SAAS,kBAAkB,EAC7B,aAAa,SAAS,aAAa,CAAC,EAAE,CAAC,IACrC,wBAAwB,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG;IAChD,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/express",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.33",
|
|
4
4
|
"description": "Forklaunch framework for express.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -24,55 +24,56 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"lib/**"
|
|
26
26
|
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsgo --noEmit && tsup index.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --clean && tsgo -p tsconfig.build.json --emitDeclarationOnly",
|
|
29
|
+
"clean": "rm -rf lib pnpm.lock.yaml node_modules",
|
|
30
|
+
"docs": "typedoc --out docs *",
|
|
31
|
+
"format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
|
|
32
|
+
"lint": "eslint . -c eslint.config.mjs",
|
|
33
|
+
"lint:fix": "eslint . -c eslint.config.mjs --fix",
|
|
34
|
+
"prepack": "pnpm run build",
|
|
35
|
+
"publish:package": "./publish-package.bash",
|
|
36
|
+
"test": "vitest --passWithNoTests"
|
|
37
|
+
},
|
|
27
38
|
"dependencies": {
|
|
39
|
+
"@forklaunch/common": "workspace:*",
|
|
40
|
+
"@forklaunch/core": "workspace:*",
|
|
41
|
+
"@forklaunch/validator": "workspace:*",
|
|
28
42
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
29
|
-
"@scalar/express-api-reference": "^0.
|
|
30
|
-
"@types/multer": "^2.
|
|
31
|
-
"body-parser": "^2.
|
|
43
|
+
"@scalar/express-api-reference": "^0.10.11",
|
|
44
|
+
"@types/multer": "^2.2.0",
|
|
45
|
+
"body-parser": "^2.3.0",
|
|
32
46
|
"busboy": "^1.6.0",
|
|
33
47
|
"cors": "^2.8.6",
|
|
34
48
|
"express": "^5.2.1",
|
|
35
|
-
"fastmcp": "^4.
|
|
36
|
-
"multer": "2.
|
|
37
|
-
"qs": "^6.15.
|
|
38
|
-
"range-parser": "^1.
|
|
39
|
-
"swagger-ui-express": "^5.0.1"
|
|
40
|
-
"@forklaunch/common": "1.2.17",
|
|
41
|
-
"@forklaunch/core": "1.5.1",
|
|
42
|
-
"@forklaunch/validator": "1.2.17"
|
|
49
|
+
"fastmcp": "^4.12.0",
|
|
50
|
+
"multer": "2.2.0",
|
|
51
|
+
"qs": "^6.15.3",
|
|
52
|
+
"range-parser": "^1.3.0",
|
|
53
|
+
"swagger-ui-express": "^5.0.1"
|
|
43
54
|
},
|
|
44
55
|
"devDependencies": {
|
|
45
56
|
"@eslint/js": "^10.0.1",
|
|
46
57
|
"@types/body-parser": "^1.19.6",
|
|
47
|
-
"@types/bun": "^1.3.
|
|
58
|
+
"@types/bun": "^1.3.14",
|
|
48
59
|
"@types/busboy": "^1.5.4",
|
|
49
60
|
"@types/cors": "^2.8.19",
|
|
50
61
|
"@types/express": "^5.0.6",
|
|
51
|
-
"@types/express-serve-static-core": "^5.1.
|
|
62
|
+
"@types/express-serve-static-core": "^5.1.2",
|
|
52
63
|
"@types/jest": "^30.0.0",
|
|
53
|
-
"@types/node": "^
|
|
54
|
-
"@types/qs": "^6.15.
|
|
64
|
+
"@types/node": "^26.1.1",
|
|
65
|
+
"@types/qs": "^6.15.1",
|
|
55
66
|
"@types/range-parser": "^1.2.7",
|
|
56
67
|
"@types/swagger-ui-express": "^4.1.8",
|
|
57
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
58
|
-
"jest": "^30.
|
|
68
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
69
|
+
"jest": "^30.4.2",
|
|
59
70
|
"kill-port-process": "^4.0.2",
|
|
60
|
-
"prettier": "^3.
|
|
61
|
-
"ts-jest": "^29.4.
|
|
71
|
+
"prettier": "^3.9.6",
|
|
72
|
+
"ts-jest": "^29.4.12",
|
|
62
73
|
"ts-node": "^10.9.2",
|
|
63
74
|
"tsup": "^8.5.1",
|
|
64
|
-
"typedoc": "^0.28.
|
|
65
|
-
"typescript": "
|
|
66
|
-
"typescript-eslint": "^8.
|
|
67
|
-
},
|
|
68
|
-
"scripts": {
|
|
69
|
-
"build": "tsgo --noEmit && tsup index.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",
|
|
70
|
-
"clean": "rm -rf lib pnpm.lock.yaml node_modules",
|
|
71
|
-
"docs": "typedoc --out docs *",
|
|
72
|
-
"format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
|
|
73
|
-
"lint": "eslint . -c eslint.config.mjs",
|
|
74
|
-
"lint:fix": "eslint . -c eslint.config.mjs --fix",
|
|
75
|
-
"publish:package": "./publish-package.bash",
|
|
76
|
-
"test": "vitest --passWithNoTests"
|
|
75
|
+
"typedoc": "^0.28.20",
|
|
76
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
77
|
+
"typescript-eslint": "^8.65.0"
|
|
77
78
|
}
|
|
78
|
-
}
|
|
79
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 forklaunch
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|