@konker.dev/neverthrow-r-middleware 0.0.2
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/LICENSE +15 -0
- package/README.md +26 -0
- package/dist/handler.d.ts +3 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +2 -0
- package/dist/handler.js.map +1 -0
- package/dist/http/HttpApiError.d.ts +16 -0
- package/dist/http/HttpApiError.d.ts.map +1 -0
- package/dist/http/HttpApiError.js +60 -0
- package/dist/http/HttpApiError.js.map +1 -0
- package/dist/http/HttpApiError.test.d.ts +2 -0
- package/dist/http/HttpApiError.test.d.ts.map +1 -0
- package/dist/http/HttpApiError.test.js +45 -0
- package/dist/http/HttpApiError.test.js.map +1 -0
- package/dist/http/Rec.d.ts +13 -0
- package/dist/http/Rec.d.ts.map +1 -0
- package/dist/http/Rec.js +2 -0
- package/dist/http/Rec.js.map +1 -0
- package/dist/http/RequestResponseHandler.d.ts +7 -0
- package/dist/http/RequestResponseHandler.d.ts.map +1 -0
- package/dist/http/RequestResponseHandler.js +2 -0
- package/dist/http/RequestResponseHandler.js.map +1 -0
- package/dist/http/RequestW.d.ts +14 -0
- package/dist/http/RequestW.d.ts.map +1 -0
- package/dist/http/RequestW.js +17 -0
- package/dist/http/RequestW.js.map +1 -0
- package/dist/http/RequestW.test.d.ts +2 -0
- package/dist/http/RequestW.test.d.ts.map +1 -0
- package/dist/http/RequestW.test.js +26 -0
- package/dist/http/RequestW.test.js.map +1 -0
- package/dist/http/ResponseW.d.ts +11 -0
- package/dist/http/ResponseW.d.ts.map +1 -0
- package/dist/http/ResponseW.js +14 -0
- package/dist/http/ResponseW.js.map +1 -0
- package/dist/http/ResponseW.test.d.ts +2 -0
- package/dist/http/ResponseW.test.d.ts.map +1 -0
- package/dist/http/ResponseW.test.js +23 -0
- package/dist/http/ResponseW.test.js.map +1 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.d.ts +14 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.d.ts.map +1 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.js +26 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.js.map +1 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.test.d.ts +2 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.test.d.ts.map +1 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.test.js +76 -0
- package/dist/http/contrib/apiGatewayProxyEventV2Adapter.test.js.map +1 -0
- package/dist/http/contrib/base64BodyDecoder.d.ts +7 -0
- package/dist/http/contrib/base64BodyDecoder.d.ts.map +1 -0
- package/dist/http/contrib/base64BodyDecoder.js +15 -0
- package/dist/http/contrib/base64BodyDecoder.js.map +1 -0
- package/dist/http/contrib/base64BodyDecoder.test.d.ts +2 -0
- package/dist/http/contrib/base64BodyDecoder.test.d.ts.map +1 -0
- package/dist/http/contrib/base64BodyDecoder.test.js +47 -0
- package/dist/http/contrib/base64BodyDecoder.test.js.map +1 -0
- package/dist/http/contrib/basicAuthAuthenticator.d.ts +17 -0
- package/dist/http/contrib/basicAuthAuthenticator.d.ts.map +1 -0
- package/dist/http/contrib/basicAuthAuthenticator.js +30 -0
- package/dist/http/contrib/basicAuthAuthenticator.js.map +1 -0
- package/dist/http/contrib/basicAuthAuthenticator.test.d.ts +2 -0
- package/dist/http/contrib/basicAuthAuthenticator.test.d.ts.map +1 -0
- package/dist/http/contrib/basicAuthAuthenticator.test.js +64 -0
- package/dist/http/contrib/basicAuthAuthenticator.test.js.map +1 -0
- package/dist/http/contrib/basicAuthDecoder.d.ts +13 -0
- package/dist/http/contrib/basicAuthDecoder.d.ts.map +1 -0
- package/dist/http/contrib/basicAuthDecoder.js +23 -0
- package/dist/http/contrib/basicAuthDecoder.js.map +1 -0
- package/dist/http/contrib/basicAuthDecoder.test.d.ts +2 -0
- package/dist/http/contrib/basicAuthDecoder.test.d.ts.map +1 -0
- package/dist/http/contrib/basicAuthDecoder.test.js +31 -0
- package/dist/http/contrib/basicAuthDecoder.test.js.map +1 -0
- package/dist/http/contrib/bodyValidator.d.ts +11 -0
- package/dist/http/contrib/bodyValidator.d.ts.map +1 -0
- package/dist/http/contrib/bodyValidator.js +15 -0
- package/dist/http/contrib/bodyValidator.js.map +1 -0
- package/dist/http/contrib/bodyValidator.test.d.ts +2 -0
- package/dist/http/contrib/bodyValidator.test.d.ts.map +1 -0
- package/dist/http/contrib/bodyValidator.test.js +58 -0
- package/dist/http/contrib/bodyValidator.test.js.map +1 -0
- package/dist/http/contrib/envValidator.d.ts +10 -0
- package/dist/http/contrib/envValidator.d.ts.map +1 -0
- package/dist/http/contrib/envValidator.js +12 -0
- package/dist/http/contrib/envValidator.js.map +1 -0
- package/dist/http/contrib/envValidator.test.d.ts +2 -0
- package/dist/http/contrib/envValidator.test.d.ts.map +1 -0
- package/dist/http/contrib/envValidator.test.js +49 -0
- package/dist/http/contrib/envValidator.test.js.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.d.ts +13 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.d.ts.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.js +22 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.js.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.test.d.ts +2 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.test.d.ts.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.test.js +39 -0
- package/dist/http/contrib/headerSignatureAuthorizer/index.test.js.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.d.ts +4 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.d.ts.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.js +13 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.js.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.test.d.ts +2 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.test.d.ts.map +1 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.test.js +9 -0
- package/dist/http/contrib/headerSignatureAuthorizer/lib.test.js.map +1 -0
- package/dist/http/contrib/headersNormalizer/index.d.ts +9 -0
- package/dist/http/contrib/headersNormalizer/index.d.ts.map +1 -0
- package/dist/http/contrib/headersNormalizer/index.js +8 -0
- package/dist/http/contrib/headersNormalizer/index.js.map +1 -0
- package/dist/http/contrib/headersNormalizer/index.test.d.ts +2 -0
- package/dist/http/contrib/headersNormalizer/index.test.d.ts.map +1 -0
- package/dist/http/contrib/headersNormalizer/index.test.js +38 -0
- package/dist/http/contrib/headersNormalizer/index.test.js.map +1 -0
- package/dist/http/contrib/headersNormalizer/lib.d.ts +11 -0
- package/dist/http/contrib/headersNormalizer/lib.d.ts.map +1 -0
- package/dist/http/contrib/headersNormalizer/lib.js +64 -0
- package/dist/http/contrib/headersNormalizer/lib.js.map +1 -0
- package/dist/http/contrib/headersNormalizer/lib.test.d.ts +2 -0
- package/dist/http/contrib/headersNormalizer/lib.test.d.ts.map +1 -0
- package/dist/http/contrib/headersNormalizer/lib.test.js +35 -0
- package/dist/http/contrib/headersNormalizer/lib.test.js.map +1 -0
- package/dist/http/contrib/headersNormalizer/types.d.ts +10 -0
- package/dist/http/contrib/headersNormalizer/types.d.ts.map +1 -0
- package/dist/http/contrib/headersNormalizer/types.js +2 -0
- package/dist/http/contrib/headersNormalizer/types.js.map +1 -0
- package/dist/http/contrib/headersValidator.d.ts +12 -0
- package/dist/http/contrib/headersValidator.d.ts.map +1 -0
- package/dist/http/contrib/headersValidator.js +15 -0
- package/dist/http/contrib/headersValidator.js.map +1 -0
- package/dist/http/contrib/headersValidator.test.d.ts +2 -0
- package/dist/http/contrib/headersValidator.test.d.ts.map +1 -0
- package/dist/http/contrib/headersValidator.test.js +46 -0
- package/dist/http/contrib/headersValidator.test.js.map +1 -0
- package/dist/http/contrib/helmetJsHeaders.d.ts +5 -0
- package/dist/http/contrib/helmetJsHeaders.d.ts.map +1 -0
- package/dist/http/contrib/helmetJsHeaders.js +25 -0
- package/dist/http/contrib/helmetJsHeaders.js.map +1 -0
- package/dist/http/contrib/helmetJsHeaders.test.d.ts +2 -0
- package/dist/http/contrib/helmetJsHeaders.test.d.ts.map +1 -0
- package/dist/http/contrib/helmetJsHeaders.test.js +18 -0
- package/dist/http/contrib/helmetJsHeaders.test.js.map +1 -0
- package/dist/http/contrib/honoAdapter.d.ts +16 -0
- package/dist/http/contrib/honoAdapter.d.ts.map +1 -0
- package/dist/http/contrib/honoAdapter.js +28 -0
- package/dist/http/contrib/honoAdapter.js.map +1 -0
- package/dist/http/contrib/honoAdapter.test.d.ts +2 -0
- package/dist/http/contrib/honoAdapter.test.d.ts.map +1 -0
- package/dist/http/contrib/honoAdapter.test.js +75 -0
- package/dist/http/contrib/honoAdapter.test.js.map +1 -0
- package/dist/http/contrib/identity.d.ts +4 -0
- package/dist/http/contrib/identity.d.ts.map +1 -0
- package/dist/http/contrib/identity.js +3 -0
- package/dist/http/contrib/identity.js.map +1 -0
- package/dist/http/contrib/identity.test.d.ts +2 -0
- package/dist/http/contrib/identity.test.d.ts.map +1 -0
- package/dist/http/contrib/identity.test.js +12 -0
- package/dist/http/contrib/identity.test.js.map +1 -0
- package/dist/http/contrib/index.d.ts +25 -0
- package/dist/http/contrib/index.d.ts.map +1 -0
- package/dist/http/contrib/index.js +25 -0
- package/dist/http/contrib/index.js.map +1 -0
- package/dist/http/contrib/jsonBodyParserRequest.d.ts +10 -0
- package/dist/http/contrib/jsonBodyParserRequest.d.ts.map +1 -0
- package/dist/http/contrib/jsonBodyParserRequest.js +22 -0
- package/dist/http/contrib/jsonBodyParserRequest.js.map +1 -0
- package/dist/http/contrib/jsonBodyParserRequest.test.d.ts +2 -0
- package/dist/http/contrib/jsonBodyParserRequest.test.d.ts.map +1 -0
- package/dist/http/contrib/jsonBodyParserRequest.test.js +37 -0
- package/dist/http/contrib/jsonBodyParserRequest.test.js.map +1 -0
- package/dist/http/contrib/jsonBodySerializerResponse.d.ts +9 -0
- package/dist/http/contrib/jsonBodySerializerResponse.d.ts.map +1 -0
- package/dist/http/contrib/jsonBodySerializerResponse.js +15 -0
- package/dist/http/contrib/jsonBodySerializerResponse.js.map +1 -0
- package/dist/http/contrib/jsonBodySerializerResponse.test.d.ts +2 -0
- package/dist/http/contrib/jsonBodySerializerResponse.test.d.ts.map +1 -0
- package/dist/http/contrib/jsonBodySerializerResponse.test.js +31 -0
- package/dist/http/contrib/jsonBodySerializerResponse.test.js.map +1 -0
- package/dist/http/contrib/jwtAuthenticator.d.ts +15 -0
- package/dist/http/contrib/jwtAuthenticator.d.ts.map +1 -0
- package/dist/http/contrib/jwtAuthenticator.js +28 -0
- package/dist/http/contrib/jwtAuthenticator.js.map +1 -0
- package/dist/http/contrib/jwtAuthenticator.test.d.ts +2 -0
- package/dist/http/contrib/jwtAuthenticator.test.d.ts.map +1 -0
- package/dist/http/contrib/jwtAuthenticator.test.js +88 -0
- package/dist/http/contrib/jwtAuthenticator.test.js.map +1 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.d.ts +15 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.d.ts.map +1 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.js +28 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.js.map +1 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.test.d.ts +2 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.test.d.ts.map +1 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.test.js +88 -0
- package/dist/http/contrib/jwtAuthenticatorRsa.test.js.map +1 -0
- package/dist/http/contrib/jwtDecoder.d.ts +13 -0
- package/dist/http/contrib/jwtDecoder.d.ts.map +1 -0
- package/dist/http/contrib/jwtDecoder.js +23 -0
- package/dist/http/contrib/jwtDecoder.js.map +1 -0
- package/dist/http/contrib/jwtDecoder.test.d.ts +2 -0
- package/dist/http/contrib/jwtDecoder.test.d.ts.map +1 -0
- package/dist/http/contrib/jwtDecoder.test.js +76 -0
- package/dist/http/contrib/jwtDecoder.test.js.map +1 -0
- package/dist/http/contrib/pathParametersValidator.d.ts +12 -0
- package/dist/http/contrib/pathParametersValidator.d.ts.map +1 -0
- package/dist/http/contrib/pathParametersValidator.js +15 -0
- package/dist/http/contrib/pathParametersValidator.js.map +1 -0
- package/dist/http/contrib/pathParametersValidator.test.d.ts +2 -0
- package/dist/http/contrib/pathParametersValidator.test.d.ts.map +1 -0
- package/dist/http/contrib/pathParametersValidator.test.js +46 -0
- package/dist/http/contrib/pathParametersValidator.test.js.map +1 -0
- package/dist/http/contrib/pathTokenAuthorizer.d.ts +13 -0
- package/dist/http/contrib/pathTokenAuthorizer.d.ts.map +1 -0
- package/dist/http/contrib/pathTokenAuthorizer.js +19 -0
- package/dist/http/contrib/pathTokenAuthorizer.js.map +1 -0
- package/dist/http/contrib/pathTokenAuthorizer.test.d.ts +2 -0
- package/dist/http/contrib/pathTokenAuthorizer.test.d.ts.map +1 -0
- package/dist/http/contrib/pathTokenAuthorizer.test.js +29 -0
- package/dist/http/contrib/pathTokenAuthorizer.test.js.map +1 -0
- package/dist/http/contrib/queryStringValidator.d.ts +12 -0
- package/dist/http/contrib/queryStringValidator.d.ts.map +1 -0
- package/dist/http/contrib/queryStringValidator.js +15 -0
- package/dist/http/contrib/queryStringValidator.js.map +1 -0
- package/dist/http/contrib/queryStringValidator.test.d.ts +2 -0
- package/dist/http/contrib/queryStringValidator.test.d.ts.map +1 -0
- package/dist/http/contrib/queryStringValidator.test.js +46 -0
- package/dist/http/contrib/queryStringValidator.test.js.map +1 -0
- package/dist/http/contrib/requestResponseLogger.d.ts +5 -0
- package/dist/http/contrib/requestResponseLogger.d.ts.map +1 -0
- package/dist/http/contrib/requestResponseLogger.js +8 -0
- package/dist/http/contrib/requestResponseLogger.js.map +1 -0
- package/dist/http/contrib/requestResponseLogger.test.d.ts +2 -0
- package/dist/http/contrib/requestResponseLogger.test.d.ts.map +1 -0
- package/dist/http/contrib/requestResponseLogger.test.js +18 -0
- package/dist/http/contrib/requestResponseLogger.test.js.map +1 -0
- package/dist/http/contrib/responseProcessor.d.ts +8 -0
- package/dist/http/contrib/responseProcessor.d.ts.map +1 -0
- package/dist/http/contrib/responseProcessor.js +16 -0
- package/dist/http/contrib/responseProcessor.js.map +1 -0
- package/dist/http/contrib/responseProcessor.test.d.ts +2 -0
- package/dist/http/contrib/responseProcessor.test.d.ts.map +1 -0
- package/dist/http/contrib/responseProcessor.test.js +29 -0
- package/dist/http/contrib/responseProcessor.test.js.map +1 -0
- package/dist/http/contrib/standardRequestResponseAdapter.d.ts +16 -0
- package/dist/http/contrib/standardRequestResponseAdapter.d.ts.map +1 -0
- package/dist/http/contrib/standardRequestResponseAdapter.js +27 -0
- package/dist/http/contrib/standardRequestResponseAdapter.js.map +1 -0
- package/dist/http/contrib/standardRequestResponseAdapter.test.d.ts +2 -0
- package/dist/http/contrib/standardRequestResponseAdapter.test.d.ts.map +1 -0
- package/dist/http/contrib/standardRequestResponseAdapter.test.js +85 -0
- package/dist/http/contrib/standardRequestResponseAdapter.test.js.map +1 -0
- package/dist/http/contrib/trivial.d.ts +5 -0
- package/dist/http/contrib/trivial.d.ts.map +1 -0
- package/dist/http/contrib/trivial.js +9 -0
- package/dist/http/contrib/trivial.js.map +1 -0
- package/dist/http/contrib/trivial.test.d.ts +2 -0
- package/dist/http/contrib/trivial.test.d.ts.map +1 -0
- package/dist/http/contrib/trivial.test.js +14 -0
- package/dist/http/contrib/trivial.test.js.map +1 -0
- package/dist/http/index.d.ts +6 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +6 -0
- package/dist/http/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/Logger.d.ts +23 -0
- package/dist/lib/Logger.d.ts.map +1 -0
- package/dist/lib/Logger.js +30 -0
- package/dist/lib/Logger.js.map +1 -0
- package/dist/lib/Logger.test.d.ts +2 -0
- package/dist/lib/Logger.test.d.ts.map +1 -0
- package/dist/lib/Logger.test.js +54 -0
- package/dist/lib/Logger.test.js.map +1 -0
- package/dist/lib/MiddlewareError.d.ts +10 -0
- package/dist/lib/MiddlewareError.d.ts.map +1 -0
- package/dist/lib/MiddlewareError.js +20 -0
- package/dist/lib/MiddlewareError.js.map +1 -0
- package/dist/lib/MiddlewareError.test.d.ts +2 -0
- package/dist/lib/MiddlewareError.test.d.ts.map +1 -0
- package/dist/lib/MiddlewareError.test.js +55 -0
- package/dist/lib/MiddlewareError.test.js.map +1 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/utils.d.ts +7 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +11 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.test.d.ts +2 -0
- package/dist/lib/utils.test.d.ts.map +1 -0
- package/dist/lib/utils.test.js +47 -0
- package/dist/lib/utils.test.js.map +1 -0
- package/dist/test/kitchen-sink.test.d.ts +2 -0
- package/dist/test/kitchen-sink.test.d.ts.map +1 -0
- package/dist/test/kitchen-sink.test.js +76 -0
- package/dist/test/kitchen-sink.test.js.map +1 -0
- package/dist/test/round-trip.test.d.ts +2 -0
- package/dist/test/round-trip.test.d.ts.map +1 -0
- package/dist/test/round-trip.test.js +75 -0
- package/dist/test/round-trip.test.js.map +1 -0
- package/dist/test/test-common.d.ts +17 -0
- package/dist/test/test-common.d.ts.map +1 -0
- package/dist/test/test-common.js +25 -0
- package/dist/test/test-common.js.map +1 -0
- package/package.json +265 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Result, ResultAsync } from 'neverthrow';
|
|
2
|
+
import type { MiddlewareError } from './MiddlewareError.js';
|
|
3
|
+
export declare function sanitizeRecord(record?: Record<string, string | undefined>): Record<string, string>;
|
|
4
|
+
export declare function fromPromise<T>(thunk: () => Promise<T>, onError?: (e: unknown) => MiddlewareError): ResultAsync<T, MiddlewareError>;
|
|
5
|
+
export declare const tryJsonParse: (input: string) => Result<unknown, MiddlewareError>;
|
|
6
|
+
export declare const tryJsonStringify: (input: unknown) => Result<string, MiddlewareError>;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAElG;AAED,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACvB,OAAO,GAAE,CAAC,CAAC,EAAE,OAAO,KAAK,eAAmC,GAC3D,WAAW,CAAC,CAAC,EAAE,eAAe,CAAC,CAEjC;AAED,eAAO,MAAM,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,OAAO,EAAE,eAAe,CAG5E,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,EAAE,eAAe,CAGhF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Result, ResultAsync } from 'neverthrow';
|
|
2
|
+
import { toMiddlewareError } from './MiddlewareError.js';
|
|
3
|
+
export function sanitizeRecord(record) {
|
|
4
|
+
return Object.fromEntries(Object.entries(record ?? {}).map(([k, v]) => [k, v ?? '']));
|
|
5
|
+
}
|
|
6
|
+
export function fromPromise(thunk, onError = toMiddlewareError) {
|
|
7
|
+
return ResultAsync.fromPromise(thunk(), onError);
|
|
8
|
+
}
|
|
9
|
+
export const tryJsonParse = Result.fromThrowable((input) => JSON.parse(input), (e) => toMiddlewareError(e, 'Invalid JSON'));
|
|
10
|
+
export const tryJsonStringify = Result.fromThrowable((input) => JSON.stringify(input), (e) => toMiddlewareError(e, 'JSON stringify failed'));
|
|
11
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,UAAU,cAAc,CAAC,MAA2C;IACxE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,KAAuB,EACvB,UAA2C,iBAAiB;IAE5D,OAAO,WAAW,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAwD,MAAM,CAAC,aAAa,CACnG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAY,EAC/C,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,cAAc,CAAC,CAC5C,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAwD,MAAM,CAAC,aAAa,CACvG,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EACzC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,uBAAuB,CAAC,CACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/lib/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { fromPromise, sanitizeRecord, tryJsonParse, tryJsonStringify } from './utils.js';
|
|
3
|
+
describe('sanitizeRecord', () => {
|
|
4
|
+
it('returns an empty object for undefined', () => {
|
|
5
|
+
expect(sanitizeRecord(undefined)).toEqual({});
|
|
6
|
+
});
|
|
7
|
+
it('replaces undefined values with empty strings', () => {
|
|
8
|
+
expect(sanitizeRecord({ a: 'x', b: undefined })).toEqual({ a: 'x', b: '' });
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe('fromPromise', () => {
|
|
12
|
+
it('resolves to Ok on success', async () => {
|
|
13
|
+
const result = await fromPromise(async () => Promise.resolve(42));
|
|
14
|
+
expect(result.isOk() && result.value).toBe(42);
|
|
15
|
+
});
|
|
16
|
+
it('resolves to Err via toMiddlewareError on rejection', async () => {
|
|
17
|
+
const result = await fromPromise(async () => Promise.reject(new Error('boom')));
|
|
18
|
+
expect(result.isErr() && result.error.message).toBe('boom');
|
|
19
|
+
});
|
|
20
|
+
it('accepts a custom error mapper', async () => {
|
|
21
|
+
const result = await fromPromise(async () => Promise.reject(new Error('boom')), () => ({ _tag: 'MiddlewareError', message: 'mapped' }));
|
|
22
|
+
expect(result.isErr() && result.error.message).toBe('mapped');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('tryJsonParse', () => {
|
|
26
|
+
it('parses valid JSON', () => {
|
|
27
|
+
const result = tryJsonParse('{"a":1}');
|
|
28
|
+
expect(result.isOk() && result.value).toEqual({ a: 1 });
|
|
29
|
+
});
|
|
30
|
+
it('returns Err for invalid JSON', () => {
|
|
31
|
+
const result = tryJsonParse('not json');
|
|
32
|
+
expect(result.isErr() && result.error.message).toBe('Invalid JSON');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('tryJsonStringify', () => {
|
|
36
|
+
it('stringifies a plain object', () => {
|
|
37
|
+
const result = tryJsonStringify({ a: 1 });
|
|
38
|
+
expect(result.isOk() && result.value).toBe('{"a":1}');
|
|
39
|
+
});
|
|
40
|
+
it('returns Err for a circular value', () => {
|
|
41
|
+
const circ = {};
|
|
42
|
+
circ.self = circ;
|
|
43
|
+
const result = tryJsonStringify(circ);
|
|
44
|
+
expect(result.isErr() && result.error.message).toBe('JSON stringify failed');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../src/lib/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEzF,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,C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ink.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { okAsyncR } from '@konker.dev/neverthrow-r/constructors';
|
|
2
|
+
import { pipe } from '@konker.dev/neverthrow-r/pipe';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { middleware as base64BodyDecoder } from '../http/contrib/base64BodyDecoder.js';
|
|
6
|
+
import { middleware as basicAuthDecoder } from '../http/contrib/basicAuthDecoder.js';
|
|
7
|
+
import { middleware as bodyValidator } from '../http/contrib/bodyValidator.js';
|
|
8
|
+
import { middleware as envValidator } from '../http/contrib/envValidator.js';
|
|
9
|
+
import { middleware as headersNormalizer } from '../http/contrib/headersNormalizer/index.js';
|
|
10
|
+
import { middleware as headersValidator } from '../http/contrib/headersValidator.js';
|
|
11
|
+
import { middleware as helmetJsHeaders } from '../http/contrib/helmetJsHeaders.js';
|
|
12
|
+
import { middleware as jsonBodyParserRequest } from '../http/contrib/jsonBodyParserRequest.js';
|
|
13
|
+
import { middleware as pathParametersValidator } from '../http/contrib/pathParametersValidator.js';
|
|
14
|
+
import { middleware as queryStringValidator } from '../http/contrib/queryStringValidator.js';
|
|
15
|
+
import { EMPTY_REQUEST_W, makeRequestW } from '../http/RequestW.js';
|
|
16
|
+
import { EMPTY_RESPONSE_W, makeResponseW } from '../http/ResponseW.js';
|
|
17
|
+
import { recordingLogger } from './test-common.js';
|
|
18
|
+
const envSchema = z.object({
|
|
19
|
+
KITCHEN_SINK_ENV: z.literal('ready'),
|
|
20
|
+
});
|
|
21
|
+
const headerSchema = z.object({
|
|
22
|
+
authorization: z.string().startsWith('Basic '),
|
|
23
|
+
'x-base64': z.literal('1'),
|
|
24
|
+
});
|
|
25
|
+
const querySchema = z.object({
|
|
26
|
+
foo: z.literal('bar'),
|
|
27
|
+
page: z.coerce.number(),
|
|
28
|
+
});
|
|
29
|
+
const pathSchema = z.object({
|
|
30
|
+
slug: z.literal('hello'),
|
|
31
|
+
});
|
|
32
|
+
const bodySchema = z.object({
|
|
33
|
+
name: z.literal('Konrad'),
|
|
34
|
+
});
|
|
35
|
+
function innerHandler(req) {
|
|
36
|
+
return okAsyncR(makeResponseW(EMPTY_RESPONSE_W, {
|
|
37
|
+
body: {
|
|
38
|
+
userId: req.userId,
|
|
39
|
+
slug: req.pathParameters.slug,
|
|
40
|
+
page: req.queryStringParameters.page,
|
|
41
|
+
name: req.body.name,
|
|
42
|
+
env: req.validatedEnv.KITCHEN_SINK_ENV,
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
const stack = pipe(innerHandler, envValidator(envSchema), bodyValidator(bodySchema), jsonBodyParserRequest(), base64BodyDecoder((req) => req.headers['x-base64'] === '1'), queryStringValidator(querySchema), pathParametersValidator(pathSchema), headersValidator(headerSchema), basicAuthDecoder(), headersNormalizer(), helmetJsHeaders());
|
|
47
|
+
describe('integration: kitchen sink middleware stack', () => {
|
|
48
|
+
it('runs a broad composed stack successfully', async () => {
|
|
49
|
+
const oldEnv = process.env;
|
|
50
|
+
process.env = { ...oldEnv, KITCHEN_SINK_ENV: 'ready' };
|
|
51
|
+
const { logger } = recordingLogger();
|
|
52
|
+
const request = makeRequestW(EMPTY_REQUEST_W, {
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: 'Basic dXNlcjA6c2VjcmV0LTA=',
|
|
55
|
+
'X-Base64': '1',
|
|
56
|
+
},
|
|
57
|
+
queryStringParameters: { foo: 'bar', page: '2' },
|
|
58
|
+
pathParameters: { slug: 'hello' },
|
|
59
|
+
body: Buffer.from('{"name":"Konrad"}').toString('base64'),
|
|
60
|
+
});
|
|
61
|
+
const result = await stack(request)({ logger });
|
|
62
|
+
process.env = oldEnv;
|
|
63
|
+
expect(result.isOk()).toBe(true);
|
|
64
|
+
if (result.isOk()) {
|
|
65
|
+
expect(result.value.headers['X-Content-Type-Options']).toBe('nosniff');
|
|
66
|
+
expect(result.value.body).toEqual({
|
|
67
|
+
userId: 'user0',
|
|
68
|
+
slug: 'hello',
|
|
69
|
+
page: 2,
|
|
70
|
+
name: 'Konrad',
|
|
71
|
+
env: 'ready',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=kitchen-sink.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kitchen-sink.test.js","sourceRoot":"","sources":["../../src/test/kitchen-sink.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC7F,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,UAAU,IAAI,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,UAAU,IAAI,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,YAAY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AC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACvE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;gBAChC,MAAM,EAAE,OAAO;gBACf,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,CAAC;gBACP,IAAI,EAAE,QAAQ;gBACd,GAAG,EAAE,OAAO;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round-trip.test.d.ts","sourceRoot":"","sources":["../../src/test/round-trip.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { okAsyncR } from '@konker.dev/neverthrow-r/constructors';
|
|
2
|
+
import { pipe } from '@konker.dev/neverthrow-r/pipe';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { middleware as apiGatewayProxyEventV2Adapter } from '../http/contrib/apiGatewayProxyEventV2Adapter.js';
|
|
6
|
+
import { middleware as bodyValidator } from '../http/contrib/bodyValidator.js';
|
|
7
|
+
import { middleware as jsonBodyParserRequest } from '../http/contrib/jsonBodyParserRequest.js';
|
|
8
|
+
import { middleware as jsonBodySerializerResponse } from '../http/contrib/jsonBodySerializerResponse.js';
|
|
9
|
+
import { EMPTY_RESPONSE_W, makeResponseW } from '../http/ResponseW.js';
|
|
10
|
+
import { recordingLogger } from './test-common.js';
|
|
11
|
+
const payloadSchema = z.object({ name: z.string() });
|
|
12
|
+
// --- fixture API Gateway events -----------------------------------------
|
|
13
|
+
function fixtureEvent(body) {
|
|
14
|
+
return {
|
|
15
|
+
version: '2.0',
|
|
16
|
+
routeKey: 'POST /greet',
|
|
17
|
+
rawPath: '/greet',
|
|
18
|
+
rawQueryString: '',
|
|
19
|
+
headers: { 'content-type': 'application/json' },
|
|
20
|
+
queryStringParameters: undefined,
|
|
21
|
+
pathParameters: undefined,
|
|
22
|
+
requestContext: {
|
|
23
|
+
accountId: '123',
|
|
24
|
+
apiId: 'abc',
|
|
25
|
+
domainName: 'example.com',
|
|
26
|
+
domainPrefix: 'example',
|
|
27
|
+
http: {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
path: '/greet',
|
|
30
|
+
protocol: 'HTTP/1.1',
|
|
31
|
+
sourceIp: '127.0.0.1',
|
|
32
|
+
userAgent: 'integration-test',
|
|
33
|
+
},
|
|
34
|
+
requestId: 'req-1',
|
|
35
|
+
routeKey: 'POST /greet',
|
|
36
|
+
stage: '$default',
|
|
37
|
+
time: '1/Jan/2026:00:00:00 +0000',
|
|
38
|
+
timeEpoch: 0,
|
|
39
|
+
},
|
|
40
|
+
body,
|
|
41
|
+
isBase64Encoded: false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function innerHandler(req) {
|
|
45
|
+
return okAsyncR(makeResponseW(EMPTY_RESPONSE_W, { body: { greeting: `hello, ${req.body.name}!` } }));
|
|
46
|
+
}
|
|
47
|
+
// --- composed stack ------------------------------------------------------
|
|
48
|
+
//
|
|
49
|
+
// Outermost is the adapter (raw event in / proxy result out). Inside that
|
|
50
|
+
// the serializer turns the inner structured response body into a string.
|
|
51
|
+
// Then the parser converts the incoming string body to `unknown`, and the
|
|
52
|
+
// validator narrows it to Payload before the inner handler runs.
|
|
53
|
+
const stack = pipe(innerHandler, bodyValidator(payloadSchema), jsonBodyParserRequest(), jsonBodySerializerResponse(), apiGatewayProxyEventV2Adapter());
|
|
54
|
+
describe('integration: adapter → serializer → parser → validator → inner', () => {
|
|
55
|
+
it('round-trips a JSON request/response through the full stack', async () => {
|
|
56
|
+
const { logger } = recordingLogger();
|
|
57
|
+
const result = await stack(fixtureEvent('{"name":"world"}'))({ logger });
|
|
58
|
+
expect(result.isOk()).toBe(true);
|
|
59
|
+
if (result.isOk()) {
|
|
60
|
+
expect(result.value.statusCode).toBe(200);
|
|
61
|
+
expect(JSON.parse(result.value.body)).toEqual({ greeting: 'hello, world!' });
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
it('fails with a MiddlewareError when the body is not valid JSON', async () => {
|
|
65
|
+
const { logger } = recordingLogger();
|
|
66
|
+
const result = await stack(fixtureEvent('not json'))({ logger });
|
|
67
|
+
expect(result.isErr() && result.error.message).toBe('Invalid JSON');
|
|
68
|
+
});
|
|
69
|
+
it('fails with a MiddlewareError when the body fails validation', async () => {
|
|
70
|
+
const { logger } = recordingLogger();
|
|
71
|
+
const result = await stack(fixtureEvent('{"name":42}'))({ logger });
|
|
72
|
+
expect(result.isErr() && result.error.message).toBe('Body validation failed');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=round-trip.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round-trip.test.js","sourceRoot":"","sources":["../../src/test/round-trip.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,IAAI,6BAA6B,EAAE,MAAM,kDAAkD,CAAC;AAC/G,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,UAAU,IAAI,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,UAAU,IAAI,0BAA0B,EAAE,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AAI,EAAE;QAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ResultAsyncR } from '@konker.dev/neverthrow-r/types';
|
|
2
|
+
import type { Rec } from '../http/RequestResponseHandler.js';
|
|
3
|
+
import { type RequestW } from '../http/RequestW.js';
|
|
4
|
+
import { type ResponseW } from '../http/ResponseW.js';
|
|
5
|
+
import type { Logger } from '../lib/Logger.js';
|
|
6
|
+
export type LogCall = {
|
|
7
|
+
readonly level: keyof Logger;
|
|
8
|
+
readonly args: ReadonlyArray<unknown>;
|
|
9
|
+
};
|
|
10
|
+
export declare function recordingLogger(): {
|
|
11
|
+
logger: Logger;
|
|
12
|
+
calls: Array<LogCall>;
|
|
13
|
+
};
|
|
14
|
+
/** Builds an inner handler that returns `EMPTY_RESPONSE_W` for any input. */
|
|
15
|
+
export declare const echoHandler: <I extends Rec, O extends Rec = Rec, R = unknown>(body?: O) => ((i: RequestW<I>) => ResultAsyncR<R, ResponseW<O>, never>);
|
|
16
|
+
export declare const sampleRequestW: RequestW;
|
|
17
|
+
//# sourceMappingURL=test-common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-common.d.ts","sourceRoot":"","sources":["../../src/test/test-common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAgB,eAAe,IAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CAgB3E;AAED,6EAA6E;AAC7E,eAAO,MAAM,WAAW,GACrB,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,EAC9C,OAAO,CAAC,KACP,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAKxC,CAAC;AAEvB,eAAO,MAAM,cAAc,EAAE,QAA0B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { okAsyncR } from '@konker.dev/neverthrow-r/constructors';
|
|
2
|
+
import { EMPTY_REQUEST_W } from '../http/RequestW.js';
|
|
3
|
+
import { EMPTY_RESPONSE_W } from '../http/ResponseW.js';
|
|
4
|
+
export function recordingLogger() {
|
|
5
|
+
const calls = [];
|
|
6
|
+
const make = (level) => (...args) => {
|
|
7
|
+
calls.push({ level, args });
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
calls,
|
|
11
|
+
logger: {
|
|
12
|
+
debug: make('debug'),
|
|
13
|
+
info: make('info'),
|
|
14
|
+
warn: make('warn'),
|
|
15
|
+
error: make('error'),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Builds an inner handler that returns `EMPTY_RESPONSE_W` for any input. */
|
|
20
|
+
export const echoHandler = (body) => (_i) => okAsyncR({
|
|
21
|
+
...EMPTY_RESPONSE_W,
|
|
22
|
+
...(body ?? {}),
|
|
23
|
+
});
|
|
24
|
+
export const sampleRequestW = EMPTY_REQUEST_W;
|
|
25
|
+
//# sourceMappingURL=test-common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-common.js","sourceRoot":"","sources":["../../src/test/test-common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAIjE,OAAO,EAAE,eAAe,EAAiB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,sBAAsB,CAAC;AAQxE,MAAM,UAAU,eAAe;IAC7B,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,MAAM,IAAI,GACR,CAAC,KAAmB,EAAE,EAAE,CACxB,CAAC,GAAG,IAA4B,EAAE,EAAE;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAC;IACJ,OAAO;QACL,KAAK;QACL,MAAM,EAAE;YACN,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;YACpB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAClB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;SACrB;KACF,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GACtB,CACE,IAAQ,EACoD,EAAE,CAChE,CAAC,EAAE,EAAE,EAAE,CACL,QAAQ,CAAe;IACrB,GAAG,gBAAgB;IACnB,GAAG,CAAC,IAAI,IAAK,EAAQ,CAAC;CACP,CAAC,CAAC;AAEvB,MAAM,CAAC,MAAM,cAAc,GAAa,eAAe,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@konker.dev/neverthrow-r-middleware",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": "Konrad Markus <mail@konker.dev>",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"description": "Type-safe HTTP middleware system built on @konker.dev/neverthrow-r",
|
|
8
|
+
"homepage": "https://konker.dev/",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"middleware",
|
|
11
|
+
"node",
|
|
12
|
+
"typescript",
|
|
13
|
+
"functional-programming",
|
|
14
|
+
"neverthrow"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/konker/konker.dev/packages/neverthrow-r-middleware"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./http/contrib/apiGatewayProxyEventV2Adapter": {
|
|
27
|
+
"types": "./dist/http/contrib/apiGatewayProxyEventV2Adapter.d.ts",
|
|
28
|
+
"import": "./dist/http/contrib/apiGatewayProxyEventV2Adapter.js"
|
|
29
|
+
},
|
|
30
|
+
"./http/contrib/base64BodyDecoder": {
|
|
31
|
+
"types": "./dist/http/contrib/base64BodyDecoder.d.ts",
|
|
32
|
+
"import": "./dist/http/contrib/base64BodyDecoder.js"
|
|
33
|
+
},
|
|
34
|
+
"./http/contrib/basicAuthAuthenticator": {
|
|
35
|
+
"types": "./dist/http/contrib/basicAuthAuthenticator.d.ts",
|
|
36
|
+
"import": "./dist/http/contrib/basicAuthAuthenticator.js"
|
|
37
|
+
},
|
|
38
|
+
"./http/contrib/basicAuthDecoder": {
|
|
39
|
+
"types": "./dist/http/contrib/basicAuthDecoder.d.ts",
|
|
40
|
+
"import": "./dist/http/contrib/basicAuthDecoder.js"
|
|
41
|
+
},
|
|
42
|
+
"./http/contrib/bodyValidator": {
|
|
43
|
+
"types": "./dist/http/contrib/bodyValidator.d.ts",
|
|
44
|
+
"import": "./dist/http/contrib/bodyValidator.js"
|
|
45
|
+
},
|
|
46
|
+
"./http/contrib/envValidator": {
|
|
47
|
+
"types": "./dist/http/contrib/envValidator.d.ts",
|
|
48
|
+
"import": "./dist/http/contrib/envValidator.js"
|
|
49
|
+
},
|
|
50
|
+
"./http/contrib/headerSignatureAuthorizer": {
|
|
51
|
+
"types": "./dist/http/contrib/headerSignatureAuthorizer/index.d.ts",
|
|
52
|
+
"import": "./dist/http/contrib/headerSignatureAuthorizer/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./http/contrib/headerSignatureAuthorizer/lib": {
|
|
55
|
+
"types": "./dist/http/contrib/headerSignatureAuthorizer/lib.d.ts",
|
|
56
|
+
"import": "./dist/http/contrib/headerSignatureAuthorizer/lib.js"
|
|
57
|
+
},
|
|
58
|
+
"./http/contrib/headersNormalizer": {
|
|
59
|
+
"types": "./dist/http/contrib/headersNormalizer/index.d.ts",
|
|
60
|
+
"import": "./dist/http/contrib/headersNormalizer/index.js"
|
|
61
|
+
},
|
|
62
|
+
"./http/contrib/headersNormalizer/lib": {
|
|
63
|
+
"types": "./dist/http/contrib/headersNormalizer/lib.d.ts",
|
|
64
|
+
"import": "./dist/http/contrib/headersNormalizer/lib.js"
|
|
65
|
+
},
|
|
66
|
+
"./http/contrib/headersNormalizer/types": {
|
|
67
|
+
"types": "./dist/http/contrib/headersNormalizer/types.d.ts",
|
|
68
|
+
"import": "./dist/http/contrib/headersNormalizer/types.js"
|
|
69
|
+
},
|
|
70
|
+
"./http/contrib/headersValidator": {
|
|
71
|
+
"types": "./dist/http/contrib/headersValidator.d.ts",
|
|
72
|
+
"import": "./dist/http/contrib/headersValidator.js"
|
|
73
|
+
},
|
|
74
|
+
"./http/contrib/helmetJsHeaders": {
|
|
75
|
+
"types": "./dist/http/contrib/helmetJsHeaders.d.ts",
|
|
76
|
+
"import": "./dist/http/contrib/helmetJsHeaders.js"
|
|
77
|
+
},
|
|
78
|
+
"./http/contrib/honoAdapter": {
|
|
79
|
+
"types": "./dist/http/contrib/honoAdapter.d.ts",
|
|
80
|
+
"import": "./dist/http/contrib/honoAdapter.js"
|
|
81
|
+
},
|
|
82
|
+
"./http/contrib/identity": {
|
|
83
|
+
"types": "./dist/http/contrib/identity.d.ts",
|
|
84
|
+
"import": "./dist/http/contrib/identity.js"
|
|
85
|
+
},
|
|
86
|
+
"./http/contrib": {
|
|
87
|
+
"types": "./dist/http/contrib/index.d.ts",
|
|
88
|
+
"import": "./dist/http/contrib/index.js"
|
|
89
|
+
},
|
|
90
|
+
"./http/contrib/jsonBodyParserRequest": {
|
|
91
|
+
"types": "./dist/http/contrib/jsonBodyParserRequest.d.ts",
|
|
92
|
+
"import": "./dist/http/contrib/jsonBodyParserRequest.js"
|
|
93
|
+
},
|
|
94
|
+
"./http/contrib/jsonBodySerializerResponse": {
|
|
95
|
+
"types": "./dist/http/contrib/jsonBodySerializerResponse.d.ts",
|
|
96
|
+
"import": "./dist/http/contrib/jsonBodySerializerResponse.js"
|
|
97
|
+
},
|
|
98
|
+
"./http/contrib/jwtAuthenticator": {
|
|
99
|
+
"types": "./dist/http/contrib/jwtAuthenticator.d.ts",
|
|
100
|
+
"import": "./dist/http/contrib/jwtAuthenticator.js"
|
|
101
|
+
},
|
|
102
|
+
"./http/contrib/jwtAuthenticatorRsa": {
|
|
103
|
+
"types": "./dist/http/contrib/jwtAuthenticatorRsa.d.ts",
|
|
104
|
+
"import": "./dist/http/contrib/jwtAuthenticatorRsa.js"
|
|
105
|
+
},
|
|
106
|
+
"./http/contrib/jwtDecoder": {
|
|
107
|
+
"types": "./dist/http/contrib/jwtDecoder.d.ts",
|
|
108
|
+
"import": "./dist/http/contrib/jwtDecoder.js"
|
|
109
|
+
},
|
|
110
|
+
"./http/contrib/pathParametersValidator": {
|
|
111
|
+
"types": "./dist/http/contrib/pathParametersValidator.d.ts",
|
|
112
|
+
"import": "./dist/http/contrib/pathParametersValidator.js"
|
|
113
|
+
},
|
|
114
|
+
"./http/contrib/pathTokenAuthorizer": {
|
|
115
|
+
"types": "./dist/http/contrib/pathTokenAuthorizer.d.ts",
|
|
116
|
+
"import": "./dist/http/contrib/pathTokenAuthorizer.js"
|
|
117
|
+
},
|
|
118
|
+
"./http/contrib/queryStringValidator": {
|
|
119
|
+
"types": "./dist/http/contrib/queryStringValidator.d.ts",
|
|
120
|
+
"import": "./dist/http/contrib/queryStringValidator.js"
|
|
121
|
+
},
|
|
122
|
+
"./http/contrib/requestResponseLogger": {
|
|
123
|
+
"types": "./dist/http/contrib/requestResponseLogger.d.ts",
|
|
124
|
+
"import": "./dist/http/contrib/requestResponseLogger.js"
|
|
125
|
+
},
|
|
126
|
+
"./http/contrib/responseProcessor": {
|
|
127
|
+
"types": "./dist/http/contrib/responseProcessor.d.ts",
|
|
128
|
+
"import": "./dist/http/contrib/responseProcessor.js"
|
|
129
|
+
},
|
|
130
|
+
"./http/contrib/standardRequestResponseAdapter": {
|
|
131
|
+
"types": "./dist/http/contrib/standardRequestResponseAdapter.d.ts",
|
|
132
|
+
"import": "./dist/http/contrib/standardRequestResponseAdapter.js"
|
|
133
|
+
},
|
|
134
|
+
"./http/contrib/trivial": {
|
|
135
|
+
"types": "./dist/http/contrib/trivial.d.ts",
|
|
136
|
+
"import": "./dist/http/contrib/trivial.js"
|
|
137
|
+
},
|
|
138
|
+
"./http/HttpApiError": {
|
|
139
|
+
"types": "./dist/http/HttpApiError.d.ts",
|
|
140
|
+
"import": "./dist/http/HttpApiError.js"
|
|
141
|
+
},
|
|
142
|
+
"./http": {
|
|
143
|
+
"types": "./dist/http/index.d.ts",
|
|
144
|
+
"import": "./dist/http/index.js"
|
|
145
|
+
},
|
|
146
|
+
"./http/Rec": {
|
|
147
|
+
"types": "./dist/http/Rec.d.ts",
|
|
148
|
+
"import": "./dist/http/Rec.js"
|
|
149
|
+
},
|
|
150
|
+
"./http/RequestResponseHandler": {
|
|
151
|
+
"types": "./dist/http/RequestResponseHandler.d.ts",
|
|
152
|
+
"import": "./dist/http/RequestResponseHandler.js"
|
|
153
|
+
},
|
|
154
|
+
"./http/RequestW": {
|
|
155
|
+
"types": "./dist/http/RequestW.d.ts",
|
|
156
|
+
"import": "./dist/http/RequestW.js"
|
|
157
|
+
},
|
|
158
|
+
"./http/ResponseW": {
|
|
159
|
+
"types": "./dist/http/ResponseW.d.ts",
|
|
160
|
+
"import": "./dist/http/ResponseW.js"
|
|
161
|
+
},
|
|
162
|
+
"./lib": {
|
|
163
|
+
"types": "./dist/lib/index.d.ts",
|
|
164
|
+
"import": "./dist/lib/index.js"
|
|
165
|
+
},
|
|
166
|
+
"./lib/Logger": {
|
|
167
|
+
"types": "./dist/lib/Logger.d.ts",
|
|
168
|
+
"import": "./dist/lib/Logger.js"
|
|
169
|
+
},
|
|
170
|
+
"./lib/MiddlewareError": {
|
|
171
|
+
"types": "./dist/lib/MiddlewareError.d.ts",
|
|
172
|
+
"import": "./dist/lib/MiddlewareError.js"
|
|
173
|
+
},
|
|
174
|
+
"./lib/utils": {
|
|
175
|
+
"types": "./dist/lib/utils.d.ts",
|
|
176
|
+
"import": "./dist/lib/utils.js"
|
|
177
|
+
},
|
|
178
|
+
"./test/test-common": {
|
|
179
|
+
"types": "./dist/test/test-common.d.ts",
|
|
180
|
+
"import": "./dist/test/test-common.js"
|
|
181
|
+
},
|
|
182
|
+
"./handler": {
|
|
183
|
+
"types": "./dist/handler.d.ts",
|
|
184
|
+
"import": "./dist/handler.js"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"files": [
|
|
188
|
+
"dist/**/*",
|
|
189
|
+
"!dist/**/*.test.*"
|
|
190
|
+
],
|
|
191
|
+
"main": "dist/index.js",
|
|
192
|
+
"peerDependencies": {
|
|
193
|
+
"@standard-schema/spec": "^1.0.0",
|
|
194
|
+
"aws-lambda": "^1.0.7",
|
|
195
|
+
"hono": "^4.0.0",
|
|
196
|
+
"@konker.dev/neverthrow-r-schema": "0.0.1"
|
|
197
|
+
},
|
|
198
|
+
"peerDependenciesMeta": {
|
|
199
|
+
"@konker.dev/neverthrow-r-schema": {
|
|
200
|
+
"optional": true
|
|
201
|
+
},
|
|
202
|
+
"@standard-schema/spec": {
|
|
203
|
+
"optional": true
|
|
204
|
+
},
|
|
205
|
+
"aws-lambda": {
|
|
206
|
+
"optional": true
|
|
207
|
+
},
|
|
208
|
+
"hono": {
|
|
209
|
+
"optional": true
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"dependencies": {
|
|
213
|
+
"neverthrow": "^8.2.0",
|
|
214
|
+
"@konker.dev/neverthrow-r": "0.0.1",
|
|
215
|
+
"@konker.dev/neverthrow-r-auth-utils": "0.0.1",
|
|
216
|
+
"@konker.dev/neverthrow-r-utils": "0.0.1"
|
|
217
|
+
},
|
|
218
|
+
"devDependencies": {
|
|
219
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
220
|
+
"@eslint/compat": "^2.0.1",
|
|
221
|
+
"@eslint/js": "^9.39.2",
|
|
222
|
+
"@konker.dev/common-config": "^0.8.0",
|
|
223
|
+
"@standard-schema/spec": "^1.0.0",
|
|
224
|
+
"@types/aws-lambda": "^8.10.159",
|
|
225
|
+
"@types/node": "^25.8.0",
|
|
226
|
+
"@vitest/coverage-istanbul": "^4.1.6",
|
|
227
|
+
"eslint": "^9.39.2",
|
|
228
|
+
"eslint-plugin-fp": "^2.3.0",
|
|
229
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
230
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
231
|
+
"eslint-plugin-sort-destructure-keys": "^2.0.0",
|
|
232
|
+
"hono": "^4.12.21",
|
|
233
|
+
"leasot": "^14.4.0",
|
|
234
|
+
"madge": "^8.0.0",
|
|
235
|
+
"prettier": "^3.8.3",
|
|
236
|
+
"tsx": "^4.22.1",
|
|
237
|
+
"type-coverage": "^2.29.7",
|
|
238
|
+
"typescript": "^5.9.3",
|
|
239
|
+
"typescript-eslint": "^8.52.0",
|
|
240
|
+
"vitest": "^4.1.6",
|
|
241
|
+
"zod": "^3.23.0",
|
|
242
|
+
"@konker.dev/neverthrow-r-schema": "0.0.1"
|
|
243
|
+
},
|
|
244
|
+
"scripts": {
|
|
245
|
+
"test": "vitest run --coverage",
|
|
246
|
+
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
|
|
247
|
+
"typecheck": "tsc --noEmit",
|
|
248
|
+
"build": "pnpm run clean && tsc",
|
|
249
|
+
"type-coverage-check": "type-coverage --detail --at-least 97",
|
|
250
|
+
"circular-check": "madge --extensions ts --circular --no-color --no-spinner --warning src",
|
|
251
|
+
"eslint-check": "eslint --max-warnings=0 '**/*.{ts,js,json}'",
|
|
252
|
+
"eslint-fix": "npx eslint --fix||true",
|
|
253
|
+
"generated-exports-check": "npx --package=@konker.dev/common-config generate-exports-verify `pwd`",
|
|
254
|
+
"exports-check": "NPM_CONFIG_CACHE=.npm-cache attw --pack . --ignore-rules=cjs-resolves-to-esm --profile=esm-only",
|
|
255
|
+
"fixme-check": "leasot --exit-nicely --skip-unsupported src",
|
|
256
|
+
"prettier-check": "npx prettier --check --ignore-path .gitignore --ignore-path .prettierignore '**/*.{css,html,js,ts,json,md,yaml,yml}'",
|
|
257
|
+
"prettier-fix": "pnpm run prettier-check --write",
|
|
258
|
+
"lint-check": "pnpm run eslint-check && pnpm run prettier-check && pnpm run circular-check && pnpm run fixme-check",
|
|
259
|
+
"lint-fix": "pnpm run eslint-fix && pnpm run prettier-fix",
|
|
260
|
+
"pre-push": "pnpm run lint-check && pnpm run typecheck",
|
|
261
|
+
"codecov": "npx --package=@konker.dev/common-config codecov-upload `pwd` '@konker.dev/neverthrow-r-middleware'",
|
|
262
|
+
"ci": "pnpm run lint-check && pnpm run typecheck && pnpm run type-coverage-check && pnpm run test && pnpm run build && pnpm run generated-exports-check && pnpm run exports-check && pnpm run fixme-check",
|
|
263
|
+
"cd": "pnpm run build && npx --package=@konker.dev/common-config npm-publish-if-version-not-exists `pwd`"
|
|
264
|
+
}
|
|
265
|
+
}
|