@forklaunch/core 0.1.15 → 0.1.16
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/dist/http/interfaces/forklaunchExpress.application.interface.d.ts +4 -1
- package/dist/http/interfaces/forklaunchExpress.application.interface.d.ts.map +1 -1
- package/dist/http/interfaces/forklaunchExpress.application.interface.js +5 -5
- package/dist/http/interfaces/forklaunchExpress.router.interface.d.ts +44 -2
- package/dist/http/interfaces/forklaunchExpress.router.interface.d.ts.map +1 -1
- package/dist/http/interfaces/forklaunchExpress.router.interface.js +33 -35
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1,6 +1,9 @@
|
|
1
1
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { ForklaunchRouter } from '../types';
|
2
3
|
export declare abstract class ForklaunchExpressLikeApplication<SV extends AnySchemaValidator, Server> {
|
3
|
-
|
4
|
+
readonly schemaValidator: SV;
|
5
|
+
readonly internal: Server;
|
6
|
+
routers: ForklaunchRouter<SV>[];
|
4
7
|
/**
|
5
8
|
* Creates an instance of the Application class.
|
6
9
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"forklaunchExpress.application.interface.d.ts","sourceRoot":"","sources":["../../../http/interfaces/forklaunchExpress.application.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
1
|
+
{"version":3,"file":"forklaunchExpress.application.interface.d.ts","sourceRoot":"","sources":["../../../http/interfaces/forklaunchExpress.application.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,8BAAsB,gCAAgC,CACpD,EAAE,SAAS,kBAAkB,EAC7B,MAAM;IAUJ,QAAQ,CAAC,eAAe,EAAE,EAAE;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAT3B,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAM;IAErC;;;;OAIG;gBAEQ,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,MAAM;IAG3B,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IACtC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAC1C"}
|
@@ -1,14 +1,14 @@
|
|
1
1
|
export class ForklaunchExpressLikeApplication {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
schemaValidator;
|
3
|
+
internal;
|
4
|
+
routers = [];
|
5
5
|
/**
|
6
6
|
* Creates an instance of the Application class.
|
7
7
|
*
|
8
8
|
* @param {SV} schemaValidator - The schema validator.
|
9
9
|
*/
|
10
10
|
constructor(schemaValidator, internal) {
|
11
|
-
this
|
12
|
-
this
|
11
|
+
this.schemaValidator = schemaValidator;
|
12
|
+
this.internal = internal;
|
13
13
|
}
|
14
14
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
-
import { Body, ForklaunchSchemaMiddlewareHandler, HeadersObject, HttpContractDetails, LiveTypeFunction, ParamsObject, PathParamHttpContractDetails, QueryObject, ResponsesObject } from '../types';
|
2
|
+
import { Body, ForklaunchRoute, ForklaunchSchemaMiddlewareHandler, HeadersObject, HttpContractDetails, LiveTypeFunction, ParamsObject, PathParamHttpContractDetails, QueryObject, ResponsesObject } from '../types';
|
3
3
|
interface ExpressLikeRouter<RouterFunction> {
|
4
4
|
use: (...args: (string | RouterFunction)[]) => this;
|
5
5
|
get(path: string, ...handlers: RouterFunction[]): void;
|
@@ -9,9 +9,43 @@ interface ExpressLikeRouter<RouterFunction> {
|
|
9
9
|
delete(path: string, ...handlers: RouterFunction[]): void;
|
10
10
|
}
|
11
11
|
export declare abstract class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePath extends `/${string}`, RouterFunction, Internal extends ExpressLikeRouter<RouterFunction>> {
|
12
|
-
#private;
|
13
12
|
readonly internal: Internal;
|
13
|
+
readonly routes: ForklaunchRoute<SV>[];
|
14
|
+
readonly basePath: BasePath;
|
14
15
|
constructor(basePath: BasePath, internal: Internal);
|
16
|
+
/**
|
17
|
+
* Resolves middlewares based on the contract details.
|
18
|
+
*
|
19
|
+
* @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
|
20
|
+
* @returns {MiddlewareHandler<SV>[]} - The resolved middlewares.
|
21
|
+
*/
|
22
|
+
private resolveMiddlewares;
|
23
|
+
/**
|
24
|
+
* Parses and runs the controller function with error handling.
|
25
|
+
*
|
26
|
+
* @template P - The type of request parameters.
|
27
|
+
* @template ResBodyMap - The type of response body.
|
28
|
+
* @template ReqBody - The type of request body.
|
29
|
+
* @template ReqQuery - The type of request query.
|
30
|
+
* @template LocalsObj - The type of local variables.
|
31
|
+
* @template StatusCode - The type of status code.
|
32
|
+
* @param {MiddlewareHandler<SV, P, ResBodyMap | string, ReqBody, ReqQuery, LocalsObj, StatusCode>} requestHandler - The request handler.
|
33
|
+
* @returns {ExpressMiddlewareHandler} - The Express request handler.
|
34
|
+
*/
|
35
|
+
private parseAndRunControllerFunction;
|
36
|
+
/**
|
37
|
+
* Extracts the controller function from the provided functions.
|
38
|
+
*
|
39
|
+
* @template P - The type of request parameters.
|
40
|
+
* @template ResBodyMap - The type of response body.
|
41
|
+
* @template ReqBody - The type of request body.
|
42
|
+
* @template ReqQuery - The type of request query.
|
43
|
+
* @template LocalsObj - The type of local variables.
|
44
|
+
* @param {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The provided functions.
|
45
|
+
* @returns {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>} - The extracted controller function.
|
46
|
+
* @throws {Error} - Throws an error if the last argument is not a function.
|
47
|
+
*/
|
48
|
+
private extractControllerFunction;
|
15
49
|
/**
|
16
50
|
* Registers middleware to the router.
|
17
51
|
*
|
@@ -19,6 +53,14 @@ export declare abstract class ForklaunchExpressLikeRouter<SV extends AnySchemaVa
|
|
19
53
|
* @returns {this} - The router instance.
|
20
54
|
*/
|
21
55
|
use(...args: unknown[]): this;
|
56
|
+
/**
|
57
|
+
* Executes request locally, applying parameters
|
58
|
+
*
|
59
|
+
* @param functions {ForklaunchMiddlewareHandler<SV>}
|
60
|
+
* @param controllerFunction
|
61
|
+
* @returns
|
62
|
+
*/
|
63
|
+
private localParamRequest;
|
22
64
|
/**
|
23
65
|
* Registers a GET route with the specified contract details and handler functions.
|
24
66
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"forklaunchExpress.router.interface.d.ts","sourceRoot":"","sources":["../../../http/interfaces/forklaunchExpress.router.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAU3D,OAAO,EACL,IAAI,
|
1
|
+
{"version":3,"file":"forklaunchExpress.router.interface.d.ts","sourceRoot":"","sources":["../../../http/interfaces/forklaunchExpress.router.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAU3D,OAAO,EACL,IAAI,EAEJ,eAAe,EACf,iCAAiC,EACjC,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAEhB,YAAY,EACZ,4BAA4B,EAC5B,WAAW,EACX,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,UAAU,iBAAiB,CAAC,cAAc;IACxC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,KAAK,IAAI,CAAC;IACpD,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACvD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAA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a,CAAC,EAAE,CAAC,EACxD,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEnE,IAAI,EAAE,IAAI,EACV,eAAe,EAAE,4BAA4B,CAC3C,EAAE,EACF,CAAC,EACD,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,CACX,EACD,GAAG,SAAS,EAAE,iCAAiC,CAC7C,EAAE,EACF,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,CACV,EAAE;;;CA8BN"}
|
@@ -1,13 +1,11 @@
|
|
1
1
|
import { enrichRequestDetails, parseReqHeaders, parseRequestAuth, parseRequestBody, parseRequestParams, parseRequestQuery } from '../middleware';
|
2
2
|
export class ForklaunchExpressLikeRouter {
|
3
3
|
internal;
|
4
|
-
|
5
|
-
|
6
|
-
#internal;
|
4
|
+
routes = [];
|
5
|
+
basePath;
|
7
6
|
constructor(basePath, internal) {
|
8
7
|
this.internal = internal;
|
9
|
-
this
|
10
|
-
this.#internal = internal;
|
8
|
+
this.basePath = basePath;
|
11
9
|
}
|
12
10
|
/**
|
13
11
|
* Resolves middlewares based on the contract details.
|
@@ -15,7 +13,7 @@ export class ForklaunchExpressLikeRouter {
|
|
15
13
|
* @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
|
16
14
|
* @returns {MiddlewareHandler<SV>[]} - The resolved middlewares.
|
17
15
|
*/
|
18
|
-
|
16
|
+
resolveMiddlewares(contractDetails) {
|
19
17
|
const middlewares = [
|
20
18
|
enrichRequestDetails(contractDetails)
|
21
19
|
];
|
@@ -48,7 +46,7 @@ export class ForklaunchExpressLikeRouter {
|
|
48
46
|
* @param {MiddlewareHandler<SV, P, ResBodyMap | string, ReqBody, ReqQuery, LocalsObj, StatusCode>} requestHandler - The request handler.
|
49
47
|
* @returns {ExpressMiddlewareHandler} - The Express request handler.
|
50
48
|
*/
|
51
|
-
|
49
|
+
parseAndRunControllerFunction(requestHandler) {
|
52
50
|
return (async (req, res, next) => {
|
53
51
|
if (!requestHandler) {
|
54
52
|
throw new Error('Controller function is not defined');
|
@@ -79,7 +77,7 @@ export class ForklaunchExpressLikeRouter {
|
|
79
77
|
* @returns {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>} - The extracted controller function.
|
80
78
|
* @throws {Error} - Throws an error if the last argument is not a function.
|
81
79
|
*/
|
82
|
-
|
80
|
+
extractControllerFunction(functions) {
|
83
81
|
const controllerFunction = functions.pop();
|
84
82
|
if (typeof controllerFunction !== 'function') {
|
85
83
|
throw new Error('Last argument must be a function');
|
@@ -94,7 +92,7 @@ export class ForklaunchExpressLikeRouter {
|
|
94
92
|
// * @returns {string} - The extracted SDK path.
|
95
93
|
// * @throws {Error} - Throws an error if the path is not defined.
|
96
94
|
// */
|
97
|
-
//
|
95
|
+
// extractSdkPath(path: string | RegExp | (string | RegExp)[]): string {
|
98
96
|
// let sdkPath = path;
|
99
97
|
// if (Array.isArray(path)) {
|
100
98
|
// sdkPath = path.pop() || path[0];
|
@@ -124,7 +122,7 @@ export class ForklaunchExpressLikeRouter {
|
|
124
122
|
* @param controllerFunction
|
125
123
|
* @returns
|
126
124
|
*/
|
127
|
-
|
125
|
+
localParamRequest(functions, controllerFunction) {
|
128
126
|
return (async (route, request) => {
|
129
127
|
let statusCode;
|
130
128
|
let responseMessage;
|
@@ -198,16 +196,16 @@ export class ForklaunchExpressLikeRouter {
|
|
198
196
|
* @returns {ExpressRouter} - The Express router.
|
199
197
|
*/
|
200
198
|
get(path, contractDetails, ...functions) {
|
201
|
-
const controllerFunction = this
|
202
|
-
this
|
203
|
-
basePath: this
|
199
|
+
const controllerFunction = this.extractControllerFunction(functions);
|
200
|
+
this.routes.push({
|
201
|
+
basePath: this.basePath,
|
204
202
|
path,
|
205
203
|
method: 'GET',
|
206
204
|
contractDetails
|
207
205
|
});
|
208
|
-
this.internal.get(path, ...this
|
206
|
+
this.internal.get(path, ...this.resolveMiddlewares(contractDetails).concat(functions), this.parseAndRunControllerFunction(controllerFunction));
|
209
207
|
return {
|
210
|
-
get: this
|
208
|
+
get: this.localParamRequest(functions, controllerFunction)
|
211
209
|
};
|
212
210
|
}
|
213
211
|
/**
|
@@ -225,16 +223,16 @@ export class ForklaunchExpressLikeRouter {
|
|
225
223
|
*/
|
226
224
|
post(path, contractDetails, ...functions) {
|
227
225
|
// : LiveType<SV, P, ResBodyMap, ReqBody, ReqQuery> {
|
228
|
-
const controllerFunction = this
|
229
|
-
this
|
230
|
-
basePath: this
|
226
|
+
const controllerFunction = this.extractControllerFunction(functions);
|
227
|
+
this.routes.push({
|
228
|
+
basePath: this.basePath,
|
231
229
|
path,
|
232
230
|
method: 'POST',
|
233
231
|
contractDetails
|
234
232
|
});
|
235
|
-
this.internal.post(path, ...this
|
233
|
+
this.internal.post(path, ...this.resolveMiddlewares(contractDetails).concat(functions), this.parseAndRunControllerFunction(controllerFunction));
|
236
234
|
return {
|
237
|
-
post: this
|
235
|
+
post: this.localParamRequest(functions, controllerFunction)
|
238
236
|
};
|
239
237
|
}
|
240
238
|
/**
|
@@ -251,16 +249,16 @@ export class ForklaunchExpressLikeRouter {
|
|
251
249
|
* @returns {ExpressRouter} - The Express router.
|
252
250
|
*/
|
253
251
|
put(path, contractDetails, ...functions) {
|
254
|
-
const controllerFunction = this
|
255
|
-
this
|
256
|
-
basePath: this
|
252
|
+
const controllerFunction = this.extractControllerFunction(functions);
|
253
|
+
this.routes.push({
|
254
|
+
basePath: this.basePath,
|
257
255
|
path,
|
258
256
|
method: 'PUT',
|
259
257
|
contractDetails
|
260
258
|
});
|
261
|
-
this.internal.put(path, ...this
|
259
|
+
this.internal.put(path, ...this.resolveMiddlewares(contractDetails).concat(functions), this.parseAndRunControllerFunction(controllerFunction));
|
262
260
|
return {
|
263
|
-
put: this
|
261
|
+
put: this.localParamRequest(functions, controllerFunction)
|
264
262
|
};
|
265
263
|
}
|
266
264
|
/**
|
@@ -277,16 +275,16 @@ export class ForklaunchExpressLikeRouter {
|
|
277
275
|
* @returns {ExpressRouter} - The Express router.
|
278
276
|
*/
|
279
277
|
patch(path, contractDetails, ...functions) {
|
280
|
-
const controllerFunction = this
|
281
|
-
this
|
282
|
-
basePath: this
|
278
|
+
const controllerFunction = this.extractControllerFunction(functions);
|
279
|
+
this.routes.push({
|
280
|
+
basePath: this.basePath,
|
283
281
|
path,
|
284
282
|
method: 'PATCH',
|
285
283
|
contractDetails
|
286
284
|
});
|
287
|
-
this.internal.patch(path, ...this
|
285
|
+
this.internal.patch(path, ...this.resolveMiddlewares(contractDetails).concat(functions), this.parseAndRunControllerFunction(controllerFunction));
|
288
286
|
return {
|
289
|
-
patch: this
|
287
|
+
patch: this.localParamRequest(functions, controllerFunction)
|
290
288
|
};
|
291
289
|
}
|
292
290
|
/**
|
@@ -303,16 +301,16 @@ export class ForklaunchExpressLikeRouter {
|
|
303
301
|
* @returns {ExpressRouter} - The Express router.
|
304
302
|
*/
|
305
303
|
delete(path, contractDetails, ...functions) {
|
306
|
-
const controllerFunction = this
|
307
|
-
this
|
308
|
-
basePath: this
|
304
|
+
const controllerFunction = this.extractControllerFunction(functions);
|
305
|
+
this.routes.push({
|
306
|
+
basePath: this.basePath,
|
309
307
|
path,
|
310
308
|
method: 'DELETE',
|
311
309
|
contractDetails
|
312
310
|
});
|
313
|
-
this.internal.delete(path, ...this
|
311
|
+
this.internal.delete(path, ...this.resolveMiddlewares(contractDetails).concat(functions), this.parseAndRunControllerFunction(controllerFunction));
|
314
312
|
return {
|
315
|
-
delete: this
|
313
|
+
delete: this.localParamRequest(functions, controllerFunction)
|
316
314
|
};
|
317
315
|
}
|
318
316
|
}
|