@h4ad/serverless-adapter 2.10.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/lib/@types/binary-settings.d.ts +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +0 -1
- package/lib/@types/digital-ocean/index.d.ts +0 -1
- package/lib/@types/headers.d.ts +0 -1
- package/lib/@types/helpers.d.ts +0 -1
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts +0 -1
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts +0 -1
- package/lib/@types/huawei/huawei-context.d.ts +0 -1
- package/lib/@types/huawei/index.d.ts +0 -1
- package/lib/@types/index.d.ts +0 -1
- package/lib/adapters/aws/alb.adapter.d.ts +0 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +0 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +0 -1
- package/lib/adapters/aws/dynamodb.adapter.d.ts +0 -1
- package/lib/adapters/aws/event-bridge.adapter.d.ts +0 -1
- package/lib/adapters/aws/index.d.ts +0 -1
- package/lib/adapters/aws/lambda-edge.adapter.d.ts +0 -1
- package/lib/adapters/aws/s3.adapter.d.ts +0 -1
- package/lib/adapters/aws/sns.adapter.d.ts +0 -1
- package/lib/adapters/aws/sqs.adapter.d.ts +0 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +0 -1
- package/lib/adapters/azure/index.d.ts +0 -1
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts +0 -1
- package/lib/adapters/digital-ocean/index.d.ts +0 -1
- package/lib/adapters/dummy/dummy.adapter.d.ts +0 -1
- package/lib/adapters/dummy/index.d.ts +0 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +0 -1
- package/lib/adapters/huawei/index.d.ts +0 -1
- package/lib/contracts/adapter.contract.d.ts +0 -1
- package/lib/contracts/framework.contract.d.ts +0 -1
- package/lib/contracts/handler.contract.d.ts +0 -1
- package/lib/contracts/index.d.ts +0 -1
- package/lib/contracts/resolver.contract.d.ts +0 -1
- package/lib/core/base-handler.d.ts +0 -1
- package/lib/core/constants.d.ts +0 -1
- package/lib/core/current-invoke.d.ts +0 -1
- package/lib/core/event-body.d.ts +0 -1
- package/lib/core/headers.d.ts +0 -1
- package/lib/core/index.d.ts +0 -1
- package/lib/core/is-binary.d.ts +0 -1
- package/lib/core/logger.d.ts +0 -1
- package/lib/core/no-op.d.ts +0 -1
- package/lib/core/optional.d.ts +0 -1
- package/lib/core/path.d.ts +0 -1
- package/lib/core/stream.d.ts +9 -1
- package/lib/core/stream.js +19 -4
- package/lib/core/stream.js.map +1 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +66 -0
- package/lib/frameworks/body-parser/base-body-parser.framework.js +66 -0
- package/lib/frameworks/body-parser/base-body-parser.framework.js.map +1 -0
- package/lib/frameworks/body-parser/index.d.ts +5 -0
- package/lib/frameworks/body-parser/index.js +22 -0
- package/lib/frameworks/body-parser/index.js.map +1 -0
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/json-body-parser.framework.js +29 -0
- package/lib/frameworks/body-parser/json-body-parser.framework.js.map +1 -0
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/raw-body-parser.framework.js +29 -0
- package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +1 -0
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/text-body-parser.framework.js +29 -0
- package/lib/frameworks/body-parser/text-body-parser.framework.js.map +1 -0
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +29 -0
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +1 -0
- package/lib/frameworks/cors/cors.framework.d.ts +78 -0
- package/lib/frameworks/cors/cors.framework.js +145 -0
- package/lib/frameworks/cors/cors.framework.js.map +1 -0
- package/lib/frameworks/cors/index.d.ts +1 -0
- package/lib/frameworks/cors/index.js +18 -0
- package/lib/frameworks/cors/index.js.map +1 -0
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +0 -1
- package/lib/frameworks/deepkit/index.d.ts +0 -1
- package/lib/frameworks/express/express.framework.d.ts +0 -1
- package/lib/frameworks/express/index.d.ts +0 -1
- package/lib/frameworks/fastify/fastify.framework.d.ts +0 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +13 -0
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js +27 -0
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +1 -0
- package/lib/frameworks/fastify/index.d.ts +0 -1
- package/lib/frameworks/hapi/hapi.framework.d.ts +0 -1
- package/lib/frameworks/hapi/index.d.ts +0 -1
- package/lib/frameworks/koa/index.d.ts +0 -1
- package/lib/frameworks/koa/koa.framework.d.ts +0 -1
- package/lib/frameworks/lazy/index.d.ts +0 -1
- package/lib/frameworks/lazy/lazy.framework.d.ts +0 -1
- package/lib/frameworks/trpc/index.d.ts +0 -1
- package/lib/frameworks/trpc/trpc.framework.d.ts +0 -1
- package/lib/handlers/azure/azure.handler.d.ts +0 -1
- package/lib/handlers/azure/index.d.ts +0 -1
- package/lib/handlers/default/default.handler.d.ts +0 -1
- package/lib/handlers/default/index.d.ts +0 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +0 -1
- package/lib/handlers/digital-ocean/index.d.ts +0 -1
- package/lib/handlers/firebase/http-firebase.handler.d.ts +0 -1
- package/lib/handlers/firebase/index.d.ts +0 -1
- package/lib/handlers/huawei/http-huawei.handler.d.ts +0 -1
- package/lib/handlers/huawei/index.d.ts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/network/index.d.ts +0 -1
- package/lib/network/request.d.ts +0 -1
- package/lib/network/response.d.ts +0 -1
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts +0 -1
- package/lib/resolvers/aws-context/index.d.ts +0 -1
- package/lib/resolvers/callback/callback.resolver.d.ts +0 -1
- package/lib/resolvers/callback/index.d.ts +0 -1
- package/lib/resolvers/dummy/dummy.resolver.d.ts +0 -1
- package/lib/resolvers/dummy/index.d.ts +0 -1
- package/lib/resolvers/promise/index.d.ts +0 -1
- package/lib/resolvers/promise/promise.resolver.d.ts +0 -1
- package/lib/serverless-adapter.d.ts +0 -1
- package/package.json +23 -4
- package/lib/@types/binary-settings.d.ts.map +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts.map +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts.map +0 -1
- package/lib/@types/digital-ocean/index.d.ts.map +0 -1
- package/lib/@types/headers.d.ts.map +0 -1
- package/lib/@types/helpers.d.ts.map +0 -1
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +0 -1
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +0 -1
- package/lib/@types/huawei/huawei-context.d.ts.map +0 -1
- package/lib/@types/huawei/index.d.ts.map +0 -1
- package/lib/@types/index.d.ts.map +0 -1
- package/lib/adapters/aws/alb.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/dynamodb.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/event-bridge.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/index.d.ts.map +0 -1
- package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/s3.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/sns.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/sqs.adapter.d.ts.map +0 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts.map +0 -1
- package/lib/adapters/azure/index.d.ts.map +0 -1
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts.map +0 -1
- package/lib/adapters/digital-ocean/index.d.ts.map +0 -1
- package/lib/adapters/dummy/dummy.adapter.d.ts.map +0 -1
- package/lib/adapters/dummy/index.d.ts.map +0 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +0 -1
- package/lib/adapters/huawei/index.d.ts.map +0 -1
- package/lib/contracts/adapter.contract.d.ts.map +0 -1
- package/lib/contracts/framework.contract.d.ts.map +0 -1
- package/lib/contracts/handler.contract.d.ts.map +0 -1
- package/lib/contracts/index.d.ts.map +0 -1
- package/lib/contracts/resolver.contract.d.ts.map +0 -1
- package/lib/core/base-handler.d.ts.map +0 -1
- package/lib/core/constants.d.ts.map +0 -1
- package/lib/core/current-invoke.d.ts.map +0 -1
- package/lib/core/event-body.d.ts.map +0 -1
- package/lib/core/headers.d.ts.map +0 -1
- package/lib/core/index.d.ts.map +0 -1
- package/lib/core/is-binary.d.ts.map +0 -1
- package/lib/core/logger.d.ts.map +0 -1
- package/lib/core/no-op.d.ts.map +0 -1
- package/lib/core/optional.d.ts.map +0 -1
- package/lib/core/path.d.ts.map +0 -1
- package/lib/core/stream.d.ts.map +0 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts.map +0 -1
- package/lib/frameworks/deepkit/index.d.ts.map +0 -1
- package/lib/frameworks/express/express.framework.d.ts.map +0 -1
- package/lib/frameworks/express/index.d.ts.map +0 -1
- package/lib/frameworks/fastify/fastify.framework.d.ts.map +0 -1
- package/lib/frameworks/fastify/index.d.ts.map +0 -1
- package/lib/frameworks/hapi/hapi.framework.d.ts.map +0 -1
- package/lib/frameworks/hapi/index.d.ts.map +0 -1
- package/lib/frameworks/koa/index.d.ts.map +0 -1
- package/lib/frameworks/koa/koa.framework.d.ts.map +0 -1
- package/lib/frameworks/lazy/index.d.ts.map +0 -1
- package/lib/frameworks/lazy/lazy.framework.d.ts.map +0 -1
- package/lib/frameworks/trpc/index.d.ts.map +0 -1
- package/lib/frameworks/trpc/trpc.framework.d.ts.map +0 -1
- package/lib/handlers/azure/azure.handler.d.ts.map +0 -1
- package/lib/handlers/azure/index.d.ts.map +0 -1
- package/lib/handlers/default/default.handler.d.ts.map +0 -1
- package/lib/handlers/default/index.d.ts.map +0 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts.map +0 -1
- package/lib/handlers/digital-ocean/index.d.ts.map +0 -1
- package/lib/handlers/firebase/http-firebase.handler.d.ts.map +0 -1
- package/lib/handlers/firebase/index.d.ts.map +0 -1
- package/lib/handlers/huawei/http-huawei.handler.d.ts.map +0 -1
- package/lib/handlers/huawei/index.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/network/index.d.ts.map +0 -1
- package/lib/network/request.d.ts.map +0 -1
- package/lib/network/response.d.ts.map +0 -1
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +0 -1
- package/lib/resolvers/aws-context/index.d.ts.map +0 -1
- package/lib/resolvers/callback/callback.resolver.d.ts.map +0 -1
- package/lib/resolvers/callback/index.d.ts.map +0 -1
- package/lib/resolvers/dummy/dummy.resolver.d.ts.map +0 -1
- package/lib/resolvers/dummy/index.d.ts.map +0 -1
- package/lib/resolvers/promise/index.d.ts.map +0 -1
- package/lib/resolvers/promise/promise.resolver.d.ts.map +0 -1
- package/lib/serverless-adapter.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
[![Commitizen Friendly][commitizen-img]][commitizen-url]
|
|
20
20
|
[![Semantic Release][semantic-release-img]][semantic-release-url]
|
|
21
21
|
|
|
22
|
-
Run REST APIs and other web applications using your existing Node.js application framework (Deepkit, Express, Koa, Hapi,
|
|
23
|
-
Fastify and tRPC), on top of AWS Lambda, Azure,
|
|
22
|
+
Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Deepkit, Express, Koa, Hapi,
|
|
23
|
+
Fastify and tRPC), on top of AWS Lambda, Azure, Digital Ocean and many other clouds.
|
|
24
24
|
|
|
25
25
|
This library was a refactored version of [@vendia/serverless-express](https://github.com/vendia/serverless-express), I
|
|
26
26
|
create a new way to interact and extend event sources by creating contracts to abstract the integrations between each
|
|
@@ -38,6 +38,14 @@ Why you would use this libray instead of [@vendia/serverless-express](https://gi
|
|
|
38
38
|
- Well documented, any method, class, or interface has comments to explain the behavior.
|
|
39
39
|
- We have >99% coverage.
|
|
40
40
|
|
|
41
|
+
# Installing
|
|
42
|
+
|
|
43
|
+
To be able to use, first install the library:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm i --save @h4ad/serverless-adapter
|
|
47
|
+
```
|
|
48
|
+
|
|
41
49
|
# Usage
|
|
42
50
|
|
|
43
51
|
To start to use, first you need to know what you need to import, let's start showing the [ServerlessAdapter](/docs/api/ServerlessAdapter).
|
|
@@ -91,7 +99,6 @@ for existing and giving us a brilliant library that is the core of my current co
|
|
|
91
99
|
| <a href="https://liga.facens.br/"><img height="50" src="https://mlogu6g7z5ex.i.optimole.com/yEwfkqo-4R0ttNtd/w:auto/h:auto/q:mauto/f:avif/http://liga.facens.br/wp-content/uploads/2020/03/logo-1.png" title="The LIGA logo" width="100"/></a> |
|
|
92
100
|
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
93
101
|
|
|
94
|
-
|
|
95
102
|
[build-img]:https://github.com/H4ad/serverless-adapter/actions/workflows/release.yml/badge.svg
|
|
96
103
|
|
|
97
104
|
[build-url]:https://github.com/H4ad/serverless-adapter/actions/workflows/release.yml
|
|
@@ -41,4 +41,3 @@ export declare type BinarySettings = BinarySettingsFunction | BinarySettingsCont
|
|
|
41
41
|
export declare type __ΩBinarySettingsFunction = any[];
|
|
42
42
|
export declare type __ΩBinarySettingsContentHeaders = any[];
|
|
43
43
|
export declare type __ΩBinarySettings = any[];
|
|
44
|
-
//# sourceMappingURL=binary-settings.d.ts.map
|
package/lib/@types/headers.d.ts
CHANGED
|
@@ -37,4 +37,3 @@ export declare type BothValueHeaders = Record<string, string | string[] | undefi
|
|
|
37
37
|
export declare type __ΩSingleValueHeaders = any[];
|
|
38
38
|
export declare type __ΩMultiValueHeaders = any[];
|
|
39
39
|
export declare type __ΩBothValueHeaders = any[];
|
|
40
|
-
//# sourceMappingURL=headers.d.ts.map
|
package/lib/@types/helpers.d.ts
CHANGED
|
@@ -82,4 +82,3 @@ export declare type __ΩHuaweiApiGatewayEvent = any[];
|
|
|
82
82
|
export declare type __ΩHuaweiRequestPathParameters = any[];
|
|
83
83
|
export declare type __ΩHuaweiRequestQueryStringParameters = any[];
|
|
84
84
|
export declare type __ΩHuaweiRequestContext = any[];
|
|
85
|
-
//# sourceMappingURL=huawei-api-gateway-event.d.ts.map
|
package/lib/@types/index.d.ts
CHANGED
|
@@ -68,4 +68,3 @@ export declare class DynamoDBAdapter implements AdapterContract<DynamoDBStreamEv
|
|
|
68
68
|
onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<DynamoDBStreamEvent, IEmptyResponse>): void;
|
|
69
69
|
}
|
|
70
70
|
export declare type __ΩDynamoDBAdapterOptions = any[];
|
|
71
|
-
//# sourceMappingURL=dynamodb.adapter.d.ts.map
|
|
@@ -211,4 +211,3 @@ export declare type __ΩDefaultForwardPath = any[];
|
|
|
211
211
|
export declare type __ΩNewLambdaEdgeBody = any[];
|
|
212
212
|
export declare type __ΩOldLambdaEdgeBody = any[];
|
|
213
213
|
export declare type __ΩLambdaEdgeAdapterOptions = any[];
|
|
214
|
-
//# sourceMappingURL=lambda-edge.adapter.d.ts.map
|
|
@@ -68,4 +68,3 @@ export declare class S3Adapter implements AdapterContract<S3Event, Context, IEmp
|
|
|
68
68
|
onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<S3Event, IEmptyResponse>): void;
|
|
69
69
|
}
|
|
70
70
|
export declare type __ΩS3AdapterOptions = any[];
|
|
71
|
-
//# sourceMappingURL=s3.adapter.d.ts.map
|
|
@@ -68,4 +68,3 @@ export declare class SNSAdapter implements AdapterContract<SNSEvent, Context, IE
|
|
|
68
68
|
onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<SNSEvent, IEmptyResponse>): void;
|
|
69
69
|
}
|
|
70
70
|
export declare type __ΩSNSAdapterOptions = any[];
|
|
71
|
-
//# sourceMappingURL=sns.adapter.d.ts.map
|
|
@@ -68,4 +68,3 @@ export declare class SQSAdapter implements AdapterContract<SQSEvent, Context, IE
|
|
|
68
68
|
onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<SQSEvent, IEmptyResponse>): void;
|
|
69
69
|
}
|
|
70
70
|
export declare type __ΩSQSAdapterOptions = any[];
|
|
71
|
-
//# sourceMappingURL=sqs.adapter.d.ts.map
|
|
@@ -63,4 +63,3 @@ export declare class HttpFunctionAdapter implements AdapterContract<DigitalOcean
|
|
|
63
63
|
protected getPathFromEvent(event: DigitalOceanHttpEvent): string;
|
|
64
64
|
}
|
|
65
65
|
export declare type __ΩHttpFunctionAdapterOptions = any[];
|
|
66
|
-
//# sourceMappingURL=http-function.adapter.d.ts.map
|
|
@@ -64,4 +64,3 @@ export declare class HuaweiApiGatewayAdapter implements AdapterContract<HuaweiAp
|
|
|
64
64
|
protected getPathFromEvent(event: HuaweiApiGatewayEvent): string;
|
|
65
65
|
}
|
|
66
66
|
export declare type __ΩHuaweiApiGatewayOptions = any[];
|
|
67
|
-
//# sourceMappingURL=huawei-api-gateway.adapter.d.ts.map
|
package/lib/contracts/index.d.ts
CHANGED
|
@@ -29,4 +29,3 @@ export declare abstract class BaseHandler<TApp, TEvent, TContext, TCallback, TRe
|
|
|
29
29
|
*/
|
|
30
30
|
protected getServerlessRequestResponseFromAdapterRequest(requestValues: AdapterRequest): [request: ServerlessRequest, response: ServerlessResponse];
|
|
31
31
|
}
|
|
32
|
-
//# sourceMappingURL=base-handler.d.ts.map
|
package/lib/core/constants.d.ts
CHANGED
|
@@ -46,4 +46,3 @@ export declare function getCurrentInvoke<TEvent = any, TContext = any>(): Curren
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function setCurrentInvoke<TEvent = any, TContext = any>({ event, context, }: CurrentInvoke<TEvent, TContext>): void;
|
|
48
48
|
export declare type __ΩCurrentInvoke = any[];
|
|
49
|
-
//# sourceMappingURL=current-invoke.d.ts.map
|
package/lib/core/event-body.d.ts
CHANGED
package/lib/core/headers.d.ts
CHANGED
package/lib/core/index.d.ts
CHANGED
package/lib/core/is-binary.d.ts
CHANGED
package/lib/core/logger.d.ts
CHANGED
package/lib/core/no-op.d.ts
CHANGED
package/lib/core/optional.d.ts
CHANGED
package/lib/core/path.d.ts
CHANGED
|
@@ -34,4 +34,3 @@ export declare function getPathWithQueryStringParams(path: string, queryParams:
|
|
|
34
34
|
* @public
|
|
35
35
|
*/
|
|
36
36
|
export declare function getQueryParamsStringFromRecord(queryParamsRecord: Record<string, string | string[] | undefined> | undefined | null): string;
|
|
37
|
-
//# sourceMappingURL=path.d.ts.map
|
package/lib/core/stream.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Readable, Writable } from 'stream';
|
|
3
|
+
/**
|
|
4
|
+
* Check if stream already ended
|
|
5
|
+
*
|
|
6
|
+
* @param stream - The stream
|
|
7
|
+
*
|
|
8
|
+
* @breadcrumb Core / Stream
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function isStreamEnded(stream: Readable | Writable): boolean;
|
|
3
12
|
/**
|
|
4
13
|
* Wait asynchronous the stream to complete
|
|
5
14
|
*
|
|
@@ -9,4 +18,3 @@ import { Readable, Writable } from 'stream';
|
|
|
9
18
|
* @public
|
|
10
19
|
*/
|
|
11
20
|
export declare function waitForStreamComplete<TStream extends Readable | Writable>(stream: TStream): Promise<TStream>;
|
|
12
|
-
//# sourceMappingURL=stream.d.ts.map
|
package/lib/core/stream.js
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.waitForStreamComplete = void 0;
|
|
3
|
+
exports.waitForStreamComplete = exports.isStreamEnded = void 0;
|
|
4
4
|
function __assignType(fn, args) {
|
|
5
5
|
fn.__type = args;
|
|
6
6
|
return fn;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Check if stream already ended
|
|
11
11
|
*
|
|
12
12
|
* @param stream - The stream
|
|
13
13
|
*
|
|
14
14
|
* @breadcrumb Core / Stream
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
function
|
|
17
|
+
function isStreamEnded(stream) {
|
|
18
18
|
if ('readableEnded' in stream && stream.readableEnded)
|
|
19
|
-
return
|
|
19
|
+
return true;
|
|
20
20
|
if ('writableEnded' in stream && stream.writableEnded)
|
|
21
|
+
return true;
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
exports.isStreamEnded = isStreamEnded;
|
|
25
|
+
isStreamEnded.__type = ['stream', 'isStreamEnded', 'PP!!J2!)/"'];
|
|
26
|
+
/**
|
|
27
|
+
* Wait asynchronous the stream to complete
|
|
28
|
+
*
|
|
29
|
+
* @param stream - The stream
|
|
30
|
+
*
|
|
31
|
+
* @breadcrumb Core / Stream
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
function waitForStreamComplete(stream) {
|
|
35
|
+
if (isStreamEnded(stream))
|
|
21
36
|
return Promise.resolve(stream);
|
|
22
37
|
return new Promise(__assignType((resolve, reject) => {
|
|
23
38
|
// Reading the {@link https://github.com/nodejs/node/blob/v12.22.9/lib/events.js#L262 | emit source code},
|
package/lib/core/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/core/stream.ts"],"names":[],"mappings":";;;;;;;AAIA,YAAY;AAEZ;;;;;;;GAOG;AACH,SAAgB,
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/core/stream.ts"],"names":[],"mappings":";;;;;;;AAIA,YAAY;AAEZ;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,MAA2B;IACvD,IAAI,eAAe,IAAI,MAAM,IAAI,MAAM,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAEnE,IAAI,eAAe,IAAI,MAAM,IAAI,MAAM,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAEnE,OAAO,KAAK,CAAC;AACf,CAAC;AAND,sCAMC;;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,MAAe;IAEf,IAAI,aAAa,CAAC,MAAM,CAAC;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO,IAAI,OAAO,cAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,0GAA0G;QAC1G,sIAAsI;QACtI,mIAAmI;QACnI,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,SAAS,QAAQ,CAAC,GAAG;YACnB,0BAA0B;YAC1B,IAAI,UAAU;gBAAE,OAAO;YAEvB,UAAU,GAAG,IAAI,CAAC;YAElB,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACzC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACvC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAE1C,IAAI,GAAG;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;;gBAChB,OAAO,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;;QAED,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC,2CAAC,CAAC;AACL,CAAC;AA7BD,sDA6BC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import type { NextHandleFunction } from 'connect';
|
|
4
|
+
import type { HttpError } from 'http-errors';
|
|
5
|
+
import { FrameworkContract } from '../../contracts';
|
|
6
|
+
/**
|
|
7
|
+
* The options for {@link BaseBodyParserFramework}
|
|
8
|
+
*/
|
|
9
|
+
export declare type BodyParserOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Implements a custom way of handling error.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue {@link BaseBodyParserFramework.defaultHandleOnError}
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* customErrorHandler: (req: IncomingMessage, response: ServerResponse, error: HttpError<any>) => {
|
|
18
|
+
* response.setHeader('content-type', 'text/plain');
|
|
19
|
+
* response.statusCode = error.statusCode;
|
|
20
|
+
* // always call end to return the error
|
|
21
|
+
* response.end(error.message);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param request - The referecene for request
|
|
26
|
+
* @param response - The reference for response
|
|
27
|
+
* @param error - The error throwed by body-parser
|
|
28
|
+
*/
|
|
29
|
+
customErrorHandler?: (request: IncomingMessage, response: ServerResponse, error: HttpError<any>) => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The base class used by other body-parser functions to parse a specific content-type
|
|
33
|
+
*
|
|
34
|
+
* @breadcrumb Frameworks / BodyParserFramework
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare class BaseBodyParserFramework<TApp> implements FrameworkContract<TApp> {
|
|
38
|
+
protected readonly framework: FrameworkContract<TApp>;
|
|
39
|
+
protected readonly middleware: NextHandleFunction;
|
|
40
|
+
protected readonly options?: BodyParserOptions | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Default Constructor
|
|
43
|
+
*/
|
|
44
|
+
protected constructor(framework: FrameworkContract<TApp>, middleware: NextHandleFunction, options?: BodyParserOptions | undefined);
|
|
45
|
+
/**
|
|
46
|
+
* The selected error handler
|
|
47
|
+
*/
|
|
48
|
+
protected readonly errorHandler: NonNullable<BodyParserOptions['customErrorHandler']>;
|
|
49
|
+
/**
|
|
50
|
+
* {@inheritDoc}
|
|
51
|
+
*/
|
|
52
|
+
sendRequest(app: TApp, request: IncomingMessage, response: ServerResponse): void;
|
|
53
|
+
/**
|
|
54
|
+
* Handle next execution called by the cors package
|
|
55
|
+
*/
|
|
56
|
+
protected onBodyParserFinished(app: TApp, request: IncomingMessage, response: ServerResponse): () => void;
|
|
57
|
+
/**
|
|
58
|
+
* The default function to handle errors
|
|
59
|
+
*
|
|
60
|
+
* @param request - The referecene for request
|
|
61
|
+
* @param response - The reference for response
|
|
62
|
+
* @param error - The error throwed by body-parser
|
|
63
|
+
*/
|
|
64
|
+
protected defaultHandleOnError(request: IncomingMessage, response: ServerResponse, error: HttpError<any>): void;
|
|
65
|
+
}
|
|
66
|
+
export declare type __ΩBodyParserOptions = any[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseBodyParserFramework = exports.__ΩBodyParserOptions = void 0;
|
|
4
|
+
const { __ΩFrameworkContract } = require('../../contracts');
|
|
5
|
+
function __assignType(fn, args) {
|
|
6
|
+
fn.__type = args;
|
|
7
|
+
return fn;
|
|
8
|
+
}
|
|
9
|
+
const __ΩNonNullable = ['T', 'l7!Re$!RPe#!P,-Jqk#%QRb!Pde"!p)'];
|
|
10
|
+
const core_1 = require("../../core");
|
|
11
|
+
const __ΩBodyParserOptions = ['request', 'response', 'error', '', 'customErrorHandler', 'PP!2!!2"!2#$/$4%8M'];
|
|
12
|
+
exports.__ΩBodyParserOptions = __ΩBodyParserOptions;
|
|
13
|
+
/**
|
|
14
|
+
* The base class used by other body-parser functions to parse a specific content-type
|
|
15
|
+
*
|
|
16
|
+
* @breadcrumb Frameworks / BodyParserFramework
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
class BaseBodyParserFramework {
|
|
20
|
+
//#region Constructor
|
|
21
|
+
/**
|
|
22
|
+
* Default Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(framework, middleware, options) {
|
|
25
|
+
var _a;
|
|
26
|
+
this.framework = framework;
|
|
27
|
+
this.middleware = middleware;
|
|
28
|
+
this.options = options;
|
|
29
|
+
this.errorHandler = (0, core_1.getDefaultIfUndefined)((_a = this.options) === null || _a === void 0 ? void 0 : _a.customErrorHandler, this.defaultHandleOnError.bind(this));
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region Public Methods
|
|
33
|
+
/**
|
|
34
|
+
* {@inheritDoc}
|
|
35
|
+
*/
|
|
36
|
+
sendRequest(app, request, response) {
|
|
37
|
+
this.middleware(request, response, this.onBodyParserFinished(app, request, response));
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region Protected Methods
|
|
41
|
+
/**
|
|
42
|
+
* Handle next execution called by the cors package
|
|
43
|
+
*/
|
|
44
|
+
onBodyParserFinished(app, request, response) {
|
|
45
|
+
return __assignType((err) => {
|
|
46
|
+
if (err)
|
|
47
|
+
return this.errorHandler(request, response, err);
|
|
48
|
+
this.framework.sendRequest(app, request, response);
|
|
49
|
+
}, ['err', '', 'P"2!8"/"']);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The default function to handle errors
|
|
53
|
+
*
|
|
54
|
+
* @param request - The referecene for request
|
|
55
|
+
* @param response - The reference for response
|
|
56
|
+
* @param error - The error throwed by body-parser
|
|
57
|
+
*/
|
|
58
|
+
defaultHandleOnError(request, response, error) {
|
|
59
|
+
response.setHeader('content-type', 'text/plain');
|
|
60
|
+
response.statusCode = error.statusCode;
|
|
61
|
+
response.end(error.message);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.BaseBodyParserFramework = BaseBodyParserFramework;
|
|
65
|
+
BaseBodyParserFramework.__type = ['TApp', () => __ΩFrameworkContract, 'framework', 'middleware', () => __ΩBodyParserOptions, 'options', 'constructor', () => __ΩNonNullable, () => __ΩBodyParserOptions, "customErrorHandler", 'errorHandler', 'app', 'request', 'response', 'sendRequest', '', 'onBodyParserFinished', 'error', 'defaultHandleOnError', 'b!Pe"!o""2#<9!2$<9n%2&8<9"0\'n).*fo("3+9<Pe"!2,!2-!2.$0/Pe"!2,!2-!2.P$/001<P!2-!2.!22$03<5e!!6"'];
|
|
66
|
+
//# sourceMappingURL=base-body-parser.framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-body-parser.framework.js","sourceRoot":"","sources":["../../../src/frameworks/body-parser/base-body-parser.framework.ts"],"names":[],"mappings":";;;yCAKkC,iBAAiB;;;;;;AACnD,qCAAmD;;;AAkCnD;;;;;GAKG;AACH,MAAa,uBAAuB;IAClC,qBAAqB;IAErB;;OAEG;IACH,YACqB,SAAkC,EAClC,UAA8B,EAC9B,OAA2B;;QAF3B,cAAS,GAAT,SAAS,CAAyB;QAClC,eAAU,GAAV,UAAU,CAAoB;QAC9B,YAAO,GAAP,OAAO,CAAoB;QAE9C,IAAI,CAAC,YAAY,GAAG,IAAA,4BAAqB,EACvC,MAAA,IAAI,CAAC,OAAO,0CAAE,kBAAkB,EAChC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CACrC,CAAC;IACJ,CAAC;IAaD,YAAY;IAEZ,wBAAwB;IAExB;;OAEG;IACI,WAAW,CAChB,GAAS,EACT,OAAwB,EACxB,QAAwB;QAExB,IAAI,CAAC,UAAU,CACb,OAAO,EACP,QAAQ,EACR,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAClD,CAAC;IACJ,CAAC;IAED,YAAY;IAEZ,2BAA2B;IAE3B;;OAEG;IACO,oBAAoB,CAC5B,GAAS,EACT,OAAwB,EACxB,QAAwB;QAExB,oBAAO,CAAC,GAAS,EAAE,EAAE;YACnB,IAAI,GAAG;gBAAE,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;YAE1D,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACrD,CAAC,2BAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACO,oBAAoB,CAC5B,OAAwB,EACxB,QAAwB,EACxB,KAAqB;QAErB,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QACjD,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACvC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;;AAjFH,0DAoFC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base-body-parser.framework"), exports);
|
|
18
|
+
__exportStar(require("./json-body-parser.framework"), exports);
|
|
19
|
+
__exportStar(require("./raw-body-parser.framework"), exports);
|
|
20
|
+
__exportStar(require("./text-body-parser.framework"), exports);
|
|
21
|
+
__exportStar(require("./urlencoded-body-parser.framework"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/body-parser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,+DAA6C;AAC7C,8DAA4C;AAC5C,+DAA6C;AAC7C,qEAAmD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OptionsJson } from 'body-parser';
|
|
2
|
+
import { FrameworkContract } from '../../contracts';
|
|
3
|
+
import { BaseBodyParserFramework, BodyParserOptions } from './base-body-parser.framework';
|
|
4
|
+
/**
|
|
5
|
+
* The body-parser options for application/json
|
|
6
|
+
*
|
|
7
|
+
* @remarks {@link https://github.com/expressjs/body-parser#bodyparserjsonoptions}
|
|
8
|
+
*
|
|
9
|
+
* @breadcrumb Frameworks / BodyParserFramework / JsonBodyParserFramework
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare type JsonBodyParserFrameworkOptions = OptionsJson & BodyParserOptions;
|
|
13
|
+
/**
|
|
14
|
+
* The body-parser class used to parse application/json.
|
|
15
|
+
*
|
|
16
|
+
* @breadcrumb Frameworks / BodyParserFramework / JsonBodyParserFramework
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class JsonBodyParserFramework<TApp> extends BaseBodyParserFramework<TApp> implements FrameworkContract<TApp> {
|
|
20
|
+
protected readonly framework: FrameworkContract<TApp>;
|
|
21
|
+
/**
|
|
22
|
+
* Default Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(framework: FrameworkContract<TApp>, options?: JsonBodyParserFrameworkOptions);
|
|
25
|
+
}
|
|
26
|
+
export declare type __ΩJsonBodyParserFrameworkOptions = any[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonBodyParserFramework = exports.__ΩJsonBodyParserFrameworkOptions = void 0;
|
|
4
|
+
const { __ΩFrameworkContract } = require('../../contracts');
|
|
5
|
+
const { __ΩBodyParserOptions } = require('./base-body-parser.framework');
|
|
6
|
+
//#region Imports
|
|
7
|
+
const body_parser_1 = require("body-parser");
|
|
8
|
+
const base_body_parser_framework_1 = require("./base-body-parser.framework");
|
|
9
|
+
const __ΩJsonBodyParserFrameworkOptions = [() => __ΩBodyParserOptions, 'P!n!K'];
|
|
10
|
+
exports.__ΩJsonBodyParserFrameworkOptions = __ΩJsonBodyParserFrameworkOptions;
|
|
11
|
+
/**
|
|
12
|
+
* The body-parser class used to parse application/json.
|
|
13
|
+
*
|
|
14
|
+
* @breadcrumb Frameworks / BodyParserFramework / JsonBodyParserFramework
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class JsonBodyParserFramework extends base_body_parser_framework_1.BaseBodyParserFramework {
|
|
18
|
+
//#region Constructor
|
|
19
|
+
/**
|
|
20
|
+
* Default Constructor
|
|
21
|
+
*/
|
|
22
|
+
constructor(framework, options) {
|
|
23
|
+
super(framework, (0, body_parser_1.json)(options), options);
|
|
24
|
+
this.framework = framework;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.JsonBodyParserFramework = JsonBodyParserFramework;
|
|
28
|
+
JsonBodyParserFramework.__type = ['TApp', () => base_body_parser_framework_1.BaseBodyParserFramework, () => __ΩFrameworkContract, 'framework', () => __ΩJsonBodyParserFrameworkOptions, 'options', 'constructor', 'b!Pe"!7"Pe"!o#"2$<9n%2&8"0\'5e!!6"'];
|
|
29
|
+
//# sourceMappingURL=json-body-parser.framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-body-parser.framework.js","sourceRoot":"","sources":["../../../src/frameworks/body-parser/json-body-parser.framework.ts"],"names":[],"mappings":";;;yCAGkC,iBAAiB;yCAI5C,8BAA8B;AAPrC,iBAAiB;AAEjB,6CAAgD;AAEhD,6EAGsC;;;AActC;;;;;GAKG;AACH,MAAa,uBACX,SAAQ,oDAA6B;IAGrC,qBAAqB;IAErB;;OAEG;IACH,YACqB,SAAkC,EACrD,OAAwC;QAExC,KAAK,CAAC,SAAS,EAAE,IAAA,kBAAI,EAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QAHtB,cAAS,GAAT,SAAS,CAAyB;IAIvD,CAAC;;AAdH,0DAiBC"}
|