@forklaunch/core 0.2.37 → 0.3.0
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/{src/database/mikro/models/entities/base.entity.d.ts → base.entity-DNfmMOgd.d.mts} +3 -2
- package/lib/base.entity-DNfmMOgd.d.ts +27 -0
- package/lib/{src/cache/redisTtlCache.d.ts → cache/index.d.mts} +67 -4
- package/lib/cache/index.d.ts +130 -0
- package/lib/cache/index.js +133 -0
- package/lib/cache/index.mjs +105 -0
- package/lib/controllers/index.d.mts +5 -0
- package/lib/controllers/index.d.ts +5 -0
- package/lib/controllers/index.js +18 -0
- package/lib/controllers/index.mjs +0 -0
- package/lib/database/index.d.mts +37 -0
- package/lib/{src/database/mikro/models/entities/mongo.base.entity.d.ts → database/index.d.ts} +5 -2
- package/lib/database/index.js +78 -0
- package/lib/database/index.mjs +53 -0
- package/lib/dtoMapper/index.d.mts +215 -0
- package/lib/dtoMapper/index.d.ts +215 -0
- package/lib/dtoMapper/index.js +230 -0
- package/lib/dtoMapper/index.mjs +202 -0
- package/lib/http/index.d.mts +910 -0
- package/lib/http/index.d.ts +910 -0
- package/lib/http/index.js +2181 -0
- package/lib/http/index.mjs +2122 -0
- package/lib/services/index.d.mts +64 -0
- package/lib/services/index.d.ts +64 -0
- package/lib/services/index.js +159 -0
- package/lib/services/index.mjs +131 -0
- package/package.json +39 -26
- package/lib/src/cache/index.d.ts +0 -5
- package/lib/src/cache/index.d.ts.map +0 -1
- package/lib/src/cache/index.js +0 -4
- package/lib/src/cache/interfaces/ttlCache.interface.d.ts +0 -48
- package/lib/src/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
- package/lib/src/cache/interfaces/ttlCache.interface.js +0 -1
- package/lib/src/cache/redisTtlCache.d.ts.map +0 -1
- package/lib/src/cache/redisTtlCache.js +0 -98
- package/lib/src/cache/types/ttlCacheRecord.types.d.ts +0 -14
- package/lib/src/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
- package/lib/src/cache/types/ttlCacheRecord.types.js +0 -1
- package/lib/src/cache/utils/cacheKey.d.ts +0 -2
- package/lib/src/cache/utils/cacheKey.d.ts.map +0 -1
- package/lib/src/cache/utils/cacheKey.js +0 -3
- package/lib/src/controllers/index.d.ts +0 -2
- package/lib/src/controllers/index.d.ts.map +0 -1
- package/lib/src/controllers/index.js +0 -1
- package/lib/src/controllers/interfaces/controller.interface.d.ts +0 -4
- package/lib/src/controllers/interfaces/controller.interface.d.ts.map +0 -1
- package/lib/src/controllers/interfaces/controller.interface.js +0 -1
- package/lib/src/database/index.d.ts +0 -3
- package/lib/src/database/index.d.ts.map +0 -1
- package/lib/src/database/index.js +0 -2
- package/lib/src/database/mikro/models/entities/base.entity.d.ts.map +0 -1
- package/lib/src/database/mikro/models/entities/base.entity.js +0 -42
- package/lib/src/database/mikro/models/entities/mongo.base.entity.d.ts.map +0 -1
- package/lib/src/database/mikro/models/entities/mongo.base.entity.js +0 -51
- package/lib/src/dtoMapper/index.d.ts +0 -3
- package/lib/src/dtoMapper/index.d.ts.map +0 -1
- package/lib/src/dtoMapper/index.js +0 -2
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts +0 -18
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.js +0 -1
- package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts +0 -72
- package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts.map +0 -1
- package/lib/src/dtoMapper/models/baseDtoMapper.model.js +0 -76
- package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts +0 -68
- package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts.map +0 -1
- package/lib/src/dtoMapper/models/requestDtoMapper.model.js +0 -71
- package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts +0 -67
- package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts.map +0 -1
- package/lib/src/dtoMapper/models/responseDtoMapper.model.js +0 -68
- package/lib/src/dtoMapper/types/dtoMapper.types.d.ts +0 -9
- package/lib/src/dtoMapper/types/dtoMapper.types.d.ts.map +0 -1
- package/lib/src/dtoMapper/types/dtoMapper.types.js +0 -1
- package/lib/src/http/application/expressLikeApplication.d.ts +0 -21
- package/lib/src/http/application/expressLikeApplication.d.ts.map +0 -1
- package/lib/src/http/application/expressLikeApplication.js +0 -21
- package/lib/src/http/guards/isConstrainedForklaunchRouter.d.ts +0 -4
- package/lib/src/http/guards/isConstrainedForklaunchRouter.d.ts.map +0 -1
- package/lib/src/http/guards/isConstrainedForklaunchRouter.js +0 -5
- package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts +0 -5
- package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts.map +0 -1
- package/lib/src/http/guards/isExpressLikeSchemaHandler.js +0 -6
- package/lib/src/http/guards/isForklaunchExpressLikeRouter.d.ts +0 -5
- package/lib/src/http/guards/isForklaunchExpressLikeRouter.d.ts.map +0 -1
- package/lib/src/http/guards/isForklaunchExpressLikeRouter.js +0 -6
- package/lib/src/http/guards/isForklaunchRouter.d.ts +0 -4
- package/lib/src/http/guards/isForklaunchRouter.d.ts.map +0 -1
- package/lib/src/http/guards/isForklaunchRouter.js +0 -7
- package/lib/src/http/guards/isHttpContractDetails.d.ts +0 -7
- package/lib/src/http/guards/isHttpContractDetails.d.ts.map +0 -1
- package/lib/src/http/guards/isHttpContractDetails.js +0 -9
- package/lib/src/http/guards/isPathParamContractDetails.d.ts +0 -4
- package/lib/src/http/guards/isPathParamContractDetails.d.ts.map +0 -1
- package/lib/src/http/guards/isPathParamContractDetails.js +0 -10
- package/lib/src/http/guards/isResponseShape.d.ts +0 -3
- package/lib/src/http/guards/isResponseShape.d.ts.map +0 -1
- package/lib/src/http/guards/isResponseShape.js +0 -7
- package/lib/src/http/guards/isTypedHandler.d.ts +0 -5
- package/lib/src/http/guards/isTypedHandler.d.ts.map +0 -1
- package/lib/src/http/guards/isTypedHandler.js +0 -6
- package/lib/src/http/handlers/delete.d.ts +0 -9
- package/lib/src/http/handlers/delete.d.ts.map +0 -1
- package/lib/src/http/handlers/delete.js +0 -4
- package/lib/src/http/handlers/get.d.ts +0 -9
- package/lib/src/http/handlers/get.d.ts.map +0 -1
- package/lib/src/http/handlers/get.js +0 -4
- package/lib/src/http/handlers/head.d.ts +0 -9
- package/lib/src/http/handlers/head.d.ts.map +0 -1
- package/lib/src/http/handlers/head.js +0 -4
- package/lib/src/http/handlers/middleware.d.ts +0 -9
- package/lib/src/http/handlers/middleware.d.ts.map +0 -1
- package/lib/src/http/handlers/middleware.js +0 -4
- package/lib/src/http/handlers/options.d.ts +0 -9
- package/lib/src/http/handlers/options.d.ts.map +0 -1
- package/lib/src/http/handlers/options.js +0 -4
- package/lib/src/http/handlers/patch.d.ts +0 -9
- package/lib/src/http/handlers/patch.d.ts.map +0 -1
- package/lib/src/http/handlers/patch.js +0 -4
- package/lib/src/http/handlers/post.d.ts +0 -9
- package/lib/src/http/handlers/post.d.ts.map +0 -1
- package/lib/src/http/handlers/post.js +0 -4
- package/lib/src/http/handlers/put.d.ts +0 -9
- package/lib/src/http/handlers/put.d.ts.map +0 -1
- package/lib/src/http/handlers/put.js +0 -4
- package/lib/src/http/handlers/trace.d.ts +0 -9
- package/lib/src/http/handlers/trace.d.ts.map +0 -1
- package/lib/src/http/handlers/trace.js +0 -4
- package/lib/src/http/handlers/typedAuthHandler.d.ts +0 -5
- package/lib/src/http/handlers/typedAuthHandler.d.ts.map +0 -1
- package/lib/src/http/handlers/typedAuthHandler.js +0 -3
- package/lib/src/http/handlers/typedHandler.d.ts +0 -21
- package/lib/src/http/handlers/typedHandler.d.ts.map +0 -1
- package/lib/src/http/handlers/typedHandler.js +0 -30
- package/lib/src/http/index.d.ts +0 -23
- package/lib/src/http/index.d.ts.map +0 -1
- package/lib/src/http/index.js +0 -22
- package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts +0 -24
- package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts.map +0 -1
- package/lib/src/http/interfaces/expressLikeRouter.interface.js +0 -1
- package/lib/src/http/middleware/request/auth.middleware.d.ts +0 -16
- package/lib/src/http/middleware/request/auth.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/auth.middleware.js +0 -143
- package/lib/src/http/middleware/request/cors.middleware.d.ts +0 -13
- package/lib/src/http/middleware/request/cors.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/cors.middleware.js +0 -15
- package/lib/src/http/middleware/request/createContext.middleware.d.ts +0 -15
- package/lib/src/http/middleware/request/createContext.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/createContext.middleware.js +0 -26
- package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts +0 -15
- package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/enrichDetails.middleware.js +0 -19
- package/lib/src/http/middleware/request/parse.middleware.d.ts +0 -17
- package/lib/src/http/middleware/request/parse.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/parse.middleware.js +0 -43
- package/lib/src/http/middleware/response/parse.middleware.d.ts +0 -31
- package/lib/src/http/middleware/response/parse.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/response/parse.middleware.js +0 -52
- package/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts +0 -14
- package/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts.map +0 -1
- package/lib/src/http/openApiV3Generator/openApiV3Generator.js +0 -169
- package/lib/src/http/router/expressLikeRouter.d.ts +0 -138
- package/lib/src/http/router/expressLikeRouter.d.ts.map +0 -1
- package/lib/src/http/router/expressLikeRouter.js +0 -483
- package/lib/src/http/types/apiDefinition.types.d.ts +0 -260
- package/lib/src/http/types/apiDefinition.types.d.ts.map +0 -1
- package/lib/src/http/types/apiDefinition.types.js +0 -1
- package/lib/src/http/types/contractDetails.types.d.ts +0 -211
- package/lib/src/http/types/contractDetails.types.d.ts.map +0 -1
- package/lib/src/http/types/contractDetails.types.js +0 -1
- package/lib/src/http/types/expressLikeRouter.types.d.ts +0 -51
- package/lib/src/http/types/expressLikeRouter.types.d.ts.map +0 -1
- package/lib/src/http/types/expressLikeRouter.types.js +0 -1
- package/lib/src/http/types/router.types.d.ts +0 -32
- package/lib/src/http/types/router.types.d.ts.map +0 -1
- package/lib/src/http/types/router.types.js +0 -1
- package/lib/src/http/types/typedHandler.types.d.ts +0 -10
- package/lib/src/http/types/typedHandler.types.d.ts.map +0 -1
- package/lib/src/http/types/typedHandler.types.js +0 -1
- package/lib/src/http/utils/enrichExpressLikeSend.d.ts +0 -32
- package/lib/src/http/utils/enrichExpressLikeSend.d.ts.map +0 -1
- package/lib/src/http/utils/enrichExpressLikeSend.js +0 -50
- package/lib/src/http/utils/httpStatusCodes.d.ts +0 -75
- package/lib/src/http/utils/httpStatusCodes.d.ts.map +0 -1
- package/lib/src/http/utils/httpStatusCodes.js +0 -1039
- package/lib/src/services/configInjector.d.ts +0 -21
- package/lib/src/services/configInjector.d.ts.map +0 -1
- package/lib/src/services/configInjector.js +0 -90
- package/lib/src/services/index.d.ts +0 -5
- package/lib/src/services/index.d.ts.map +0 -1
- package/lib/src/services/index.js +0 -4
- package/lib/src/services/interfaces/baseService.d.ts +0 -15
- package/lib/src/services/interfaces/baseService.d.ts.map +0 -1
- package/lib/src/services/interfaces/baseService.js +0 -1
- package/lib/src/services/types/configInjector.types.d.ts +0 -25
- package/lib/src/services/types/configInjector.types.d.ts.map +0 -1
- package/lib/src/services/types/configInjector.types.js +0 -6
- package/lib/src/services/types/entityManager.types.d.ts +0 -4
- package/lib/src/services/types/entityManager.types.d.ts.map +0 -1
- package/lib/src/services/types/entityManager.types.js +0 -1
- package/lib/tests/configInjector.test.d.ts +0 -2
- package/lib/tests/configInjector.test.d.ts.map +0 -1
- package/lib/tests/configInjector.test.js +0 -105
- package/lib/tests/dtoMapper.test.d.ts +0 -2
- package/lib/tests/dtoMapper.test.d.ts.map +0 -1
- package/lib/tests/dtoMapper.test.js +0 -170
- package/lib/tests/expressLikeRouterInstantiation.test.d.ts +0 -2
- package/lib/tests/expressLikeRouterInstantiation.test.d.ts.map +0 -1
- package/lib/tests/expressLikeRouterInstantiation.test.js +0 -118
- package/lib/tests/http.middleware.test.d.ts +0 -2
- package/lib/tests/http.middleware.test.d.ts.map +0 -1
- package/lib/tests/http.middleware.test.js +0 -102
- package/lib/tests/openApiV3Generator.test.d.ts +0 -2
- package/lib/tests/openApiV3Generator.test.d.ts.map +0 -1
- package/lib/tests/openApiV3Generator.test.js +0 -66
- package/lib/tests/redisTtlCache.test.d.ts +0 -2
- package/lib/tests/redisTtlCache.test.d.ts.map +0 -1
- package/lib/tests/redisTtlCache.test.js +0 -49
- package/lib/tests/typedHandler.test.d.ts +0 -2
- package/lib/tests/typedHandler.test.d.ts.map +0 -1
- package/lib/tests/typedHandler.test.js +0 -3
- package/lib/vitest.config.d.ts +0 -3
- package/lib/vitest.config.d.ts.map +0 -1
- package/lib/vitest.config.js +0 -7
@@ -1,32 +0,0 @@
|
|
1
|
-
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
-
import { HttpContractDetails, Method, PathParamHttpContractDetails } from './contractDetails.types';
|
3
|
-
export interface ConstrainedForklaunchRouter<SV extends AnySchemaValidator, RequestHandler> extends ForklaunchRouter<SV> {
|
4
|
-
requestHandler: RequestHandler;
|
5
|
-
}
|
6
|
-
/**
|
7
|
-
* Interface representing a Forklaunch router.
|
8
|
-
*
|
9
|
-
* @template SV - A type that extends AnySchemaValidator.
|
10
|
-
*/
|
11
|
-
export interface ForklaunchRouter<SV extends AnySchemaValidator> {
|
12
|
-
/** The base path for the router */
|
13
|
-
basePath: `/${string}`;
|
14
|
-
/** The routes associated with the router */
|
15
|
-
routes: ForklaunchRoute<SV>[];
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* Interface representing a Forklaunch route.
|
19
|
-
*
|
20
|
-
* @template SV - A type that extends AnySchemaValidator.
|
21
|
-
*/
|
22
|
-
export interface ForklaunchRoute<SV extends AnySchemaValidator> {
|
23
|
-
/** The base path for the route */
|
24
|
-
basePath: string;
|
25
|
-
/** The path for the route, which can be a string, RegExp, or an array of strings or RegExps */
|
26
|
-
path: string | RegExp | (string | RegExp)[];
|
27
|
-
/** The HTTP method for the route */
|
28
|
-
method: Method;
|
29
|
-
/** The contract details for the route */
|
30
|
-
contractDetails: PathParamHttpContractDetails<SV> | HttpContractDetails<SV>;
|
31
|
-
}
|
32
|
-
//# sourceMappingURL=router.types.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"router.types.d.ts","sourceRoot":"","sources":["../../../../src/http/types/router.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,4BAA4B,EAC7B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,2BAA2B,CAC1C,EAAE,SAAS,kBAAkB,EAC7B,cAAc,CACd,SAAQ,gBAAgB,CAAC,EAAE,CAAC;IAC5B,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,EAAE,SAAS,kBAAkB;IAC7D,mCAAmC;IACnC,QAAQ,EAAE,IAAI,MAAM,EAAE,CAAC;IACvB,4CAA4C;IAC5C,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,EAAE,SAAS,kBAAkB;IAC5D,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,+FAA+F;IAC/F,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC5C,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,eAAe,EAAE,4BAA4B,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAC;CAC7E"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
-
import { ExpressLikeSchemaHandler } from '../types/apiDefinition.types';
|
3
|
-
import { Body, ContractDetails, HeadersObject, Method, ParamsObject, QueryObject, ResponsesObject } from '../types/contractDetails.types';
|
4
|
-
export type ContractDetailsExpressLikeSchemaHandler<SV extends AnySchemaValidator, 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>> = ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj>;
|
5
|
-
export type TypedHandler<SV extends AnySchemaValidator, ContractMethod extends Method, 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>> = {
|
6
|
-
_typedHandler: true;
|
7
|
-
contractDetails: ContractDetails<SV, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders>;
|
8
|
-
handlers: ContractDetailsExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj>[];
|
9
|
-
};
|
10
|
-
//# sourceMappingURL=typedHandler.types.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"typedHandler.types.d.ts","sourceRoot":"","sources":["../../../../src/http/types/typedHandler.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,IAAI,EACJ,eAAe,EACf,aAAa,EACb,MAAM,EACN,YAAY,EACZ,WAAW,EACX,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,MAAM,uCAAuC,CACjD,EAAE,SAAS,kBAAkB,EAC7B,CAAC,SAAS,YAAY,CAAC,EAAE,CAAC,EAC1B,UAAU,SAAS,eAAe,CAAC,EAAE,CAAC,EACtC,OAAO,SAAS,IAAI,CAAC,EAAE,CAAC,EACxB,QAAQ,SAAS,WAAW,CAAC,EAAE,CAAC,EAChC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACvC,wBAAwB,CAC1B,EAAE,EACF,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,CACV,CAAC;AAEF,MAAM,MAAM,YAAY,CACtB,EAAE,SAAS,kBAAkB,EAC7B,cAAc,SAAS,MAAM,EAC7B,IAAI,SAAS,IAAI,MAAM,EAAE,EACzB,CAAC,SAAS,YAAY,CAAC,EAAE,CAAC,EAC1B,UAAU,SAAS,eAAe,CAAC,EAAE,CAAC,EACtC,OAAO,SAAS,IAAI,CAAC,EAAE,CAAC,EACxB,QAAQ,SAAS,WAAW,CAAC,EAAE,CAAC,EAChC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACvC;IACF,aAAa,EAAE,IAAI,CAAC;IACpB,eAAe,EAAE,eAAe,CAC9B,EAAE,EACF,cAAc,EACd,IAAI,EACJ,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,CACX,CAAC;IAEF,QAAQ,EAAE,uCAAuC,CAC/C,EAAE,EACF,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,CACV,EAAE,CAAC;CACL,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
-
import { ParsedQs } from 'qs';
|
3
|
-
import { ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse, ForklaunchSendableData, ForklaunchStatusResponse } from '../types/apiDefinition.types';
|
4
|
-
import { ParamsDictionary } from '../types/contractDetails.types';
|
5
|
-
/**
|
6
|
-
* Enhances the Express-like `send` method with additional logic for response handling and validation.
|
7
|
-
*
|
8
|
-
* This function intercepts the `send` method to provide custom behavior, including response validation
|
9
|
-
* through the `parseResponse` middleware. If the response status is 404, it sends a "Not Found" message.
|
10
|
-
* If the response validation fails, it sends a parsing error message. Otherwise, it calls the original `send`
|
11
|
-
* method with the provided data.
|
12
|
-
*
|
13
|
-
* @template SV - The type of the schema validator used in the request.
|
14
|
-
* @template P - The type of the parameters dictionary used in the request.
|
15
|
-
* @template ResBodyMap - A record type mapping status codes to response body types.
|
16
|
-
* @template ReqBody - The type of the request body.
|
17
|
-
* @template ReqQuery - The type of the parsed query string.
|
18
|
-
* @template ReqHeaders - The type of the request headers.
|
19
|
-
* @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
|
20
|
-
* @template LocalsObj - The type of the locals object in the response.
|
21
|
-
*
|
22
|
-
* @param {unknown} instance - The context (typically `this`) in which the original `send` method is called.
|
23
|
-
* @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
|
24
|
-
* @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
|
25
|
-
* @param {Function} originalSend - The original `send` method from the response object, to be called after custom logic.
|
26
|
-
* @param {string | ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | null | undefined} data - The data to be sent as the response body.
|
27
|
-
* @param {boolean} shouldEnrich - A flag indicating whether the response should be sent immediately.
|
28
|
-
*
|
29
|
-
* @returns {unknown} The return value of the original `send` method, typically the response itself.
|
30
|
-
*/
|
31
|
-
export declare function enrichExpressLikeSend<SV extends AnySchemaValidator, P extends ParamsDictionary, ResBodyMap extends Record<number, unknown>, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>>(instance: unknown, req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, res: ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>, originalSend: ForklaunchStatusResponse<ForklaunchSendableData>['send'], data: ForklaunchSendableData, shouldEnrich: boolean): void;
|
32
|
-
//# sourceMappingURL=enrichExpressLikeSend.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"enrichExpressLikeSend.d.ts","sourceRoot":"","sources":["../../../../src/http/utils/enrichExpressLikeSend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,SAAS,kBAAkB,EAC7B,CAAC,SAAS,gBAAgB,EAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,QAAQ,SAAS,QAAQ,EACzB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEzC,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,EAC5D,GAAG,EAAE,kBAAkB,CACrB,UAAU,EACV,oBAAoB,GAAG,UAAU,EACjC,SAAS,CACV,EACD,YAAY,EAAE,wBAAwB,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,EACtE,IAAI,EAAE,sBAAsB,EAC5B,YAAY,EAAE,OAAO,QAyBtB"}
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import { parse } from '../middleware/response/parse.middleware';
|
2
|
-
/**
|
3
|
-
* Enhances the Express-like `send` method with additional logic for response handling and validation.
|
4
|
-
*
|
5
|
-
* This function intercepts the `send` method to provide custom behavior, including response validation
|
6
|
-
* through the `parseResponse` middleware. If the response status is 404, it sends a "Not Found" message.
|
7
|
-
* If the response validation fails, it sends a parsing error message. Otherwise, it calls the original `send`
|
8
|
-
* method with the provided data.
|
9
|
-
*
|
10
|
-
* @template SV - The type of the schema validator used in the request.
|
11
|
-
* @template P - The type of the parameters dictionary used in the request.
|
12
|
-
* @template ResBodyMap - A record type mapping status codes to response body types.
|
13
|
-
* @template ReqBody - The type of the request body.
|
14
|
-
* @template ReqQuery - The type of the parsed query string.
|
15
|
-
* @template ReqHeaders - The type of the request headers.
|
16
|
-
* @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
|
17
|
-
* @template LocalsObj - The type of the locals object in the response.
|
18
|
-
*
|
19
|
-
* @param {unknown} instance - The context (typically `this`) in which the original `send` method is called.
|
20
|
-
* @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
|
21
|
-
* @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
|
22
|
-
* @param {Function} originalSend - The original `send` method from the response object, to be called after custom logic.
|
23
|
-
* @param {string | ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | null | undefined} data - The data to be sent as the response body.
|
24
|
-
* @param {boolean} shouldEnrich - A flag indicating whether the response should be sent immediately.
|
25
|
-
*
|
26
|
-
* @returns {unknown} The return value of the original `send` method, typically the response itself.
|
27
|
-
*/
|
28
|
-
export function enrichExpressLikeSend(instance, req, res, originalSend, data, shouldEnrich) {
|
29
|
-
let parseErrorSent;
|
30
|
-
if (shouldEnrich) {
|
31
|
-
if (res.statusCode === 404) {
|
32
|
-
res.status(404);
|
33
|
-
originalSend.call(instance, 'Not Found');
|
34
|
-
}
|
35
|
-
parse(req, res, (err) => {
|
36
|
-
if (err) {
|
37
|
-
let errorString = err.message;
|
38
|
-
if (res.locals.errorMessage) {
|
39
|
-
errorString += `\n------------------\n${res.locals.errorMessage}`;
|
40
|
-
}
|
41
|
-
res.status(500);
|
42
|
-
originalSend.call(instance, errorString);
|
43
|
-
parseErrorSent = true;
|
44
|
-
}
|
45
|
-
});
|
46
|
-
}
|
47
|
-
if (!parseErrorSent) {
|
48
|
-
originalSend.call(instance, data);
|
49
|
-
}
|
50
|
-
}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Object-map of the HTTP Status Codes. Maps from the status code, to the
|
3
|
-
* textual name. The key is the HTTP Status Code number, and the resulting
|
4
|
-
* value will be the textual name for that Status Code.
|
5
|
-
*
|
6
|
-
* The comments for each item are taken from httpstatuses.com and the RFC-7231
|
7
|
-
* document.
|
8
|
-
*
|
9
|
-
* @see https://httpstatuses.com
|
10
|
-
* @see https://datatracker.ietf.org/doc/html/rfc7231
|
11
|
-
*/
|
12
|
-
export declare const HTTPStatuses: Readonly<{
|
13
|
-
[key: number]: string;
|
14
|
-
}>;
|
15
|
-
/**
|
16
|
-
* Numerical HTTP status code.
|
17
|
-
*/
|
18
|
-
export type StatusCode = keyof typeof HTTPStatuses;
|
19
|
-
/**
|
20
|
-
* Checks if the given numerical status code is in the known HTTP status codes
|
21
|
-
* list.
|
22
|
-
*
|
23
|
-
* @param code HTTP Status code
|
24
|
-
* @returns True if the code is a valid HTTP status code
|
25
|
-
*/
|
26
|
-
export declare const isValidStatusCode: (code: number) => boolean;
|
27
|
-
/**
|
28
|
-
* Checks if the given status code is in the informational range (1XX).
|
29
|
-
*
|
30
|
-
* @param code HTTP Status code
|
31
|
-
* @returns True if the code is in the "informational" range.
|
32
|
-
*/
|
33
|
-
export declare const isInformational: (code: StatusCode) => boolean;
|
34
|
-
/**
|
35
|
-
* Checks if the given status code is in the successful range (2XX).
|
36
|
-
*
|
37
|
-
* @param code HTTP Status code
|
38
|
-
* @returns True if the code is in the "success" range.
|
39
|
-
*/
|
40
|
-
export declare const isSuccessful: (code: StatusCode) => boolean;
|
41
|
-
/**
|
42
|
-
* Checks if the given status code is in the redirection range (3XX).
|
43
|
-
*
|
44
|
-
* @param code HTTP Status code
|
45
|
-
* @returns True if the code is in the "redirection" range.
|
46
|
-
*/
|
47
|
-
export declare const isRedirection: (code: StatusCode) => boolean;
|
48
|
-
/**
|
49
|
-
* Checks if the given status code is in the client error range (4XX).
|
50
|
-
*
|
51
|
-
* @param code HTTP Status code
|
52
|
-
* @returns True if the code is in the "client error" range.
|
53
|
-
*/
|
54
|
-
export declare const isClientError: (code: StatusCode) => boolean;
|
55
|
-
/**
|
56
|
-
* Checks if the given status code is in the server error range (5XX).
|
57
|
-
*
|
58
|
-
* @param code HTTP Status code
|
59
|
-
* @returns True if the code is in the "server error" range.
|
60
|
-
*/
|
61
|
-
export declare const isServerError: (code: StatusCode) => boolean;
|
62
|
-
/**
|
63
|
-
* Searches the list of HTTP statuses for a matching textual name to the one
|
64
|
-
* provided. If a match is found, then the numerical status code is returned,
|
65
|
-
* otherwise `null`.
|
66
|
-
*
|
67
|
-
* Internally, the parameter and the status names are normalized by lower-casing
|
68
|
-
* the strings and trimming space.
|
69
|
-
*
|
70
|
-
* @param status HTTP Status textual name
|
71
|
-
* @returns The numerical status code, or null if not found
|
72
|
-
*/
|
73
|
-
export declare const getCodeForStatus: (status: string) => null | StatusCode;
|
74
|
-
export default HTTPStatuses;
|
75
|
-
//# sourceMappingURL=httpStatusCodes.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"httpStatusCodes.d.ts","sourceRoot":"","sources":["../../../../src/http/utils/httpStatusCodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAmgCnD,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,YAAY,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,KAAG,OAC3B,CAAC;AAEvB;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SAAU,UAAU,KAAG,OACxB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAAU,UAAU,KAAG,OACrB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,UAAU,KAAG,OACtB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,UAAU,KAAG,OACtB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,UAAU,KAAG,OAAsB,CAAC;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,IAAI,GAAG,UAOxD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|