@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,210 +0,0 @@
|
|
1
|
-
import cors from 'cors';
|
2
|
-
import * as jose from 'jose';
|
3
|
-
import { v4 } from 'uuid';
|
4
|
-
import { isResponseShape } from '../guards/isResponseShape';
|
5
|
-
/**
|
6
|
-
* Cors middleware handler
|
7
|
-
*
|
8
|
-
* @param req - Express-like request object
|
9
|
-
* @param res - Express-like response object
|
10
|
-
* @param next - Express-like next function
|
11
|
-
*/
|
12
|
-
export function corsMiddleware(req, res, next) {
|
13
|
-
console.debug('[MIDDLEWARE] cors started');
|
14
|
-
if (req.method === 'OPTIONS') {
|
15
|
-
res.cors = true;
|
16
|
-
}
|
17
|
-
cors()(req, res, next ?? (() => { }));
|
18
|
-
}
|
19
|
-
/**
|
20
|
-
* Middleware to create and add a request context.
|
21
|
-
*
|
22
|
-
* @template SV - A type that extends AnySchemaValidator.
|
23
|
-
* @template Request - A type that extends ForklaunchRequest.
|
24
|
-
* @template Response - A type that extends ForklaunchResponse.
|
25
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
26
|
-
* @param {SV} schemaValidator - The schema validator.
|
27
|
-
* @returns {Function} - Middleware function to create request context.
|
28
|
-
*/
|
29
|
-
export function createRequestContext(schemaValidator) {
|
30
|
-
return (req, res, next) => {
|
31
|
-
console.debug('[MIDDLEWARE] createRequestContext started');
|
32
|
-
req.schemaValidator = schemaValidator;
|
33
|
-
let correlationId = v4();
|
34
|
-
if (req.headers['x-correlation-id']) {
|
35
|
-
correlationId = req.headers['x-correlation-id'];
|
36
|
-
}
|
37
|
-
res.setHeader('x-correlation-id', correlationId);
|
38
|
-
req.context = {
|
39
|
-
correlationId: correlationId
|
40
|
-
};
|
41
|
-
next?.();
|
42
|
-
};
|
43
|
-
}
|
44
|
-
/**
|
45
|
-
* Middleware to enrich the request details with contract details.
|
46
|
-
*
|
47
|
-
* @template SV - A type that extends AnySchemaValidator.
|
48
|
-
* @template Request - A type that extends ForklaunchRequest.
|
49
|
-
* @template Response - A type that extends ForklaunchResponse.
|
50
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
51
|
-
* @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
|
52
|
-
* @returns {Function} - Middleware function to enrich request details.
|
53
|
-
*/
|
54
|
-
export function enrichRequestDetails(contractDetails, requestSchema, responseSchemas) {
|
55
|
-
return (req, res, next) => {
|
56
|
-
console.debug('[MIDDLEWARE] enrichRequestDetails started');
|
57
|
-
req.contractDetails = contractDetails;
|
58
|
-
req.requestSchema = requestSchema;
|
59
|
-
res.responseSchemas = responseSchemas;
|
60
|
-
next?.();
|
61
|
-
};
|
62
|
-
}
|
63
|
-
/**
|
64
|
-
* Pre-handler function to parse and validate input.
|
65
|
-
*
|
66
|
-
* @template SV - A type that extends AnySchemaValidator.
|
67
|
-
* @template Request - A type that extends ForklaunchRequest.
|
68
|
-
* @template Response - A type that extends ForklaunchResponse.
|
69
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
70
|
-
* @param {Request} req - The request object.
|
71
|
-
* @param {Response} res - The response object.
|
72
|
-
* @param {NextFunction} [next] - The next middleware function.
|
73
|
-
*/
|
74
|
-
export function parseRequest(req, _res, next) {
|
75
|
-
console.debug('[MIDDLEWARE] parseRequest started');
|
76
|
-
const request = {
|
77
|
-
params: req.params,
|
78
|
-
query: req.query,
|
79
|
-
headers: req.headers,
|
80
|
-
body: req.body
|
81
|
-
};
|
82
|
-
const parsedRequest = req.schemaValidator.parse(req.requestSchema, request);
|
83
|
-
if (parsedRequest.ok &&
|
84
|
-
isResponseShape(parsedRequest.value)) {
|
85
|
-
req.body = parsedRequest.value.body;
|
86
|
-
req.params = parsedRequest.value.params;
|
87
|
-
req.query = parsedRequest.value.query;
|
88
|
-
req.headers = parsedRequest.value.headers;
|
89
|
-
}
|
90
|
-
if (!parsedRequest.ok) {
|
91
|
-
switch (req.contractDetails.options?.requestValidation) {
|
92
|
-
default:
|
93
|
-
case 'error':
|
94
|
-
next?.(new Error(`Invalid request: ${parsedRequest.error}`));
|
95
|
-
break;
|
96
|
-
case 'warning':
|
97
|
-
console.warn(`Invalid request: ${parsedRequest.error}`);
|
98
|
-
break;
|
99
|
-
case 'none':
|
100
|
-
break;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
next?.();
|
104
|
-
}
|
105
|
-
/**
|
106
|
-
* Checks the authorization token for validity.
|
107
|
-
*
|
108
|
-
* @param {AuthMethod} [authorizationMethod] - The method of authorization.
|
109
|
-
* @param {string} [authorizationString] - The authorization string.
|
110
|
-
* @returns {Promise<[401 | 403, string] | string | undefined>} - The result of the authorization check.
|
111
|
-
*/
|
112
|
-
async function checkAuthorizationToken(authorizationMethod, authorizationString) {
|
113
|
-
if (!authorizationString) {
|
114
|
-
return [401, 'No Authorization token provided.'];
|
115
|
-
}
|
116
|
-
switch (authorizationMethod) {
|
117
|
-
case 'jwt': {
|
118
|
-
if (!authorizationString.startsWith('Bearer ')) {
|
119
|
-
return [401, 'Invalid Authorization token format.'];
|
120
|
-
}
|
121
|
-
try {
|
122
|
-
const decodedJwt = await jose.jwtVerify(authorizationString.split(' ')[1], new TextEncoder().encode(process.env.JWT_SECRET || 'your-256-bit-secret'));
|
123
|
-
return decodedJwt.payload.iss;
|
124
|
-
}
|
125
|
-
catch (error) {
|
126
|
-
console.error(error);
|
127
|
-
return [403, 'Invalid Authorization token.'];
|
128
|
-
}
|
129
|
-
}
|
130
|
-
default:
|
131
|
-
return [401, 'Invalid Authorization method.'];
|
132
|
-
}
|
133
|
-
}
|
134
|
-
/**
|
135
|
-
* Maps roles from authorization.
|
136
|
-
*
|
137
|
-
* @param {AuthMethod} [authorizationType] - The method of authorization.
|
138
|
-
* @param {string} [authorizationToken] - The authorization token.
|
139
|
-
* @returns {string[]} - The mapped roles.
|
140
|
-
*/
|
141
|
-
// function mapRoles(
|
142
|
-
// authorizationType?: AuthMethod,
|
143
|
-
// authorizationToken?: string
|
144
|
-
// ): string[] {
|
145
|
-
// return [];
|
146
|
-
// }
|
147
|
-
/**
|
148
|
-
* Maps permissions from authorization.
|
149
|
-
*
|
150
|
-
* @param {AuthMethod} [authorizationType] - The method of authorization.
|
151
|
-
* @param {string} [authorizationToken] - The authorization token.
|
152
|
-
* @returns {string[]} - The mapped permissions.
|
153
|
-
*/
|
154
|
-
// function mapPermissions(
|
155
|
-
// authorizationType?: AuthMethod,
|
156
|
-
// authorizationToken?: string
|
157
|
-
// ): string[] {
|
158
|
-
// return [];
|
159
|
-
// }
|
160
|
-
/**
|
161
|
-
* Middleware to parse request authorization.
|
162
|
-
*
|
163
|
-
* @template SV - A type that extends AnySchemaValidator.
|
164
|
-
* @template Request - A type that extends ForklaunchRequest.
|
165
|
-
* @template Response - A type that extends ForklaunchResponse.
|
166
|
-
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
167
|
-
* @param {Request} req - The request object.
|
168
|
-
* @param {Response} res - The response object.
|
169
|
-
* @param {NextFunction} [next] - The next middleware function.
|
170
|
-
*/
|
171
|
-
export async function parseRequestAuth(req, res, next) {
|
172
|
-
const auth = req.contractDetails.auth;
|
173
|
-
if (auth) {
|
174
|
-
const errorAndMessage = await checkAuthorizationToken(auth.method, req.headers.authorization);
|
175
|
-
if (Array.isArray(errorAndMessage)) {
|
176
|
-
res.status(errorAndMessage[0]).send(errorAndMessage[1]);
|
177
|
-
next?.(new Error(errorAndMessage[1]));
|
178
|
-
}
|
179
|
-
// TODO: Implement role and permission checking
|
180
|
-
// const permissionSlugs = mapPermissions(
|
181
|
-
// auth.method,
|
182
|
-
// req.headers.authorization
|
183
|
-
// );
|
184
|
-
// const roles = mapRoles(auth.method, req.headers.authorization);
|
185
|
-
// const permissionErrorMessage =
|
186
|
-
// 'User does not have sufficient permissions to perform action.';
|
187
|
-
// const roleErrorMessage =
|
188
|
-
// 'User does not have correct role to perform action.';
|
189
|
-
// permissionSlugs.forEach((permissionSlug) => {
|
190
|
-
// if (
|
191
|
-
// !req.contractDetails.auth?.allowedSlugs?.has(permissionSlug) ||
|
192
|
-
// req.contractDetails.auth?.forbiddenSlugs?.has(permissionSlug)
|
193
|
-
// ) {
|
194
|
-
// res.status(403).send(permissionErrorMessage);
|
195
|
-
// next?.(new Error(permissionErrorMessage));
|
196
|
-
// }
|
197
|
-
// }
|
198
|
-
// });
|
199
|
-
// roles.forEach((role) => {
|
200
|
-
// if (
|
201
|
-
// !req.contractDetails.auth?.allowedRoles?.has(role) ||
|
202
|
-
// req.contractDetails.auth?.forbiddenRoles?.has(role)
|
203
|
-
// ) {
|
204
|
-
// res.status(403).send(roleErrorMessage);
|
205
|
-
// next?.(new Error(roleErrorMessage));
|
206
|
-
// }
|
207
|
-
// });
|
208
|
-
}
|
209
|
-
// next?.();
|
210
|
-
}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
-
import { ParsedQs } from 'qs';
|
3
|
-
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse } from '../types/apiDefinition.types';
|
4
|
-
import { ParamsDictionary } from '../types/contractDetails.types';
|
5
|
-
/**
|
6
|
-
* Middleware to parse and validate the response according to the provided schema.
|
7
|
-
*
|
8
|
-
* This function validates the response against a schema provided by the request's schema validator.
|
9
|
-
* If the response does not conform to the schema, the behavior is determined by the `responseValidation`
|
10
|
-
* option in `req.contractDetails.options`:
|
11
|
-
* - `'error'` (default): Calls `next` with an error.
|
12
|
-
* - `'warning'`: Logs a warning to the console.
|
13
|
-
* - `'none'`: Silently continues without action.
|
14
|
-
*
|
15
|
-
* @template SV - The type of the schema validator used in the request.
|
16
|
-
* @template P - The type of the parameters dictionary used in the request.
|
17
|
-
* @template ResBodyMap - A record type mapping status codes to response body types.
|
18
|
-
* @template ReqBody - The type of the request body.
|
19
|
-
* @template ReqQuery - The type of the parsed query string.
|
20
|
-
* @template ReqHeaders - The type of the request headers.
|
21
|
-
* @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
|
22
|
-
* @template LocalsObj - The type of the locals object in the response.
|
23
|
-
*
|
24
|
-
* @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
|
25
|
-
* @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
|
26
|
-
* @param {ForklaunchNextFunction} [next] - The next middleware function to be called. If not provided, the function will return after processing.
|
27
|
-
*
|
28
|
-
* @returns {void} This function does not return a value.
|
29
|
-
*/
|
30
|
-
export declare function parseResponse<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>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, res: ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>, next?: ForklaunchNextFunction): void;
|
31
|
-
//# sourceMappingURL=response.middleware.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"response.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/response.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAC3B,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,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,IAAI,CAAC,EAAE,sBAAsB,QAsC9B"}
|
@@ -1,52 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Middleware to parse and validate the response according to the provided schema.
|
3
|
-
*
|
4
|
-
* This function validates the response against a schema provided by the request's schema validator.
|
5
|
-
* If the response does not conform to the schema, the behavior is determined by the `responseValidation`
|
6
|
-
* option in `req.contractDetails.options`:
|
7
|
-
* - `'error'` (default): Calls `next` with an error.
|
8
|
-
* - `'warning'`: Logs a warning to the console.
|
9
|
-
* - `'none'`: Silently continues without action.
|
10
|
-
*
|
11
|
-
* @template SV - The type of the schema validator used in the request.
|
12
|
-
* @template P - The type of the parameters dictionary used in the request.
|
13
|
-
* @template ResBodyMap - A record type mapping status codes to response body types.
|
14
|
-
* @template ReqBody - The type of the request body.
|
15
|
-
* @template ReqQuery - The type of the parsed query string.
|
16
|
-
* @template ReqHeaders - The type of the request headers.
|
17
|
-
* @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
|
18
|
-
* @template LocalsObj - The type of the locals object in the response.
|
19
|
-
*
|
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 {ForklaunchNextFunction} [next] - The next middleware function to be called. If not provided, the function will return after processing.
|
23
|
-
*
|
24
|
-
* @returns {void} This function does not return a value.
|
25
|
-
*/
|
26
|
-
export function parseResponse(req, res, next) {
|
27
|
-
console.debug('[MIDDLEWARE] parseResponse started');
|
28
|
-
const { headers, responses } = res.responseSchemas;
|
29
|
-
const parsedResponse = req.schemaValidator.parse(responses?.[res.statusCode], res.bodyData);
|
30
|
-
const parsedHeaders = req.schemaValidator.parse(headers, res.getHeaders());
|
31
|
-
const parseErrors = [];
|
32
|
-
if (!parsedHeaders.ok) {
|
33
|
-
parseErrors.push(`${parsedHeaders.error ? `Header ${parsedHeaders.error}` : ''}`);
|
34
|
-
}
|
35
|
-
if (!parsedResponse.ok) {
|
36
|
-
parseErrors.push(`${parsedResponse.error ? `Response ${parsedResponse.error}` : ''}`);
|
37
|
-
}
|
38
|
-
if (parseErrors.length > 0) {
|
39
|
-
switch (req.contractDetails.options?.responseValidation) {
|
40
|
-
default:
|
41
|
-
case 'error':
|
42
|
-
next?.(new Error(`Invalid response:\n${parseErrors.join('\n\n')}`));
|
43
|
-
break;
|
44
|
-
case 'warning':
|
45
|
-
console.warn(`Invalid response:\n${parseErrors.join('\n\n')}`);
|
46
|
-
break;
|
47
|
-
case 'none':
|
48
|
-
break;
|
49
|
-
}
|
50
|
-
}
|
51
|
-
next?.();
|
52
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/http/openApiV3Generator/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './openApiV3Generator';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/http/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/http/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"entityMapper.test.d.ts","sourceRoot":"","sources":["../../tests/entityMapper.test.ts"],"names":[],"mappings":""}
|
@@ -1,168 +0,0 @@
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
-
};
|
7
|
-
import { SchemaValidator, number, string } from '@forklaunch/validator/typebox';
|
8
|
-
import { Property } from '@mikro-orm/core';
|
9
|
-
import { BaseEntity } from '../src/database/mikro/models/entities/base.entity';
|
10
|
-
import { RequestDtoMapper } from '../src/dtoMapper/models/requestDtoMapper.model';
|
11
|
-
import { ResponseDtoMapper } from '../src/dtoMapper/models/responseDtoMapper.model';
|
12
|
-
const SV = SchemaValidator();
|
13
|
-
class TestEntity extends BaseEntity {
|
14
|
-
name;
|
15
|
-
age;
|
16
|
-
}
|
17
|
-
__decorate([
|
18
|
-
Property()
|
19
|
-
], TestEntity.prototype, "name", void 0);
|
20
|
-
__decorate([
|
21
|
-
Property()
|
22
|
-
], TestEntity.prototype, "age", void 0);
|
23
|
-
class TestRequestDtoMapper extends RequestDtoMapper {
|
24
|
-
schema = {
|
25
|
-
id: string,
|
26
|
-
name: string,
|
27
|
-
age: number
|
28
|
-
};
|
29
|
-
toEntity(...additionalArgs) {
|
30
|
-
const entity = new TestEntity();
|
31
|
-
entity.id = this.dto.id;
|
32
|
-
entity.name = this.dto.name;
|
33
|
-
entity.age = this.dto.age;
|
34
|
-
return entity;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
class TestResponseDtoMapper extends ResponseDtoMapper {
|
38
|
-
schema = {
|
39
|
-
id: string,
|
40
|
-
name: string,
|
41
|
-
age: number
|
42
|
-
};
|
43
|
-
fromEntity(entity) {
|
44
|
-
this.dto = {
|
45
|
-
id: entity.id,
|
46
|
-
name: entity.name,
|
47
|
-
age: entity.age
|
48
|
-
};
|
49
|
-
return this;
|
50
|
-
}
|
51
|
-
}
|
52
|
-
function extractNonTimeBasedEntityFields(entity) {
|
53
|
-
entity.createdAt = new Date(0);
|
54
|
-
entity.updatedAt = new Date(0);
|
55
|
-
return entity;
|
56
|
-
}
|
57
|
-
describe('Request Entity Mapper Test', () => {
|
58
|
-
let TestRequestEM;
|
59
|
-
beforeAll(() => {
|
60
|
-
TestRequestEM = new TestRequestDtoMapper(SchemaValidator());
|
61
|
-
});
|
62
|
-
test('Schema Equality', async () => {
|
63
|
-
expect(TestRequestEM.schema).toEqual(TestRequestDtoMapper.schema());
|
64
|
-
});
|
65
|
-
test('From JSON', async () => {
|
66
|
-
const json = {
|
67
|
-
id: '123',
|
68
|
-
name: 'test',
|
69
|
-
age: 1
|
70
|
-
};
|
71
|
-
const responseEM = TestRequestEM.fromJson(json);
|
72
|
-
const staticEM = TestRequestDtoMapper.fromJson(SchemaValidator(), json);
|
73
|
-
const expectedDto = {
|
74
|
-
id: '123',
|
75
|
-
name: 'test',
|
76
|
-
age: 1
|
77
|
-
};
|
78
|
-
expect(staticEM.dto).toEqual(expectedDto);
|
79
|
-
expect(responseEM.dto).toEqual(expectedDto);
|
80
|
-
expect(responseEM.dto).toEqual(staticEM.dto);
|
81
|
-
});
|
82
|
-
test('Deserialization Equality', async () => {
|
83
|
-
const json = {
|
84
|
-
id: '123',
|
85
|
-
name: 'test',
|
86
|
-
age: 1
|
87
|
-
};
|
88
|
-
const entity = extractNonTimeBasedEntityFields(TestRequestEM.deserializeJsonToEntity(json));
|
89
|
-
const objectEntity = extractNonTimeBasedEntityFields(TestRequestEM.fromJson(json).toEntity());
|
90
|
-
const staticEntity = extractNonTimeBasedEntityFields(TestRequestDtoMapper.deserializeJsonToEntity(SchemaValidator(), json));
|
91
|
-
let expectedEntity = new TestEntity();
|
92
|
-
expectedEntity.id = '123';
|
93
|
-
expectedEntity.name = 'test';
|
94
|
-
expectedEntity.age = 1;
|
95
|
-
expectedEntity = extractNonTimeBasedEntityFields(expectedEntity);
|
96
|
-
expect(entity).toEqual(expectedEntity);
|
97
|
-
expect(objectEntity).toEqual(expectedEntity);
|
98
|
-
expect(staticEntity).toEqual(expectedEntity);
|
99
|
-
expect(entity).toEqual(objectEntity);
|
100
|
-
expect(entity).toEqual(staticEntity);
|
101
|
-
expect(staticEntity).toEqual(expectedEntity);
|
102
|
-
expect(staticEntity).toEqual(objectEntity);
|
103
|
-
});
|
104
|
-
test('Serialization Failure', async () => {
|
105
|
-
const json = {
|
106
|
-
id: '123',
|
107
|
-
name: 'test'
|
108
|
-
};
|
109
|
-
// @ts-expect-error
|
110
|
-
expect(() => TestRequestEM.fromJson(json)).toThrow();
|
111
|
-
expect(() =>
|
112
|
-
// @ts-expect-error
|
113
|
-
TestRequestDtoMapper.fromJson(new TypeboxSchemaValidator(), json)).toThrow();
|
114
|
-
});
|
115
|
-
});
|
116
|
-
describe('Response Entity Mapper Test', () => {
|
117
|
-
let TestResponseEM;
|
118
|
-
beforeAll(() => {
|
119
|
-
TestResponseEM = new TestResponseDtoMapper(SchemaValidator());
|
120
|
-
});
|
121
|
-
test('Schema Equality', async () => {
|
122
|
-
expect(TestResponseEM.schema).toEqual(TestResponseDtoMapper.schema());
|
123
|
-
});
|
124
|
-
test('From Entity', async () => {
|
125
|
-
const entity = new TestEntity();
|
126
|
-
entity.id = '123';
|
127
|
-
entity.name = 'test';
|
128
|
-
entity.age = 1;
|
129
|
-
const responseEM = TestResponseEM.fromEntity(entity);
|
130
|
-
const staticEM = TestResponseDtoMapper.fromEntity(SchemaValidator(), entity);
|
131
|
-
const expectedDto = {
|
132
|
-
id: '123',
|
133
|
-
name: 'test',
|
134
|
-
age: 1
|
135
|
-
};
|
136
|
-
expect(staticEM.dto).toEqual(expectedDto);
|
137
|
-
expect(responseEM.dto).toEqual(expectedDto);
|
138
|
-
expect(responseEM.dto).toEqual(staticEM.dto);
|
139
|
-
});
|
140
|
-
test('Serialization Equality', async () => {
|
141
|
-
const entity = new TestEntity();
|
142
|
-
entity.id = '123';
|
143
|
-
entity.name = 'test';
|
144
|
-
entity.age = 1;
|
145
|
-
const json = TestResponseEM.serializeEntityToJson(entity);
|
146
|
-
const objectJson = TestResponseEM.fromEntity(entity).toJson();
|
147
|
-
const staticJson = TestResponseDtoMapper.serializeEntityToJson(SchemaValidator(), entity);
|
148
|
-
const expectedJson = {
|
149
|
-
id: '123',
|
150
|
-
name: 'test',
|
151
|
-
age: 1
|
152
|
-
};
|
153
|
-
expect(json).toEqual(expectedJson);
|
154
|
-
expect(objectJson).toEqual(expectedJson);
|
155
|
-
expect(staticJson).toEqual(expectedJson);
|
156
|
-
expect(json).toEqual(objectJson);
|
157
|
-
expect(json).toEqual(staticJson);
|
158
|
-
expect(staticJson).toEqual(expectedJson);
|
159
|
-
expect(staticJson).toEqual(objectJson);
|
160
|
-
});
|
161
|
-
test('Serialization Failure', async () => {
|
162
|
-
const entity = new TestEntity();
|
163
|
-
entity.id = '123';
|
164
|
-
entity.name = 'test';
|
165
|
-
expect(() => TestResponseEM.fromEntity(entity).toJson()).toThrow();
|
166
|
-
expect(() => TestResponseDtoMapper.fromEntity(SchemaValidator(), entity).toJson()).toThrow();
|
167
|
-
});
|
168
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"expressLikeRouter.test.d.ts","sourceRoot":"","sources":["../../tests/expressLikeRouter.test.ts"],"names":[],"mappings":""}
|
/package/lib/{dist/cache/interfaces/ttlCache.interface.js → src/http/types/typedHandler.types.js}
RENAMED
File without changes
|