@forklaunch/core 0.2.6 → 0.2.7
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/jest.config.d.ts.map +1 -1
- package/lib/jest.config.js +0 -2
- package/lib/src/http/guards/isForklaunchRouter.d.ts +4 -0
- package/lib/src/http/guards/isForklaunchRouter.d.ts.map +1 -0
- package/lib/src/http/guards/isForklaunchRouter.js +7 -0
- package/lib/src/http/guards/isTypedHandler.d.ts +1 -1
- package/lib/src/http/guards/isTypedHandler.d.ts.map +1 -1
- package/lib/src/http/handlers/typedAuthHandler.d.ts +5 -0
- package/lib/src/http/handlers/typedAuthHandler.d.ts.map +1 -0
- package/lib/src/http/handlers/typedAuthHandler.js +3 -0
- package/lib/src/http/handlers/typedHandler.d.ts +0 -6
- package/lib/src/http/handlers/typedHandler.d.ts.map +1 -1
- package/lib/src/http/index.d.ts +2 -0
- package/lib/src/http/index.d.ts.map +1 -1
- package/lib/src/http/index.js +2 -0
- package/lib/src/http/middleware/request/auth.middleware.d.ts +3 -18
- package/lib/src/http/middleware/request/auth.middleware.d.ts.map +1 -1
- package/lib/src/http/middleware/request/auth.middleware.js +104 -69
- package/lib/src/http/openApiV3Generator/openApiV3Generator.js +1 -1
- package/lib/src/http/router/expressLikeRouter.d.ts.map +1 -1
- package/lib/src/http/router/expressLikeRouter.js +4 -23
- package/lib/src/http/types/apiDefinition.types.d.ts +36 -13
- package/lib/src/http/types/apiDefinition.types.d.ts.map +1 -1
- package/lib/src/http/types/contractDetails.types.d.ts +53 -11
- package/lib/src/http/types/contractDetails.types.d.ts.map +1 -1
- package/lib/src/http/types/expressLikeRouter.types.d.ts +1 -1
- package/lib/src/http/types/expressLikeRouter.types.d.ts.map +1 -1
- package/lib/src/http/types/typedHandler.types.d.ts +10 -0
- package/lib/src/http/types/typedHandler.types.d.ts.map +1 -0
- package/lib/tests/expressLikeRouterInstantiation.test.js +47 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/LICENSE +0 -21
- package/lib/dist/cache/index.d.ts +0 -4
- package/lib/dist/cache/index.d.ts.map +0 -1
- package/lib/dist/cache/index.js +0 -3
- package/lib/dist/cache/interfaces/ttlCache.interface.d.ts +0 -2
- package/lib/dist/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
- package/lib/dist/cache/redisTtlCache.d.ts +0 -353
- package/lib/dist/cache/redisTtlCache.d.ts.map +0 -1
- package/lib/dist/cache/redisTtlCache.js +0 -98
- package/lib/dist/cache/types/ttlCacheRecord.types.d.ts +0 -2
- package/lib/dist/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
- package/lib/dist/cache/types/ttlCacheRecord.types.js +0 -1
- package/lib/dist/controllers/index.d.ts +0 -2
- package/lib/dist/controllers/index.d.ts.map +0 -1
- package/lib/dist/controllers/index.js +0 -1
- package/lib/dist/controllers/interfaces/controller.interface.d.ts +0 -2
- package/lib/dist/controllers/interfaces/controller.interface.d.ts.map +0 -1
- package/lib/dist/controllers/interfaces/controller.interface.js +0 -1
- package/lib/dist/database/index.d.ts +0 -2
- package/lib/dist/database/index.d.ts.map +0 -1
- package/lib/dist/database/index.js +0 -1
- package/lib/dist/database/mikro/models/entities/base.entity.d.ts +0 -26
- package/lib/dist/database/mikro/models/entities/base.entity.d.ts.map +0 -1
- package/lib/dist/database/mikro/models/entities/base.entity.js +0 -46
- package/lib/dist/entityMapper/index.d.ts +0 -3
- package/lib/dist/entityMapper/index.d.ts.map +0 -1
- package/lib/dist/entityMapper/index.js +0 -2
- package/lib/dist/entityMapper/interfaces/entityMapper.interface.d.ts +0 -2
- package/lib/dist/entityMapper/interfaces/entityMapper.interface.d.ts.map +0 -1
- package/lib/dist/entityMapper/interfaces/entityMapper.interface.js +0 -1
- package/lib/dist/entityMapper/models/baseEntityMapper.model.d.ts +0 -63
- package/lib/dist/entityMapper/models/baseEntityMapper.model.d.ts.map +0 -1
- package/lib/dist/entityMapper/models/baseEntityMapper.model.js +0 -75
- package/lib/dist/entityMapper/models/requestEntityMapper.model.d.ts +0 -58
- package/lib/dist/entityMapper/models/requestEntityMapper.model.d.ts.map +0 -1
- package/lib/dist/entityMapper/models/requestEntityMapper.model.js +0 -70
- package/lib/dist/entityMapper/models/responseEntityMapper.model.d.ts +0 -56
- package/lib/dist/entityMapper/models/responseEntityMapper.model.d.ts.map +0 -1
- package/lib/dist/entityMapper/models/responseEntityMapper.model.js +0 -65
- package/lib/dist/entityMapper/types/entityMapper.types.d.ts +0 -2
- package/lib/dist/entityMapper/types/entityMapper.types.d.ts.map +0 -1
- package/lib/dist/entityMapper/types/entityMapper.types.js +0 -1
- package/lib/dist/http/guards/isHttpContractDetails.d.ts +0 -5
- package/lib/dist/http/guards/isHttpContractDetails.d.ts.map +0 -1
- package/lib/dist/http/guards/isHttpContractDetails.js +0 -6
- package/lib/dist/http/guards/isResponseShape.d.ts +0 -2
- package/lib/dist/http/guards/isResponseShape.d.ts.map +0 -1
- package/lib/dist/http/guards/isResponseShape.js +0 -7
- package/lib/dist/http/index.d.ts +0 -6
- package/lib/dist/http/index.d.ts.map +0 -1
- package/lib/dist/http/index.js +0 -5
- package/lib/dist/http/interfaces/expressLikeApplication.interface.d.ts +0 -12
- package/lib/dist/http/interfaces/expressLikeApplication.interface.d.ts.map +0 -1
- package/lib/dist/http/interfaces/expressLikeApplication.interface.js +0 -14
- package/lib/dist/http/interfaces/expressLikeRouter.interface.d.ts +0 -103
- package/lib/dist/http/interfaces/expressLikeRouter.interface.d.ts.map +0 -1
- package/lib/dist/http/interfaces/expressLikeRouter.interface.js +0 -336
- package/lib/dist/http/interfaces/index.d.ts +0 -3
- package/lib/dist/http/interfaces/index.d.ts.map +0 -1
- package/lib/dist/http/interfaces/index.js +0 -2
- package/lib/dist/http/middleware/index.d.ts +0 -3
- package/lib/dist/http/middleware/index.d.ts.map +0 -1
- package/lib/dist/http/middleware/index.js +0 -2
- package/lib/dist/http/middleware/request.middleware.d.ts +0 -69
- package/lib/dist/http/middleware/request.middleware.d.ts.map +0 -1
- package/lib/dist/http/middleware/request.middleware.js +0 -210
- package/lib/dist/http/middleware/response.middleware.d.ts +0 -27
- package/lib/dist/http/middleware/response.middleware.d.ts.map +0 -1
- package/lib/dist/http/middleware/response.middleware.js +0 -52
- package/lib/dist/http/openApiV3Generator/index.d.ts +0 -2
- package/lib/dist/http/openApiV3Generator/index.d.ts.map +0 -1
- package/lib/dist/http/openApiV3Generator/index.js +0 -1
- package/lib/dist/http/openApiV3Generator/openApiV3Generator.d.ts +0 -11
- package/lib/dist/http/openApiV3Generator/openApiV3Generator.d.ts.map +0 -1
- package/lib/dist/http/openApiV3Generator/openApiV3Generator.js +0 -167
- package/lib/dist/http/types/apiDefinition.types.d.ts +0 -2
- package/lib/dist/http/types/apiDefinition.types.d.ts.map +0 -1
- package/lib/dist/http/types/apiDefinition.types.js +0 -1
- package/lib/dist/http/types/contractDetails.types.d.ts +0 -2
- package/lib/dist/http/types/contractDetails.types.d.ts.map +0 -1
- package/lib/dist/http/types/contractDetails.types.js +0 -1
- package/lib/dist/http/types/index.d.ts +0 -4
- package/lib/dist/http/types/index.d.ts.map +0 -1
- package/lib/dist/http/types/index.js +0 -3
- package/lib/dist/http/types/router.types.d.ts +0 -2
- package/lib/dist/http/types/router.types.d.ts.map +0 -1
- package/lib/dist/http/types/router.types.js +0 -1
- package/lib/dist/http/utils/enrichExpressLikeSend.d.ts +0 -28
- package/lib/dist/http/utils/enrichExpressLikeSend.d.ts.map +0 -1
- package/lib/dist/http/utils/enrichExpressLikeSend.js +0 -50
- package/lib/dist/http/utils/httpStatusCodes.d.ts +0 -986
- package/lib/dist/http/utils/httpStatusCodes.d.ts.map +0 -1
- package/lib/dist/http/utils/httpStatusCodes.js +0 -1039
- package/lib/dist/http/utils/index.d.ts +0 -3
- package/lib/dist/http/utils/index.d.ts.map +0 -1
- package/lib/dist/http/utils/index.js +0 -2
- package/lib/dist/index.d.ts +0 -7
- package/lib/dist/index.d.ts.map +0 -1
- package/lib/dist/index.js +0 -6
- package/lib/dist/jest.config.d.ts +0 -15
- package/lib/dist/jest.config.d.ts.map +0 -1
- package/lib/dist/jest.config.js +0 -21
- package/lib/dist/lib/index.d.ts +0 -7
- package/lib/dist/lib/index.d.ts.map +0 -1
- package/lib/dist/lib/index.js +0 -6
- package/lib/dist/lib/jest.config.d.ts +0 -15
- package/lib/dist/lib/jest.config.d.ts.map +0 -1
- package/lib/dist/lib/jest.config.js +0 -21
- package/lib/dist/lib/src/cache/index.d.ts +0 -4
- package/lib/dist/lib/src/cache/index.d.ts.map +0 -1
- package/lib/dist/lib/src/cache/index.js +0 -3
- package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.d.ts +0 -2
- package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
- package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.js +0 -1
- package/lib/dist/lib/src/cache/redisTtlCache.d.ts +0 -353
- package/lib/dist/lib/src/cache/redisTtlCache.d.ts.map +0 -1
- package/lib/dist/lib/src/cache/redisTtlCache.js +0 -98
- package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.d.ts +0 -2
- package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
- package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.js +0 -1
- package/lib/dist/lib/src/controllers/index.d.ts +0 -2
- package/lib/dist/lib/src/controllers/index.d.ts.map +0 -1
- package/lib/dist/lib/src/controllers/index.js +0 -1
- package/lib/dist/lib/src/controllers/interfaces/controller.interface.d.ts +0 -2
- package/lib/dist/lib/src/controllers/interfaces/controller.interface.d.ts.map +0 -1
- package/lib/dist/lib/src/controllers/interfaces/controller.interface.js +0 -1
- package/lib/dist/lib/src/database/index.d.ts +0 -2
- package/lib/dist/lib/src/database/index.d.ts.map +0 -1
- package/lib/dist/lib/src/database/index.js +0 -1
- package/lib/dist/lib/src/database/mikro/models/entities/base.entity.d.ts +0 -26
- package/lib/dist/lib/src/database/mikro/models/entities/base.entity.d.ts.map +0 -1
- package/lib/dist/lib/src/database/mikro/models/entities/base.entity.js +0 -46
- package/lib/dist/lib/src/domainMapper/index.d.ts +0 -3
- package/lib/dist/lib/src/domainMapper/index.d.ts.map +0 -1
- package/lib/dist/lib/src/domainMapper/index.js +0 -2
- package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts +0 -2
- package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
- package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.js +0 -1
- package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.d.ts +0 -63
- package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.d.ts.map +0 -1
- package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.js +0 -75
- package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.d.ts +0 -58
- package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.d.ts.map +0 -1
- package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.js +0 -70
- package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.d.ts +0 -56
- package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.d.ts.map +0 -1
- package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.js +0 -65
- package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.d.ts +0 -2
- package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.d.ts.map +0 -1
- package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.js +0 -1
- package/lib/dist/lib/src/dtoMapper/index.d.ts +0 -3
- package/lib/dist/lib/src/dtoMapper/index.d.ts.map +0 -1
- package/lib/dist/lib/src/dtoMapper/index.js +0 -2
- package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts +0 -2
- package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
- package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.js +0 -1
- package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts +0 -63
- package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts.map +0 -1
- package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.js +0 -75
- package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts +0 -58
- package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts.map +0 -1
- package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.js +0 -70
- package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts +0 -56
- package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts.map +0 -1
- package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.js +0 -65
- package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.d.ts +0 -2
- package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.d.ts.map +0 -1
- package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.js +0 -1
- package/lib/dist/lib/src/http/application/expressLikeApplication.d.ts +0 -18
- package/lib/dist/lib/src/http/application/expressLikeApplication.d.ts.map +0 -1
- package/lib/dist/lib/src/http/application/expressLikeApplication.js +0 -20
- package/lib/dist/lib/src/http/guards/isHttpContractDetails.d.ts +0 -5
- package/lib/dist/lib/src/http/guards/isHttpContractDetails.d.ts.map +0 -1
- package/lib/dist/lib/src/http/guards/isHttpContractDetails.js +0 -6
- package/lib/dist/lib/src/http/guards/isResponseShape.d.ts +0 -2
- package/lib/dist/lib/src/http/guards/isResponseShape.d.ts.map +0 -1
- package/lib/dist/lib/src/http/guards/isResponseShape.js +0 -7
- package/lib/dist/lib/src/http/handler/typedHandler.d.ts +0 -21
- package/lib/dist/lib/src/http/handler/typedHandler.d.ts.map +0 -1
- package/lib/dist/lib/src/http/handler/typedHandler.js +0 -25
- package/lib/dist/lib/src/http/index.d.ts +0 -11
- package/lib/dist/lib/src/http/index.d.ts.map +0 -1
- package/lib/dist/lib/src/http/index.js +0 -10
- package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.d.ts +0 -12
- package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.d.ts.map +0 -1
- package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.js +0 -14
- package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.d.ts +0 -2
- package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.d.ts.map +0 -1
- package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.js +0 -1
- package/lib/dist/lib/src/http/interfaces/index.d.ts +0 -3
- package/lib/dist/lib/src/http/interfaces/index.d.ts.map +0 -1
- package/lib/dist/lib/src/http/interfaces/index.js +0 -2
- package/lib/dist/lib/src/http/middleware/index.d.ts +0 -3
- package/lib/dist/lib/src/http/middleware/index.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/index.js +0 -2
- package/lib/dist/lib/src/http/middleware/request/auth.middleware.d.ts +0 -27
- package/lib/dist/lib/src/http/middleware/request/auth.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/request/auth.middleware.js +0 -107
- package/lib/dist/lib/src/http/middleware/request/cors.middleware.d.ts +0 -9
- package/lib/dist/lib/src/http/middleware/request/cors.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/request/cors.middleware.js +0 -15
- package/lib/dist/lib/src/http/middleware/request/createContext.middleware.d.ts +0 -12
- package/lib/dist/lib/src/http/middleware/request/createContext.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/request/createContext.middleware.js +0 -26
- package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.d.ts +0 -12
- package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.js +0 -19
- package/lib/dist/lib/src/http/middleware/request/parse.middleware.d.ts +0 -13
- package/lib/dist/lib/src/http/middleware/request/parse.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/request/parse.middleware.js +0 -43
- package/lib/dist/lib/src/http/middleware/request.middleware.d.ts +0 -69
- package/lib/dist/lib/src/http/middleware/request.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/request.middleware.js +0 -210
- package/lib/dist/lib/src/http/middleware/response/parse.middleware.d.ts +0 -27
- package/lib/dist/lib/src/http/middleware/response/parse.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/response/parse.middleware.js +0 -52
- package/lib/dist/lib/src/http/middleware/response.middleware.d.ts +0 -27
- package/lib/dist/lib/src/http/middleware/response.middleware.d.ts.map +0 -1
- package/lib/dist/lib/src/http/middleware/response.middleware.js +0 -52
- package/lib/dist/lib/src/http/openApiV3Generator/index.d.ts +0 -2
- package/lib/dist/lib/src/http/openApiV3Generator/index.d.ts.map +0 -1
- package/lib/dist/lib/src/http/openApiV3Generator/index.js +0 -1
- package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts +0 -11
- package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts.map +0 -1
- package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.js +0 -167
- package/lib/dist/lib/src/http/router/expressLikeRouter.d.ts +0 -89
- package/lib/dist/lib/src/http/router/expressLikeRouter.d.ts.map +0 -1
- package/lib/dist/lib/src/http/router/expressLikeRouter.js +0 -322
- package/lib/dist/lib/src/http/types/apiDefinition.types.d.ts +0 -2
- package/lib/dist/lib/src/http/types/apiDefinition.types.d.ts.map +0 -1
- package/lib/dist/lib/src/http/types/apiDefinition.types.js +0 -1
- package/lib/dist/lib/src/http/types/contractDetails.types.d.ts +0 -2
- package/lib/dist/lib/src/http/types/contractDetails.types.d.ts.map +0 -1
- package/lib/dist/lib/src/http/types/contractDetails.types.js +0 -1
- package/lib/dist/lib/src/http/types/index.d.ts +0 -4
- package/lib/dist/lib/src/http/types/index.d.ts.map +0 -1
- package/lib/dist/lib/src/http/types/index.js +0 -3
- package/lib/dist/lib/src/http/types/router.types.d.ts +0 -2
- package/lib/dist/lib/src/http/types/router.types.d.ts.map +0 -1
- package/lib/dist/lib/src/http/types/router.types.js +0 -1
- package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.d.ts +0 -28
- package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.d.ts.map +0 -1
- package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.js +0 -50
- package/lib/dist/lib/src/http/utils/httpStatusCodes.d.ts +0 -986
- package/lib/dist/lib/src/http/utils/httpStatusCodes.d.ts.map +0 -1
- package/lib/dist/lib/src/http/utils/httpStatusCodes.js +0 -1039
- package/lib/dist/lib/src/http/utils/index.d.ts +0 -3
- package/lib/dist/lib/src/http/utils/index.d.ts.map +0 -1
- package/lib/dist/lib/src/http/utils/index.js +0 -2
- package/lib/dist/lib/src/services/index.d.ts +0 -2
- package/lib/dist/lib/src/services/index.d.ts.map +0 -1
- package/lib/dist/lib/src/services/index.js +0 -1
- package/lib/dist/lib/src/services/interfaces/baseService.d.ts +0 -2
- package/lib/dist/lib/src/services/interfaces/baseService.d.ts.map +0 -1
- package/lib/dist/lib/src/services/interfaces/baseService.js +0 -1
- package/lib/dist/lib/tests/dtoMapper.test.d.ts +0 -2
- package/lib/dist/lib/tests/dtoMapper.test.d.ts.map +0 -1
- package/lib/dist/lib/tests/dtoMapper.test.js +0 -172
- package/lib/dist/lib/tests/entityMapper.test.d.ts +0 -2
- package/lib/dist/lib/tests/entityMapper.test.d.ts.map +0 -1
- package/lib/dist/lib/tests/entityMapper.test.js +0 -172
- package/lib/dist/lib/tests/expressLikeRouter.test.d.ts +0 -2
- package/lib/dist/lib/tests/expressLikeRouter.test.d.ts.map +0 -1
- package/lib/dist/lib/tests/expressLikeRouter.test.js +0 -3
- package/lib/dist/lib/tests/http.middleware.test.d.ts +0 -2
- package/lib/dist/lib/tests/http.middleware.test.d.ts.map +0 -1
- package/lib/dist/lib/tests/http.middleware.test.js +0 -95
- package/lib/dist/lib/tests/openApiV3Generator.test.d.ts +0 -2
- package/lib/dist/lib/tests/openApiV3Generator.test.d.ts.map +0 -1
- package/lib/dist/lib/tests/openApiV3Generator.test.js +0 -66
- package/lib/dist/lib/tests/redisTtlCache.test.d.ts +0 -2
- package/lib/dist/lib/tests/redisTtlCache.test.d.ts.map +0 -1
- package/lib/dist/lib/tests/redisTtlCache.test.js +0 -49
- package/lib/dist/lib/tests/typedHandler.test.d.ts +0 -2
- package/lib/dist/lib/tests/typedHandler.test.d.ts.map +0 -1
- package/lib/dist/lib/tests/typedHandler.test.js +0 -3
- package/lib/dist/lib/vitest.config.d.ts +0 -3
- package/lib/dist/lib/vitest.config.d.ts.map +0 -1
- package/lib/dist/lib/vitest.config.js +0 -7
- package/lib/dist/services/index.d.ts +0 -2
- package/lib/dist/services/index.d.ts.map +0 -1
- package/lib/dist/services/index.js +0 -1
- package/lib/dist/services/interfaces/baseService.d.ts +0 -2
- package/lib/dist/services/interfaces/baseService.d.ts.map +0 -1
- package/lib/dist/services/interfaces/baseService.js +0 -1
- package/lib/dist/tests/entityMapper.test.d.ts +0 -2
- package/lib/dist/tests/entityMapper.test.d.ts.map +0 -1
- package/lib/dist/tests/entityMapper.test.js +0 -171
- package/lib/dist/tests/http.middleware.test.d.ts +0 -2
- package/lib/dist/tests/http.middleware.test.d.ts.map +0 -1
- package/lib/dist/tests/http.middleware.test.js +0 -93
- package/lib/dist/tests/openApiV3Generator.test.d.ts +0 -2
- package/lib/dist/tests/openApiV3Generator.test.d.ts.map +0 -1
- package/lib/dist/tests/openApiV3Generator.test.js +0 -66
- package/lib/dist/tests/redisTtlCache.test.d.ts +0 -2
- package/lib/dist/tests/redisTtlCache.test.d.ts.map +0 -1
- package/lib/dist/tests/redisTtlCache.test.js +0 -49
- package/lib/index.d.ts +0 -7
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -7
- package/lib/src/domainMapper/index.d.ts +0 -3
- package/lib/src/domainMapper/index.d.ts.map +0 -1
- package/lib/src/domainMapper/index.js +0 -2
- package/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts +0 -18
- package/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
- package/lib/src/domainMapper/interfaces/dtoMapper.interface.js +0 -1
- package/lib/src/domainMapper/models/baseDtoMapper.model.d.ts +0 -72
- package/lib/src/domainMapper/models/baseDtoMapper.model.d.ts.map +0 -1
- package/lib/src/domainMapper/models/baseDtoMapper.model.js +0 -75
- package/lib/src/domainMapper/models/requestDtoMapper.model.d.ts +0 -68
- package/lib/src/domainMapper/models/requestDtoMapper.model.d.ts.map +0 -1
- package/lib/src/domainMapper/models/requestDtoMapper.model.js +0 -70
- package/lib/src/domainMapper/models/responseDtoMapper.model.d.ts +0 -67
- package/lib/src/domainMapper/models/responseDtoMapper.model.d.ts.map +0 -1
- package/lib/src/domainMapper/models/responseDtoMapper.model.js +0 -65
- package/lib/src/domainMapper/types/dtoMapper.types.d.ts +0 -9
- package/lib/src/domainMapper/types/dtoMapper.types.d.ts.map +0 -1
- package/lib/src/domainMapper/types/dtoMapper.types.js +0 -1
- package/lib/src/http/handler/typedHandler.d.ts +0 -24
- package/lib/src/http/handler/typedHandler.d.ts.map +0 -1
- package/lib/src/http/handler/typedHandler.js +0 -25
- package/lib/src/http/interfaces/expressLikeApplication.interface.d.ts +0 -16
- package/lib/src/http/interfaces/expressLikeApplication.interface.d.ts.map +0 -1
- package/lib/src/http/interfaces/expressLikeApplication.interface.js +0 -14
- package/lib/src/http/interfaces/index.d.ts +0 -3
- package/lib/src/http/interfaces/index.d.ts.map +0 -1
- package/lib/src/http/interfaces/index.js +0 -2
- package/lib/src/http/middleware/index.d.ts +0 -3
- package/lib/src/http/middleware/index.d.ts.map +0 -1
- package/lib/src/http/middleware/index.js +0 -2
- package/lib/src/http/middleware/request.middleware.d.ts +0 -73
- package/lib/src/http/middleware/request.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request.middleware.js +0 -210
- package/lib/src/http/middleware/response.middleware.d.ts +0 -31
- package/lib/src/http/middleware/response.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/response.middleware.js +0 -52
- package/lib/src/http/openApiV3Generator/index.d.ts +0 -2
- package/lib/src/http/openApiV3Generator/index.d.ts.map +0 -1
- package/lib/src/http/openApiV3Generator/index.js +0 -1
- package/lib/src/http/types/index.d.ts +0 -4
- package/lib/src/http/types/index.d.ts.map +0 -1
- package/lib/src/http/types/index.js +0 -3
- package/lib/src/http/utils/index.d.ts +0 -3
- package/lib/src/http/utils/index.d.ts.map +0 -1
- package/lib/src/http/utils/index.js +0 -2
- package/lib/tests/entityMapper.test.d.ts +0 -2
- package/lib/tests/entityMapper.test.d.ts.map +0 -1
- package/lib/tests/entityMapper.test.js +0 -168
- package/lib/tests/expressLikeRouter.test.d.ts +0 -2
- package/lib/tests/expressLikeRouter.test.d.ts.map +0 -1
- package/lib/tests/expressLikeRouter.test.js +0 -3
- /package/lib/{dist/cache/interfaces/ttlCache.interface.js → src/http/types/typedHandler.types.js} +0 -0
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Router class that sets up routes and middleware for an Express router, for use with controller/routes pattern.
|
|
3
|
-
*
|
|
4
|
-
* @template SV - A type that extends AnySchemaValidator.
|
|
5
|
-
* @template contractDetails - The contract details.
|
|
6
|
-
* @template functions - The handler middlware and function.
|
|
7
|
-
*/
|
|
8
|
-
export function typedHandler<SV, contractDetails, functions>(_schemaValidator: any, _method: any, contractDetails: any, ...functions: any[]): TypedHandler;
|
|
9
|
-
/**
|
|
10
|
-
* A class that represents an Express-like router.
|
|
11
|
-
*/
|
|
12
|
-
export class ForklaunchExpressLikeRouter {
|
|
13
|
-
constructor(basePath: any, schemaValidator: any, internal: any);
|
|
14
|
-
schemaValidator: any;
|
|
15
|
-
internal: any;
|
|
16
|
-
routes: any[];
|
|
17
|
-
basePath: any;
|
|
18
|
-
/**
|
|
19
|
-
* Registers middleware to the router.
|
|
20
|
-
*
|
|
21
|
-
* @param {...unknown[]} args - The middleware to register.
|
|
22
|
-
* @returns {this} - The router instance.
|
|
23
|
-
*/
|
|
24
|
-
use(...args: unknown[][]): this;
|
|
25
|
-
/**
|
|
26
|
-
* Registers a GET route with the specified contract details and handler functions.
|
|
27
|
-
*
|
|
28
|
-
* @template P - The type of request parameters.
|
|
29
|
-
* @template ResBodyMap - The type of response body.
|
|
30
|
-
* @template ReqBody - The type of request body.
|
|
31
|
-
* @template ReqQuery - The type of request query.
|
|
32
|
-
* @template LocalsObj - The type of local variables.
|
|
33
|
-
* @param {string} path - The path for the route.
|
|
34
|
-
* @param {PathParamHttpContractDetails<SV, P, ResBodyMap, ReqQuery>} contractDetails - The contract details.
|
|
35
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
36
|
-
* @returns {ExpressRouter} - The Express router.
|
|
37
|
-
*/
|
|
38
|
-
get<P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>(path: string, contractDetailsOrTypedHandler: any, ...functions: SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[][]): ExpressRouter;
|
|
39
|
-
/**
|
|
40
|
-
* Registers a POST route with the specified contract details and handler functions.
|
|
41
|
-
*
|
|
42
|
-
* @template P - The type of request parameters.
|
|
43
|
-
* @template ResBodyMap - The type of response body.
|
|
44
|
-
* @template ReqBody - The type of request body.
|
|
45
|
-
* @template ReqQuery - The type of request query.
|
|
46
|
-
* @template LocalsObj - The type of local variables.
|
|
47
|
-
* @param {string} path - The path for the route.
|
|
48
|
-
* @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
|
|
49
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
50
|
-
* @returns {ExpressRouter} - The Express router.
|
|
51
|
-
*/
|
|
52
|
-
post<P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>(path: string, contractDetailsOrTypedHandler: any, ...functions: SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[][]): ExpressRouter;
|
|
53
|
-
/**
|
|
54
|
-
* Registers a PUT route with the specified contract details and handler functions.
|
|
55
|
-
*
|
|
56
|
-
* @template P - The type of request parameters.
|
|
57
|
-
* @template ResBodyMap - The type of response body.
|
|
58
|
-
* @template ReqBody - The type of request body.
|
|
59
|
-
* @template ReqQuery - The type of request query.
|
|
60
|
-
* @template LocalsObj - The type of local variables.
|
|
61
|
-
* @param {string} path - The path for the route.
|
|
62
|
-
* @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
|
|
63
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
64
|
-
* @returns {ExpressRouter} - The Express router.
|
|
65
|
-
*/
|
|
66
|
-
put<P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>(path: string, contractDetailsOrTypedHandler: any, ...functions: SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[][]): ExpressRouter;
|
|
67
|
-
/**
|
|
68
|
-
* Registers a PATCH route with the specified contract details and handler functions.
|
|
69
|
-
*
|
|
70
|
-
* @template P - The type of request parameters.
|
|
71
|
-
* @template ResBodyMap - The type of response body.
|
|
72
|
-
* @template ReqBody - The type of request body.
|
|
73
|
-
* @template ReqQuery - The type of request query.
|
|
74
|
-
* @template LocalsObj - The type of local variables.
|
|
75
|
-
* @param {string} path - The path for the route.
|
|
76
|
-
* @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
|
|
77
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
78
|
-
* @returns {ExpressRouter} - The Express router.
|
|
79
|
-
*/
|
|
80
|
-
patch<P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>(path: string, contractDetailsOrTypedHandler: any, ...functions: SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[][]): ExpressRouter;
|
|
81
|
-
/**
|
|
82
|
-
* Registers a DELETE route with the specified contract details and handler functions.
|
|
83
|
-
*
|
|
84
|
-
* @template P - The type of request parameters.
|
|
85
|
-
* @template ResBodyMap - The type of response body.
|
|
86
|
-
* @template ReqBody - The type of request body.
|
|
87
|
-
* @template ReqQuery - The type of request query.
|
|
88
|
-
* @template LocalsObj - The type of local variables.
|
|
89
|
-
* @param {string} path - The path for the route.
|
|
90
|
-
* @param {PathParamHttpContractDetails<SV, P, ResBodyMap, ReqQuery>} contractDetails - The contract details.
|
|
91
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
92
|
-
* @returns {ExpressRouter} - The Express router.
|
|
93
|
-
*/
|
|
94
|
-
delete<P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>(path: string, contractDetailsOrTypedHandler: any, ...functions: SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[][]): ExpressRouter;
|
|
95
|
-
#private;
|
|
96
|
-
}
|
|
97
|
-
declare class TypedHandler {
|
|
98
|
-
constructor(contractDetails: any, functions: any);
|
|
99
|
-
contractDetails: any;
|
|
100
|
-
functions: any;
|
|
101
|
-
}
|
|
102
|
-
export {};
|
|
103
|
-
//# sourceMappingURL=expressLikeRouter.interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expressLikeRouter.interface.d.ts","sourceRoot":"","sources":["../../../../dist/http/interfaces/expressLikeRouter.interface.js"],"names":[],"mappings":"AAsUA;;;;;;GAMG;AACH,6BAJa,EAAE,4HAMd;AA7UD;;GAEG;AACH;IAKI,gEAMC;IAVD,qBAAgB;IAChB,cAAS;IACT,cAAY;IACZ,cAAS;IAyFT;;;;;OAKG;IACH,aAHc,OAAO,EAAE,EAAA,GACV,IAAI,CAKhB;IAwHD;;;;;;;;;;;;OAYG;IACH,IAVa,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,QACX,MAAM,oDAEH,uBAAuB,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAA,GAC3E,aAAa,CAMzB;IACD;;;;;;;;;;;;OAYG;IACH,KAVa,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,QACX,MAAM,oDAEH,uBAAuB,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAA,GAC3E,aAAa,CAMzB;IACD;;;;;;;;;;;;OAYG;IACH,IAVa,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,QACX,MAAM,oDAEH,uBAAuB,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAA,GAC3E,aAAa,CAMzB;IACD;;;;;;;;;;;;OAYG;IACH,MAVa,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,QACX,MAAM,oDAEH,uBAAuB,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAA,GAC3E,aAAa,CAMzB;IACD;;;;;;;;;;;;OAYG;IACH,OAVa,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,QACX,MAAM,oDAEH,uBAAuB,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAA,GAC3E,aAAa,CAMzB;;CACJ;AACD;IAGI,kDAGC;IALD,qBAAgB;IAChB,eAAU;CAKb"}
|
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { isHttpContractDetails } from '../guards/isHttpContractDetails';
|
|
2
|
-
import { corsMiddleware, createRequestContext, enrichRequestDetails, parseRequest } from '../middleware';
|
|
3
|
-
/**
|
|
4
|
-
* A class that represents an Express-like router.
|
|
5
|
-
*/
|
|
6
|
-
export class ForklaunchExpressLikeRouter {
|
|
7
|
-
schemaValidator;
|
|
8
|
-
internal;
|
|
9
|
-
routes = [];
|
|
10
|
-
basePath;
|
|
11
|
-
constructor(basePath, schemaValidator, internal) {
|
|
12
|
-
this.schemaValidator = schemaValidator;
|
|
13
|
-
this.internal = internal;
|
|
14
|
-
this.basePath = basePath;
|
|
15
|
-
this.internal.use(createRequestContext(this.schemaValidator));
|
|
16
|
-
this.internal.use(corsMiddleware);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Resolves middlewares based on the contract details.
|
|
20
|
-
*
|
|
21
|
-
* @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
|
|
22
|
-
* @returns {MiddlewareHandler<SV>[]} - The resolved middlewares.
|
|
23
|
-
*/
|
|
24
|
-
#resolveMiddlewares(contractDetails, requestSchema, responseSchemas) {
|
|
25
|
-
return [
|
|
26
|
-
enrichRequestDetails(contractDetails, requestSchema, responseSchemas),
|
|
27
|
-
parseRequest
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Parses and runs the controller function with error handling.
|
|
32
|
-
*
|
|
33
|
-
* @template P - The type of request parameters.
|
|
34
|
-
* @template ResBodyMap - The type of response body.
|
|
35
|
-
* @template ReqBody - The type of request body.
|
|
36
|
-
* @template ReqQuery - The type of request query.
|
|
37
|
-
* @template LocalsObj - The type of local variables.
|
|
38
|
-
* @template StatusCode - The type of status code.
|
|
39
|
-
* @param {MiddlewareHandler<SV, P, ResBodyMap | string, ReqBody, ReqQuery, LocalsObj, StatusCode>} requestHandler - The request handler.
|
|
40
|
-
* @returns {ExpressMiddlewareHandler} - The Express request handler.
|
|
41
|
-
*/
|
|
42
|
-
#parseAndRunControllerFunction(requestHandler) {
|
|
43
|
-
return async (req, res, next) => {
|
|
44
|
-
if (!requestHandler) {
|
|
45
|
-
throw new Error('Controller function is not defined');
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
await requestHandler(req, res, next);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
next?.(error);
|
|
52
|
-
console.error(error);
|
|
53
|
-
if (!res.headersSent) {
|
|
54
|
-
res.status(500).send('Internal Server Error');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Extracts the controller function from the provided functions.
|
|
61
|
-
*
|
|
62
|
-
* @template P - The type of request parameters.
|
|
63
|
-
* @template ResBodyMap - The type of response body.
|
|
64
|
-
* @template ReqBody - The type of request body.
|
|
65
|
-
* @template ReqQuery - The type of request query.
|
|
66
|
-
* @template LocalsObj - The type of local variables.
|
|
67
|
-
* @param {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The provided functions.
|
|
68
|
-
* @returns {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>} - The extracted controller function.
|
|
69
|
-
* @throws {Error} - Throws an error if the last argument is not a function.
|
|
70
|
-
*/
|
|
71
|
-
#extractControllerFunction(functions) {
|
|
72
|
-
const controllerFunction = functions.pop();
|
|
73
|
-
if (typeof controllerFunction !== 'function') {
|
|
74
|
-
throw new Error('Last argument must be a function');
|
|
75
|
-
}
|
|
76
|
-
return controllerFunction;
|
|
77
|
-
}
|
|
78
|
-
// TODO: Move to UniversalSDK
|
|
79
|
-
// /**
|
|
80
|
-
// * Extracts the SDK path from the given path.
|
|
81
|
-
// *
|
|
82
|
-
// * @param {string | RegExp | (string | RegExp)[]} path - The provided path.
|
|
83
|
-
// * @returns {string} - The extracted SDK path.
|
|
84
|
-
// * @throws {Error} - Throws an error if the path is not defined.
|
|
85
|
-
// */
|
|
86
|
-
// extractSdkPath(path: string | RegExp | (string | RegExp)[]): string {
|
|
87
|
-
// let sdkPath = path;
|
|
88
|
-
// if (Array.isArray(path)) {
|
|
89
|
-
// sdkPath = path.pop() || path[0];
|
|
90
|
-
// }
|
|
91
|
-
// if (!sdkPath) {
|
|
92
|
-
// throw new Error('Path is not defined');
|
|
93
|
-
// }
|
|
94
|
-
// if (sdkPath instanceof RegExp) {
|
|
95
|
-
// sdkPath = generateStringFromRegex(sdkPath);
|
|
96
|
-
// }
|
|
97
|
-
// return sdkPath as string;
|
|
98
|
-
// }
|
|
99
|
-
/**
|
|
100
|
-
* Registers middleware to the router.
|
|
101
|
-
*
|
|
102
|
-
* @param {...unknown[]} args - The middleware to register.
|
|
103
|
-
* @returns {this} - The router instance.
|
|
104
|
-
*/
|
|
105
|
-
use(...args) {
|
|
106
|
-
this.internal.use(...args);
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
#compile(contractDetails) {
|
|
110
|
-
const schemaValidator = this.schemaValidator;
|
|
111
|
-
const requestSchema = schemaValidator.compile(schemaValidator.schemify({
|
|
112
|
-
...(contractDetails.params ? { params: contractDetails.params } : {}),
|
|
113
|
-
...(contractDetails.requestHeaders
|
|
114
|
-
? { headers: contractDetails.requestHeaders }
|
|
115
|
-
: {}),
|
|
116
|
-
...(contractDetails.query ? { query: contractDetails.query } : {}),
|
|
117
|
-
...(isHttpContractDetails(contractDetails) && contractDetails.body
|
|
118
|
-
? { body: contractDetails.body }
|
|
119
|
-
: {})
|
|
120
|
-
}));
|
|
121
|
-
const responseEntries = {
|
|
122
|
-
400: schemaValidator.string,
|
|
123
|
-
401: schemaValidator.string,
|
|
124
|
-
403: schemaValidator.string,
|
|
125
|
-
404: schemaValidator.string,
|
|
126
|
-
500: schemaValidator.string,
|
|
127
|
-
...contractDetails.responses
|
|
128
|
-
};
|
|
129
|
-
const responseSchemas = {
|
|
130
|
-
responses: {},
|
|
131
|
-
...(contractDetails.responseHeaders
|
|
132
|
-
? {
|
|
133
|
-
headers: schemaValidator.compile(schemaValidator.schemify(contractDetails.responseHeaders))
|
|
134
|
-
}
|
|
135
|
-
: {})
|
|
136
|
-
};
|
|
137
|
-
Object.entries(responseEntries).forEach(([code, responseShape]) => {
|
|
138
|
-
responseSchemas.responses[Number(code)] = schemaValidator.compile(schemaValidator.schemify(responseShape));
|
|
139
|
-
});
|
|
140
|
-
return {
|
|
141
|
-
requestSchema,
|
|
142
|
-
responseSchemas
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Executes request locally, applying parameters
|
|
147
|
-
*
|
|
148
|
-
* @param functions {ForklaunchMiddlewareHandler<SV>}
|
|
149
|
-
* @param controllerFunction
|
|
150
|
-
* @returns
|
|
151
|
-
*/
|
|
152
|
-
#localParamRequest(functions, controllerFunction) {
|
|
153
|
-
return async (route, request) => {
|
|
154
|
-
let statusCode;
|
|
155
|
-
let responseMessage;
|
|
156
|
-
const responseHeaders = {};
|
|
157
|
-
const req = {
|
|
158
|
-
params: request?.params ?? {},
|
|
159
|
-
query: request?.query ?? {},
|
|
160
|
-
headers: request?.headers ?? {},
|
|
161
|
-
body: request?.body ?? {},
|
|
162
|
-
path: route
|
|
163
|
-
};
|
|
164
|
-
const res = {
|
|
165
|
-
status: (code) => {
|
|
166
|
-
statusCode = code;
|
|
167
|
-
return res;
|
|
168
|
-
},
|
|
169
|
-
send: (message) => {
|
|
170
|
-
responseMessage = message;
|
|
171
|
-
},
|
|
172
|
-
json: (body) => {
|
|
173
|
-
responseMessage = body;
|
|
174
|
-
},
|
|
175
|
-
jsonp: (body) => {
|
|
176
|
-
responseMessage = body;
|
|
177
|
-
},
|
|
178
|
-
setHeader: (key, value) => {
|
|
179
|
-
responseHeaders[key] = value;
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
let cursor = functions.shift();
|
|
183
|
-
if (cursor) {
|
|
184
|
-
for (const fn of functions) {
|
|
185
|
-
await cursor(req, res, (err) => {
|
|
186
|
-
if (err) {
|
|
187
|
-
throw err;
|
|
188
|
-
}
|
|
189
|
-
cursor = fn;
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
await cursor(req, res, async (err) => {
|
|
193
|
-
if (err) {
|
|
194
|
-
throw err;
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
const cFunction = controllerFunction;
|
|
199
|
-
await cFunction(req, res, (err) => {
|
|
200
|
-
if (err) {
|
|
201
|
-
throw err;
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
return {
|
|
205
|
-
code: statusCode,
|
|
206
|
-
response: responseMessage,
|
|
207
|
-
headers: responseHeaders
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
#registerRoute(method, path, registrationFunction, contractDetailsOrTypedHandler, ...functions) {
|
|
212
|
-
if (contractDetailsOrTypedHandler instanceof TypedHandler) {
|
|
213
|
-
const typedHandler = contractDetailsOrTypedHandler;
|
|
214
|
-
return this.#registerRoute(method, path, registrationFunction, typedHandler.contractDetails, ...typedHandler.functions.concat(functions));
|
|
215
|
-
}
|
|
216
|
-
const contractDetails = contractDetailsOrTypedHandler;
|
|
217
|
-
this.routes.push({
|
|
218
|
-
basePath: this.basePath,
|
|
219
|
-
path,
|
|
220
|
-
method,
|
|
221
|
-
contractDetails
|
|
222
|
-
});
|
|
223
|
-
const { requestSchema, responseSchemas } = this.#compile(contractDetails);
|
|
224
|
-
const controllerFunction = this.#extractControllerFunction(functions);
|
|
225
|
-
registrationFunction.bind(this.internal)(path, ...this.#resolveMiddlewares(contractDetails, requestSchema, responseSchemas).concat(functions), this.#parseAndRunControllerFunction(controllerFunction));
|
|
226
|
-
return this.#localParamRequest(functions, controllerFunction);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Registers a GET route with the specified contract details and handler functions.
|
|
230
|
-
*
|
|
231
|
-
* @template P - The type of request parameters.
|
|
232
|
-
* @template ResBodyMap - The type of response body.
|
|
233
|
-
* @template ReqBody - The type of request body.
|
|
234
|
-
* @template ReqQuery - The type of request query.
|
|
235
|
-
* @template LocalsObj - The type of local variables.
|
|
236
|
-
* @param {string} path - The path for the route.
|
|
237
|
-
* @param {PathParamHttpContractDetails<SV, P, ResBodyMap, ReqQuery>} contractDetails - The contract details.
|
|
238
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
239
|
-
* @returns {ExpressRouter} - The Express router.
|
|
240
|
-
*/
|
|
241
|
-
get(path, contractDetailsOrTypedHandler, ...functions) {
|
|
242
|
-
return {
|
|
243
|
-
get: this.#registerRoute('get', path, this.internal.get, contractDetailsOrTypedHandler, ...functions)
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Registers a POST route with the specified contract details and handler functions.
|
|
248
|
-
*
|
|
249
|
-
* @template P - The type of request parameters.
|
|
250
|
-
* @template ResBodyMap - The type of response body.
|
|
251
|
-
* @template ReqBody - The type of request body.
|
|
252
|
-
* @template ReqQuery - The type of request query.
|
|
253
|
-
* @template LocalsObj - The type of local variables.
|
|
254
|
-
* @param {string} path - The path for the route.
|
|
255
|
-
* @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
|
|
256
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
257
|
-
* @returns {ExpressRouter} - The Express router.
|
|
258
|
-
*/
|
|
259
|
-
post(path, contractDetailsOrTypedHandler, ...functions) {
|
|
260
|
-
return {
|
|
261
|
-
post: this.#registerRoute('post', path, this.internal.post, contractDetailsOrTypedHandler, ...functions)
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Registers a PUT route with the specified contract details and handler functions.
|
|
266
|
-
*
|
|
267
|
-
* @template P - The type of request parameters.
|
|
268
|
-
* @template ResBodyMap - The type of response body.
|
|
269
|
-
* @template ReqBody - The type of request body.
|
|
270
|
-
* @template ReqQuery - The type of request query.
|
|
271
|
-
* @template LocalsObj - The type of local variables.
|
|
272
|
-
* @param {string} path - The path for the route.
|
|
273
|
-
* @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
|
|
274
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
275
|
-
* @returns {ExpressRouter} - The Express router.
|
|
276
|
-
*/
|
|
277
|
-
put(path, contractDetailsOrTypedHandler, ...functions) {
|
|
278
|
-
return {
|
|
279
|
-
put: this.#registerRoute('put', path, this.internal.put, contractDetailsOrTypedHandler, ...functions)
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Registers a PATCH route with the specified contract details and handler functions.
|
|
284
|
-
*
|
|
285
|
-
* @template P - The type of request parameters.
|
|
286
|
-
* @template ResBodyMap - The type of response body.
|
|
287
|
-
* @template ReqBody - The type of request body.
|
|
288
|
-
* @template ReqQuery - The type of request query.
|
|
289
|
-
* @template LocalsObj - The type of local variables.
|
|
290
|
-
* @param {string} path - The path for the route.
|
|
291
|
-
* @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
|
|
292
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
293
|
-
* @returns {ExpressRouter} - The Express router.
|
|
294
|
-
*/
|
|
295
|
-
patch(path, contractDetailsOrTypedHandler, ...functions) {
|
|
296
|
-
return {
|
|
297
|
-
patch: this.#registerRoute('patch', path, this.internal.patch, contractDetailsOrTypedHandler, ...functions)
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Registers a DELETE route with the specified contract details and handler functions.
|
|
302
|
-
*
|
|
303
|
-
* @template P - The type of request parameters.
|
|
304
|
-
* @template ResBodyMap - The type of response body.
|
|
305
|
-
* @template ReqBody - The type of request body.
|
|
306
|
-
* @template ReqQuery - The type of request query.
|
|
307
|
-
* @template LocalsObj - The type of local variables.
|
|
308
|
-
* @param {string} path - The path for the route.
|
|
309
|
-
* @param {PathParamHttpContractDetails<SV, P, ResBodyMap, ReqQuery>} contractDetails - The contract details.
|
|
310
|
-
* @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
|
|
311
|
-
* @returns {ExpressRouter} - The Express router.
|
|
312
|
-
*/
|
|
313
|
-
delete(path, contractDetailsOrTypedHandler, ...functions) {
|
|
314
|
-
return {
|
|
315
|
-
delete: this.#registerRoute('delete', path, this.internal.delete, contractDetailsOrTypedHandler, ...functions)
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
class TypedHandler {
|
|
320
|
-
contractDetails;
|
|
321
|
-
functions;
|
|
322
|
-
constructor(contractDetails, functions) {
|
|
323
|
-
this.contractDetails = contractDetails;
|
|
324
|
-
this.functions = functions;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Router class that sets up routes and middleware for an Express router, for use with controller/routes pattern.
|
|
329
|
-
*
|
|
330
|
-
* @template SV - A type that extends AnySchemaValidator.
|
|
331
|
-
* @template contractDetails - The contract details.
|
|
332
|
-
* @template functions - The handler middlware and function.
|
|
333
|
-
*/
|
|
334
|
-
export function typedHandler(_schemaValidator, _method, contractDetails, ...functions) {
|
|
335
|
-
return new TypedHandler(contractDetails, functions);
|
|
336
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../dist/http/interfaces/index.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../dist/http/middleware/index.js"],"names":[],"mappings":""}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cors middleware handler
|
|
3
|
-
*
|
|
4
|
-
* @param req - Express-like request object
|
|
5
|
-
* @param res - Express-like response object
|
|
6
|
-
* @param next - Express-like next function
|
|
7
|
-
*/
|
|
8
|
-
export function corsMiddleware(req: any, res: any, next: any): void;
|
|
9
|
-
/**
|
|
10
|
-
* Middleware to create and add a request context.
|
|
11
|
-
*
|
|
12
|
-
* @template SV - A type that extends AnySchemaValidator.
|
|
13
|
-
* @template Request - A type that extends ForklaunchRequest.
|
|
14
|
-
* @template Response - A type that extends ForklaunchResponse.
|
|
15
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
16
|
-
* @param {SV} schemaValidator - The schema validator.
|
|
17
|
-
* @returns {Function} - Middleware function to create request context.
|
|
18
|
-
*/
|
|
19
|
-
export function createRequestContext<SV, Request, Response, NextFunction>(schemaValidator: SV): Function;
|
|
20
|
-
/**
|
|
21
|
-
* Middleware to enrich the request details with contract details.
|
|
22
|
-
*
|
|
23
|
-
* @template SV - A type that extends AnySchemaValidator.
|
|
24
|
-
* @template Request - A type that extends ForklaunchRequest.
|
|
25
|
-
* @template Response - A type that extends ForklaunchResponse.
|
|
26
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
27
|
-
* @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
|
|
28
|
-
* @returns {Function} - Middleware function to enrich request details.
|
|
29
|
-
*/
|
|
30
|
-
export function enrichRequestDetails<SV, Request, Response, NextFunction>(contractDetails: PathParamHttpContractDetails<SV> | HttpContractDetails<SV>, requestSchema: any, responseSchemas: any): Function;
|
|
31
|
-
/**
|
|
32
|
-
* Pre-handler function to parse and validate input.
|
|
33
|
-
*
|
|
34
|
-
* @template SV - A type that extends AnySchemaValidator.
|
|
35
|
-
* @template Request - A type that extends ForklaunchRequest.
|
|
36
|
-
* @template Response - A type that extends ForklaunchResponse.
|
|
37
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
38
|
-
* @param {Request} req - The request object.
|
|
39
|
-
* @param {Response} res - The response object.
|
|
40
|
-
* @param {NextFunction} [next] - The next middleware function.
|
|
41
|
-
*/
|
|
42
|
-
export function parseRequest<SV, Request, Response, NextFunction>(req: Request, _res: any, next?: NextFunction | undefined): void;
|
|
43
|
-
/**
|
|
44
|
-
* Maps roles from authorization.
|
|
45
|
-
*
|
|
46
|
-
* @param {AuthMethod} [authorizationType] - The method of authorization.
|
|
47
|
-
* @param {string} [authorizationToken] - The authorization token.
|
|
48
|
-
* @returns {string[]} - The mapped roles.
|
|
49
|
-
*/
|
|
50
|
-
/**
|
|
51
|
-
* Maps permissions from authorization.
|
|
52
|
-
*
|
|
53
|
-
* @param {AuthMethod} [authorizationType] - The method of authorization.
|
|
54
|
-
* @param {string} [authorizationToken] - The authorization token.
|
|
55
|
-
* @returns {string[]} - The mapped permissions.
|
|
56
|
-
*/
|
|
57
|
-
/**
|
|
58
|
-
* Middleware to parse request authorization.
|
|
59
|
-
*
|
|
60
|
-
* @template SV - A type that extends AnySchemaValidator.
|
|
61
|
-
* @template Request - A type that extends ForklaunchRequest.
|
|
62
|
-
* @template Response - A type that extends ForklaunchResponse.
|
|
63
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
64
|
-
* @param {Request} req - The request object.
|
|
65
|
-
* @param {Response} res - The response object.
|
|
66
|
-
* @param {NextFunction} [next] - The next middleware function.
|
|
67
|
-
*/
|
|
68
|
-
export function parseRequestAuth<SV, Request, Response, NextFunction>(req: Request, res: Response, next?: NextFunction | undefined): Promise<void>;
|
|
69
|
-
//# sourceMappingURL=request.middleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request.middleware.d.ts","sourceRoot":"","sources":["../../../../dist/http/middleware/request.middleware.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,oEAMC;AACD;;;;;;;;;GASG;AACH,qCAPa,EAAE,EACF,OAAO,EACP,QAAQ,EACR,YAAY,mBACd,EAAE,YAiBZ;AACD;;;;;;;;;GASG;AACH,qCAPa,EAAE,EACF,OAAO,EACP,QAAQ,EACR,YAAY,mBACd,4BAA4B,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,EAAE,CAAC,sDAWpE;AACD;;;;;;;;;;GAUG;AACH,6BARa,EAAE,EACF,OAAO,EACP,QAAQ,EACR,YAAY,OACd,OAAO,oDAkCjB;AA8BD;;;;;;GAMG;AAOH;;;;;;GAMG;AAOH;;;;;;;;;;GAUG;AACH,iCARa,EAAE,EACF,OAAO,EACP,QAAQ,EACR,YAAY,OACd,OAAO,OACP,QAAQ,kDA0ClB"}
|