@h4ad/serverless-adapter 2.17.0 → 3.0.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 +7 -0
- package/lib/@types/binary-settings.js +2 -11
- package/lib/@types/binary-settings.js.map +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.js +2 -7
- package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.js +2 -7
- package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +1 -1
- package/lib/@types/digital-ocean/index.js +2 -18
- package/lib/@types/digital-ocean/index.js.map +1 -1
- package/lib/@types/headers.js +2 -11
- package/lib/@types/headers.js.map +1 -1
- package/lib/@types/helpers.js +2 -6
- package/lib/@types/helpers.js.map +1 -1
- package/lib/@types/huawei/huawei-api-gateway-event.js +2 -14
- package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -1
- package/lib/@types/huawei/huawei-api-gateway-response.js +2 -7
- package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -1
- package/lib/@types/huawei/huawei-context.js +2 -36
- package/lib/@types/huawei/huawei-context.js.map +1 -1
- package/lib/@types/huawei/index.js +2 -20
- package/lib/@types/huawei/index.js.map +1 -1
- package/lib/@types/index.js +2 -20
- package/lib/@types/index.js.map +1 -1
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +2 -86
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +1 -1
- package/lib/adapters/apollo-server/index.js +2 -18
- package/lib/adapters/apollo-server/index.js.map +1 -1
- package/lib/adapters/aws/alb.adapter.js +2 -129
- package/lib/adapters/aws/alb.adapter.js.map +1 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.js +2 -140
- package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.js +2 -134
- package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -1
- package/lib/adapters/aws/base/aws-simple-adapter.js +2 -99
- package/lib/adapters/aws/base/aws-simple-adapter.js.map +1 -1
- package/lib/adapters/aws/base/index.js +2 -18
- package/lib/adapters/aws/base/index.js.map +1 -1
- package/lib/adapters/aws/dynamodb.adapter.js +2 -64
- package/lib/adapters/aws/dynamodb.adapter.js.map +1 -1
- package/lib/adapters/aws/event-bridge.adapter.js +2 -75
- package/lib/adapters/aws/event-bridge.adapter.js.map +1 -1
- package/lib/adapters/aws/index.js +2 -27
- package/lib/adapters/aws/index.js.map +1 -1
- package/lib/adapters/aws/lambda-edge.adapter.js +2 -284
- package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -1
- package/lib/adapters/aws/s3.adapter.js +2 -63
- package/lib/adapters/aws/s3.adapter.js.map +1 -1
- package/lib/adapters/aws/sns.adapter.js +2 -63
- package/lib/adapters/aws/sns.adapter.js.map +1 -1
- package/lib/adapters/aws/sqs.adapter.js +2 -64
- package/lib/adapters/aws/sqs.adapter.js.map +1 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.js +2 -202
- package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -1
- package/lib/adapters/azure/index.js +2 -18
- package/lib/adapters/azure/index.js.map +1 -1
- package/lib/adapters/digital-ocean/http-function.adapter.js +2 -118
- package/lib/adapters/digital-ocean/http-function.adapter.js.map +1 -1
- package/lib/adapters/digital-ocean/index.js +2 -18
- package/lib/adapters/digital-ocean/index.js.map +1 -1
- package/lib/adapters/dummy/dummy.adapter.js +2 -54
- package/lib/adapters/dummy/dummy.adapter.js.map +1 -1
- package/lib/adapters/dummy/index.js +2 -18
- package/lib/adapters/dummy/index.js.map +1 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js +2 -126
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -1
- package/lib/adapters/huawei/index.js +2 -18
- package/lib/adapters/huawei/index.js.map +1 -1
- package/lib/contracts/adapter.contract.js +2 -18
- package/lib/contracts/adapter.contract.js.map +1 -1
- package/lib/contracts/framework.contract.js +2 -7
- package/lib/contracts/framework.contract.js.map +1 -1
- package/lib/contracts/handler.contract.js +2 -13
- package/lib/contracts/handler.contract.js.map +1 -1
- package/lib/contracts/index.js +2 -21
- package/lib/contracts/index.js.map +1 -1
- package/lib/contracts/resolver.contract.js +2 -15
- package/lib/contracts/resolver.contract.js.map +1 -1
- package/lib/core/base-handler.js +2 -67
- package/lib/core/base-handler.js.map +1 -1
- package/lib/core/constants.js +2 -33
- package/lib/core/constants.js.map +1 -1
- package/lib/core/current-invoke.js +2 -46
- package/lib/core/current-invoke.js.map +1 -1
- package/lib/core/event-body.js +2 -31
- package/lib/core/event-body.js.map +1 -1
- package/lib/core/headers.js +3 -97
- package/lib/core/headers.js.map +1 -1
- package/lib/core/index.js +2 -28
- package/lib/core/index.js.map +1 -1
- package/lib/core/is-binary.js +2 -118
- package/lib/core/is-binary.js.map +1 -1
- package/lib/core/logger.js +2 -115
- package/lib/core/logger.js.map +1 -1
- package/lib/core/no-op.js +2 -12
- package/lib/core/no-op.js.map +1 -1
- package/lib/core/optional.js +2 -31
- package/lib/core/optional.js.map +1 -1
- package/lib/core/path.js +2 -68
- package/lib/core/path.js.map +1 -1
- package/lib/core/stream.js +2 -63
- package/lib/core/stream.js.map +1 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.js +2 -87
- package/lib/frameworks/apollo-server/apollo-server.framework.js.map +1 -1
- package/lib/frameworks/apollo-server/index.js +2 -18
- package/lib/frameworks/apollo-server/index.js.map +1 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.js +2 -66
- package/lib/frameworks/body-parser/base-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/index.js +2 -22
- package/lib/frameworks/body-parser/index.js.map +1 -1
- package/lib/frameworks/body-parser/json-body-parser.framework.js +2 -29
- package/lib/frameworks/body-parser/json-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/raw-body-parser.framework.js +2 -29
- package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/text-body-parser.framework.js +2 -29
- package/lib/frameworks/body-parser/text-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +2 -29
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +1 -1
- package/lib/frameworks/cors/cors.framework.js +3 -145
- package/lib/frameworks/cors/cors.framework.js.map +1 -1
- package/lib/frameworks/cors/index.js +2 -18
- package/lib/frameworks/cors/index.js.map +1 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.js +2 -33
- package/lib/frameworks/deepkit/http-deepkit.framework.js.map +1 -1
- package/lib/frameworks/deepkit/index.js +2 -18
- package/lib/frameworks/deepkit/index.js.map +1 -1
- package/lib/frameworks/express/express.framework.js +2 -22
- package/lib/frameworks/express/express.framework.js.map +1 -1
- package/lib/frameworks/express/index.js +2 -18
- package/lib/frameworks/express/index.js.map +1 -1
- package/lib/frameworks/fastify/fastify.framework.js +2 -23
- package/lib/frameworks/fastify/fastify.framework.js.map +1 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js +2 -27
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +1 -1
- package/lib/frameworks/fastify/index.js +2 -18
- package/lib/frameworks/fastify/index.js.map +1 -1
- package/lib/frameworks/hapi/hapi.framework.js +2 -23
- package/lib/frameworks/hapi/hapi.framework.js.map +1 -1
- package/lib/frameworks/hapi/index.js +2 -18
- package/lib/frameworks/hapi/index.js.map +1 -1
- package/lib/frameworks/koa/index.js +2 -18
- package/lib/frameworks/koa/index.js.map +1 -1
- package/lib/frameworks/koa/koa.framework.js +2 -22
- package/lib/frameworks/koa/koa.framework.js.map +1 -1
- package/lib/frameworks/lazy/index.js +2 -18
- package/lib/frameworks/lazy/index.js.map +1 -1
- package/lib/frameworks/lazy/lazy.framework.js +2 -82
- package/lib/frameworks/lazy/lazy.framework.js.map +1 -1
- package/lib/frameworks/trpc/index.js +2 -18
- package/lib/frameworks/trpc/index.js.map +1 -1
- package/lib/frameworks/trpc/trpc.framework.js +2 -153
- package/lib/frameworks/trpc/trpc.framework.js.map +1 -1
- package/lib/handlers/aws/aws-stream.handler.js +2 -169
- package/lib/handlers/aws/aws-stream.handler.js.map +1 -1
- package/lib/handlers/aws/index.js +2 -18
- package/lib/handlers/aws/index.js.map +1 -1
- package/lib/handlers/azure/azure.handler.js +2 -74
- package/lib/handlers/azure/azure.handler.js.map +1 -1
- package/lib/handlers/azure/index.js +2 -18
- package/lib/handlers/azure/index.js.map +1 -1
- package/lib/handlers/base/index.js +2 -18
- package/lib/handlers/base/index.js.map +1 -1
- package/lib/handlers/base/raw-request.js +2 -65
- package/lib/handlers/base/raw-request.js.map +1 -1
- package/lib/handlers/default/default.handler.js +2 -191
- package/lib/handlers/default/default.handler.js.map +1 -1
- package/lib/handlers/default/index.js +2 -18
- package/lib/handlers/default/index.js.map +1 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.js +2 -34
- package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +1 -1
- package/lib/handlers/digital-ocean/index.js +2 -18
- package/lib/handlers/digital-ocean/index.js.map +1 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.js +2 -50
- package/lib/handlers/firebase/http-firebase-v2.handler.js.map +1 -1
- package/lib/handlers/firebase/http-firebase.handler.js +2 -27
- package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
- package/lib/handlers/firebase/index.js +2 -19
- package/lib/handlers/firebase/index.js.map +1 -1
- package/lib/handlers/gcp/gcp.handler.js +2 -40
- package/lib/handlers/gcp/gcp.handler.js.map +1 -1
- package/lib/handlers/gcp/index.js +2 -18
- package/lib/handlers/gcp/index.js.map +1 -1
- package/lib/handlers/huawei/http-huawei.handler.js +2 -106
- package/lib/handlers/huawei/http-huawei.handler.js.map +1 -1
- package/lib/handlers/huawei/index.js +2 -18
- package/lib/handlers/huawei/index.js.map +1 -1
- package/lib/index.doc.js +2 -0
- package/lib/index.doc.js.map +1 -0
- package/lib/index.js +2 -22
- package/lib/index.js.map +1 -1
- package/lib/network/index.js +2 -21
- package/lib/network/index.js.map +1 -1
- package/lib/network/request.js +2 -46
- package/lib/network/request.js.map +1 -1
- package/lib/network/response-stream.js +7 -88
- package/lib/network/response-stream.js.map +1 -1
- package/lib/network/response.js +4 -127
- package/lib/network/response.js.map +1 -1
- package/lib/network/utils.js +2 -21
- package/lib/network/utils.js.map +1 -1
- package/lib/resolvers/aws-context/aws-context.resolver.js +2 -59
- package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -1
- package/lib/resolvers/aws-context/index.js +2 -18
- package/lib/resolvers/aws-context/index.js.map +1 -1
- package/lib/resolvers/callback/callback.resolver.js +2 -53
- package/lib/resolvers/callback/callback.resolver.js.map +1 -1
- package/lib/resolvers/callback/index.js +2 -18
- package/lib/resolvers/callback/index.js.map +1 -1
- package/lib/resolvers/dummy/dummy.resolver.js +2 -24
- package/lib/resolvers/dummy/dummy.resolver.js.map +1 -1
- package/lib/resolvers/dummy/index.js +2 -18
- package/lib/resolvers/dummy/index.js.map +1 -1
- package/lib/resolvers/promise/index.js +2 -18
- package/lib/resolvers/promise/index.js.map +1 -1
- package/lib/resolvers/promise/promise.resolver.js +2 -48
- package/lib/resolvers/promise/promise.resolver.js.map +1 -1
- package/lib/serverless-adapter.js +2 -176
- package/lib/serverless-adapter.js.map +1 -1
- package/package.json +61 -79
- package/lib/@types/binary-settings.d.ts +0 -43
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +0 -37
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +0 -22
- package/lib/@types/digital-ocean/index.d.ts +0 -1
- package/lib/@types/headers.d.ts +0 -39
- package/lib/@types/helpers.d.ts +0 -10
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts +0 -84
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts +0 -27
- package/lib/@types/huawei/huawei-context.d.ts +0 -203
- package/lib/@types/huawei/index.d.ts +0 -3
- package/lib/@types/index.d.ts +0 -3
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +0 -56
- package/lib/adapters/apollo-server/index.d.ts +0 -1
- package/lib/adapters/aws/alb.adapter.d.ts +0 -66
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +0 -71
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +0 -70
- package/lib/adapters/aws/base/aws-simple-adapter.d.ts +0 -85
- package/lib/adapters/aws/base/index.d.ts +0 -1
- package/lib/adapters/aws/dynamodb.adapter.d.ts +0 -56
- package/lib/adapters/aws/event-bridge.adapter.d.ts +0 -64
- package/lib/adapters/aws/index.d.ts +0 -10
- package/lib/adapters/aws/lambda-edge.adapter.d.ts +0 -213
- package/lib/adapters/aws/s3.adapter.d.ts +0 -56
- package/lib/adapters/aws/sns.adapter.d.ts +0 -56
- package/lib/adapters/aws/sqs.adapter.d.ts +0 -56
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +0 -81
- package/lib/adapters/azure/index.d.ts +0 -1
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts +0 -65
- package/lib/adapters/digital-ocean/index.d.ts +0 -1
- package/lib/adapters/dummy/dummy.adapter.d.ts +0 -30
- package/lib/adapters/dummy/index.d.ts +0 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +0 -66
- package/lib/adapters/huawei/index.d.ts +0 -1
- package/lib/contracts/adapter.contract.d.ts +0 -155
- package/lib/contracts/framework.contract.d.ts +0 -19
- package/lib/contracts/handler.contract.d.ts +0 -26
- package/lib/contracts/index.d.ts +0 -4
- package/lib/contracts/resolver.contract.d.ts +0 -86
- package/lib/core/base-handler.d.ts +0 -31
- package/lib/core/constants.d.ts +0 -31
- package/lib/core/current-invoke.d.ts +0 -48
- package/lib/core/event-body.d.ts +0 -21
- package/lib/core/headers.d.ts +0 -47
- package/lib/core/index.d.ts +0 -11
- package/lib/core/is-binary.d.ts +0 -72
- package/lib/core/logger.d.ts +0 -67
- package/lib/core/no-op.d.ts +0 -7
- package/lib/core/optional.d.ts +0 -21
- package/lib/core/path.d.ts +0 -36
- package/lib/core/stream.d.ts +0 -20
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +0 -71
- package/lib/frameworks/apollo-server/index.d.ts +0 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +0 -69
- package/lib/frameworks/body-parser/index.d.ts +0 -5
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/cors/cors.framework.d.ts +0 -78
- package/lib/frameworks/cors/index.d.ts +0 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +0 -17
- package/lib/frameworks/deepkit/index.d.ts +0 -1
- package/lib/frameworks/express/express.framework.d.ts +0 -16
- package/lib/frameworks/express/index.d.ts +0 -1
- package/lib/frameworks/fastify/fastify.framework.d.ts +0 -16
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +0 -13
- package/lib/frameworks/fastify/index.d.ts +0 -1
- package/lib/frameworks/hapi/hapi.framework.d.ts +0 -16
- 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 -16
- package/lib/frameworks/lazy/index.d.ts +0 -1
- package/lib/frameworks/lazy/lazy.framework.d.ts +0 -55
- package/lib/frameworks/trpc/index.d.ts +0 -1
- package/lib/frameworks/trpc/trpc.framework.d.ts +0 -155
- package/lib/handlers/aws/aws-stream.handler.d.ts +0 -83
- package/lib/handlers/aws/index.d.ts +0 -1
- package/lib/handlers/azure/azure.handler.d.ts +0 -45
- package/lib/handlers/azure/index.d.ts +0 -1
- package/lib/handlers/base/index.d.ts +0 -1
- package/lib/handlers/base/raw-request.d.ts +0 -30
- package/lib/handlers/default/default.handler.d.ts +0 -87
- package/lib/handlers/default/index.d.ts +0 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +0 -16
- package/lib/handlers/digital-ocean/index.d.ts +0 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +0 -26
- package/lib/handlers/firebase/http-firebase.handler.d.ts +0 -18
- package/lib/handlers/firebase/index.d.ts +0 -2
- package/lib/handlers/gcp/gcp.handler.d.ts +0 -25
- package/lib/handlers/gcp/index.d.ts +0 -1
- package/lib/handlers/huawei/http-huawei.handler.d.ts +0 -59
- package/lib/handlers/huawei/index.d.ts +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/network/index.d.ts +0 -4
- package/lib/network/request.d.ts +0 -44
- package/lib/network/response-stream.d.ts +0 -41
- package/lib/network/response.d.ts +0 -48
- package/lib/network/utils.d.ts +0 -7
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts +0 -18
- package/lib/resolvers/aws-context/index.d.ts +0 -1
- package/lib/resolvers/callback/callback.resolver.d.ts +0 -23
- package/lib/resolvers/callback/index.d.ts +0 -1
- package/lib/resolvers/dummy/dummy.resolver.d.ts +0 -13
- 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 -13
- package/lib/serverless-adapter.d.ts +0 -118
|
@@ -1,106 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.HttpHuaweiHandler = exports.__ΩHttpHuaweiHandlerOptions = exports.DEFAULT_HUAWEI_LISTEN_PORT = void 0;
|
|
27
|
-
const { __ΩFrameworkContract } = require('../../contracts');
|
|
28
|
-
const { __ΩAdapterContract } = require('../../contracts');
|
|
29
|
-
const { __ΩResolverContract } = require('../../contracts');
|
|
30
|
-
const { __ΩBinarySettings } = require('../../@types');
|
|
31
|
-
const { __ΩILogger } = require('../../core');
|
|
32
|
-
const { __ΩServerlessHandler } = require('../../contracts');
|
|
33
|
-
function __assignType(fn, args) {
|
|
34
|
-
fn.__type = args;
|
|
35
|
-
return fn;
|
|
36
|
-
}
|
|
37
|
-
//#region Imports
|
|
38
|
-
const http = __importStar(require("http"));
|
|
39
|
-
const core_1 = require("../../core");
|
|
40
|
-
//#endregion
|
|
41
|
-
/**
|
|
42
|
-
* The default port that huawei will proxy the request to your framework
|
|
43
|
-
*
|
|
44
|
-
* {@link https://support.huaweicloud.com/intl/en-us/ae-ad-1-usermanual-functiongraph/functiongraph_01_1442.html#functiongraph_01_1442__li194597302096 | Reference}
|
|
45
|
-
*
|
|
46
|
-
* @breadcrumb Handlers / HttpHuaweiHandler
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
49
|
-
exports.DEFAULT_HUAWEI_LISTEN_PORT = 8000;
|
|
50
|
-
const __ΩHttpHuaweiHandlerOptions = ['port', 'requestListener', '', 'httpServerFactory', 'P\'4!8P!2"!/#4$8M'];
|
|
51
|
-
exports.__ΩHttpHuaweiHandlerOptions = __ΩHttpHuaweiHandlerOptions;
|
|
52
|
-
/**
|
|
53
|
-
* The class that implements a huawei serverless handler with http function that exposes a http server in specific port.
|
|
54
|
-
*
|
|
55
|
-
* In this Handler, you don't need to specific resolver and adapter, so you can use DummyAdapter and DummyResolver instead.
|
|
56
|
-
*
|
|
57
|
-
* @see https://support.huaweicloud.com/intl/en-us/ae-ad-1-usermanual-functiongraph/functiongraph_01_1442.html#functiongraph_01_1442__li194597302096
|
|
58
|
-
*
|
|
59
|
-
* @breadcrumb Handlers / HttpHuaweiHandler
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
class HttpHuaweiHandler {
|
|
63
|
-
//#region Constructor
|
|
64
|
-
/**
|
|
65
|
-
* Construtor padrão
|
|
66
|
-
*/
|
|
67
|
-
constructor(options) {
|
|
68
|
-
this.options = options;
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region Public Methods
|
|
72
|
-
/**
|
|
73
|
-
* {@inheritDoc}
|
|
74
|
-
*/
|
|
75
|
-
getHandler(app, framework, _, __, binarySettings, respondWithErrors, log) {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
const requestListener = __assignType((req, res) => {
|
|
78
|
-
framework.sendRequest(app, req, res);
|
|
79
|
-
}, ['req', 'res', '', 'P"2!"2""/#']);
|
|
80
|
-
const server = (0, core_1.getDefaultIfUndefined)((_a = this.options) === null || _a === void 0 ? void 0 : _a.httpServerFactory, this.createHttpServer.bind(this))(requestListener);
|
|
81
|
-
const port = (0, core_1.getDefaultIfUndefined)((_b = this.options) === null || _b === void 0 ? void 0 : _b.port, exports.DEFAULT_HUAWEI_LISTEN_PORT);
|
|
82
|
-
server.listen(port, () => {
|
|
83
|
-
log.debug('SERVERLESS_ADAPTER:PROXY: Server started.');
|
|
84
|
-
log.debug(`SERVERLESS_ADAPTER:PROXY: Listening the Huawei Requests in port ${port}`);
|
|
85
|
-
});
|
|
86
|
-
return () => {
|
|
87
|
-
log.debug('SERVERLESS_ADAPTER:PROXY: Disposing the server');
|
|
88
|
-
return new Promise(__assignType((resolve, reject) => {
|
|
89
|
-
server.close(__assignType(err => (err ? reject(err) : resolve()), ['err', '', 'P"2!"/"']));
|
|
90
|
-
}, ['resolve', 'reject', '', 'P"2!"2""/#']));
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region Protected Methods
|
|
95
|
-
/**
|
|
96
|
-
* The method that creates the instance of http server
|
|
97
|
-
*
|
|
98
|
-
* @param requestListener - O método que lidará com as requisições recebidas
|
|
99
|
-
*/
|
|
100
|
-
createHttpServer(requestListener) {
|
|
101
|
-
return http.createServer(requestListener);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.HttpHuaweiHandler = HttpHuaweiHandler;
|
|
105
|
-
HttpHuaweiHandler.__type = ['TApp', () => __ΩHttpHuaweiHandlerOptions, 'options', 'constructor', 'app', () => __ΩFrameworkContract, 'framework', () => __ΩAdapterContract, '_', () => __ΩResolverContract, '__', () => __ΩBinarySettings, 'binarySettings', 'respondWithErrors', () => __ΩILogger, 'log', () => __ΩServerlessHandler, 'getHandler', 'requestListener', 'createHttpServer', 'b!Pn"2#8<9"0$Pe"!2%e"!o&"2\'$$$o($F2)$$$$$o*&2+n,2-)2.n/20$`o1"02P!23!04<5e!!$$$$$`6\''];
|
|
106
|
-
//# sourceMappingURL=http-huawei.handler.js.map
|
|
1
|
+
"use strict";var R=Object.create,s=Object.defineProperty,h=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,y=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},l=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d(e))!g.call(t,n)&&n!==r&&s(t,n,{get:()=>e[n],enumerable:!(o=h(e,n))||o.enumerable});return t},H=(t,e,r)=>(r=t!=null?R(f(t)):{},l(e||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t)),w=t=>l(s({},"__esModule",{value:!0}),t),O={};y(O,{DEFAULT_HUAWEI_LISTEN_PORT:()=>S,HttpHuaweiHandler:()=>D});module.exports=w(O);var A=H(require("http")),P=require("../../core");const S=8e3;class D{constructor(e){this.options=e}getHandler(e,r,o,n,L,T,a){var c,v;const b=(_,i)=>{r.sendRequest(e,_,i)},p=(0,P.getDefaultIfUndefined)((c=this.options)==null?void 0:c.httpServerFactory,this.createHttpServer.bind(this))(b),u=(0,P.getDefaultIfUndefined)((v=this.options)==null?void 0:v.port,S);return p.listen(u,()=>{a.debug("SERVERLESS_ADAPTER:PROXY: Server started."),a.debug(`SERVERLESS_ADAPTER:PROXY: Listening the Huawei Requests in port ${u}`)}),()=>(a.debug("SERVERLESS_ADAPTER:PROXY: Disposing the server"),new Promise((_,i)=>{p.close(E=>E?i(E):_())}))}createHttpServer(e){return A.createServer(e)}}
|
|
2
|
+
//# sourceMappingURL=http-huawei.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-huawei.handler.js","
|
|
1
|
+
{"version":3,"file":"http-huawei.handler.js","sources":["../../../src/handlers/huawei/http-huawei.handler.ts"],"sourcesContent":["//#region Imports\n\nimport * as http from 'http';\nimport { RequestListener } from 'http';\nimport { BinarySettings } from '../../@types';\nimport {\n AdapterContract,\n FrameworkContract,\n HandlerContract,\n ResolverContract,\n ServerlessHandler,\n} from '../../contracts';\nimport { ILogger, getDefaultIfUndefined } from '../../core';\n\n//#endregion\n\n/**\n * The default port that huawei will proxy the request to your framework\n *\n * {@link https://support.huaweicloud.com/intl/en-us/ae-ad-1-usermanual-functiongraph/functiongraph_01_1442.html#functiongraph_01_1442__li194597302096 | Reference}\n *\n * @breadcrumb Handlers / HttpHuaweiHandler\n * @public\n */\nexport const DEFAULT_HUAWEI_LISTEN_PORT: number = 8000;\n\n/**\n * The options to customize {@link HttpHuaweiHandler}\n *\n * @breadcrumb Handlers / HttpHuaweiHandler\n * @public\n */\nexport type HttpHuaweiHandlerOptions = {\n /**\n * @defaultValue {@link DEFAULT_HUAWEI_LISTEN_PORT}\n */\n port?: number;\n\n /**\n * The factory to create a http server to use to listen huawei requests\n */\n httpServerFactory?: (requestListener: RequestListener) => http.Server;\n};\n\n/**\n * The class that implements a huawei serverless handler with http function that exposes a http server in specific port.\n *\n * In this Handler, you don't need to specific resolver and adapter, so you can use DummyAdapter and DummyResolver instead.\n *\n * @see https://support.huaweicloud.com/intl/en-us/ae-ad-1-usermanual-functiongraph/functiongraph_01_1442.html#functiongraph_01_1442__li194597302096\n *\n * @breadcrumb Handlers / HttpHuaweiHandler\n * @public\n */\nexport class HttpHuaweiHandler<TApp>\n implements HandlerContract<TApp, void, void, void, void, Promise<void>>\n{\n //#region Constructor\n\n /**\n * Construtor padrão\n */\n constructor(protected readonly options?: HttpHuaweiHandlerOptions) {}\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getHandler(\n app: TApp,\n framework: FrameworkContract<TApp>,\n _: AdapterContract<void, void, void>[],\n __: ResolverContract<void, void, void, void, void>,\n binarySettings: BinarySettings,\n respondWithErrors: boolean,\n log: ILogger,\n ): ServerlessHandler<Promise<void>> {\n const requestListener: RequestListener = (req, res) => {\n framework.sendRequest(app, req, res);\n };\n\n const server = getDefaultIfUndefined(\n this.options?.httpServerFactory,\n this.createHttpServer.bind(this),\n )(requestListener);\n\n const port = getDefaultIfUndefined(\n this.options?.port,\n DEFAULT_HUAWEI_LISTEN_PORT,\n );\n\n server.listen(port, () => {\n log.debug('SERVERLESS_ADAPTER:PROXY: Server started.');\n log.debug(\n `SERVERLESS_ADAPTER:PROXY: Listening the Huawei Requests in port ${port}`,\n );\n });\n\n return () => {\n log.debug('SERVERLESS_ADAPTER:PROXY: Disposing the server');\n\n return new Promise((resolve, reject) => {\n server.close(err => (err ? reject(err) : resolve()));\n });\n };\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * The method that creates the instance of http server\n *\n * @param requestListener - O método que lidará com as requisições recebidas\n */\n protected createHttpServer(requestListener: RequestListener): http.Server {\n return http.createServer(requestListener);\n }\n\n //#endregion\n}\n"],"names":["http_huawei_handler_exports","__export","DEFAULT_HUAWEI_LISTEN_PORT","HttpHuaweiHandler","__toCommonJS","http","__toESM","import_core","options","app","framework","_","__","binarySettings","respondWithErrors","log","requestListener","req","res","server","_a","port","_b","resolve","reject","err"],"mappings":"kiBAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,2BAAA,IAAAE,EAAA,kBAAA,IAAAC,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAJ,CAAA,EAEA,IAAsBK,EAAAC,EAAA,QAAA,MAAA,CAAA,EAUyBC,EAAA,QAAA,YAAA,EAYxC,MAAML,EAAqC,IA8B3C,MAAMC,CAEb,CAME,YAA+BK,EAAoC,CAApC,KAAA,QAAAA,CAAqC,CAS7D,WACLC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACkC,SAC5B,MAAAC,EAAmC,CAACC,EAAKC,IAAQ,CAC3CR,EAAA,YAAYD,EAAKQ,EAAKC,CAAG,CAAA,EAG/BC,KAASZ,EAAA,wBACba,EAAA,KAAK,UAAL,YAAAA,EAAc,kBACd,KAAK,iBAAiB,KAAK,IAAI,GAC/BJ,CAAe,EAEXK,KAAOd,EAAA,wBACXe,EAAA,KAAK,UAAL,YAAAA,EAAc,KACdpB,CAAA,EAGK,OAAAiB,EAAA,OAAOE,EAAM,IAAM,CACxBN,EAAI,MAAM,2CAA2C,EACjDA,EAAA,MACF,mEAAmEM,GAAA,CACrE,CACD,EAEM,KACLN,EAAI,MAAM,gDAAgD,EAEnD,IAAI,QAAQ,CAACQ,EAASC,IAAW,CACtCL,EAAO,MAAcM,GAAAA,EAAMD,EAAOC,CAAG,EAAIF,GAAU,CAAA,CACpD,EAEL,CAWU,iBAAiBP,EAA+C,CACjE,OAAAX,EAAK,aAAaW,CAAe,CAC1C,CAGF"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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("./http-huawei.handler"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var _=Object.defineProperty,u=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,O=Object.prototype.hasOwnProperty,a=(r,e,p,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of s(e))!O.call(r,t)&&t!==p&&_(r,t,{get:()=>e[t],enumerable:!(o=u(e,t))||o.enumerable});return r},c=(r,e,p)=>(a(r,e,"default"),p&&a(p,e,"default")),l=r=>a(_({},"__esModule",{value:!0}),r),n={};module.exports=l(n);c(n,require("./http-huawei.handler"),module.exports);
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/handlers/huawei/index.ts"],"sourcesContent":["export * from './http-huawei.handler';\n"],"names":["huawei_exports","__toCommonJS","__reExport"],"mappings":"6YAAAA,EAAA,CAAA,EAAA,OAAA,QAAAC,EAAAD,CAAA,EAAAE,EAAAF,EAAc,QAAd,uBAAA,EAAA,OAAA,OAAA"}
|
package/lib/index.doc.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var x=Object.defineProperty,q=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,u=(o,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of _(t))!a.call(o,p)&&p!==s&&x(o,p,{get:()=>t[p],enumerable:!(i=q(t,p))||i.enumerable});return o},r=(o,t,s)=>(u(o,t,"default"),s&&u(s,t,"default")),n=o=>u(x({},"__esModule",{value:!0}),o),e={};module.exports=n(e);r(e,require("./@types"),module.exports);r(e,require("./@types/huawei"),module.exports);r(e,require("./adapters/apollo-server"),module.exports);r(e,require("./adapters/aws"),module.exports);r(e,require("./adapters/azure"),module.exports);r(e,require("./adapters/digital-ocean"),module.exports);r(e,require("./adapters/dummy"),module.exports);r(e,require("./adapters/huawei"),module.exports);r(e,require("./contracts"),module.exports);r(e,require("./core"),module.exports);r(e,require("./frameworks/apollo-server"),module.exports);r(e,require("./frameworks/body-parser"),module.exports);r(e,require("./frameworks/cors"),module.exports);r(e,require("./frameworks/deepkit"),module.exports);r(e,require("./frameworks/express"),module.exports);r(e,require("./frameworks/fastify"),module.exports);r(e,require("./frameworks/koa"),module.exports);r(e,require("./frameworks/hapi"),module.exports);r(e,require("./frameworks/lazy"),module.exports);r(e,require("./frameworks/trpc"),module.exports);r(e,require("./handlers/azure"),module.exports);r(e,require("./handlers/aws"),module.exports);r(e,require("./handlers/base"),module.exports);r(e,require("./handlers/default"),module.exports);r(e,require("./handlers/digital-ocean"),module.exports);r(e,require("./handlers/firebase"),module.exports);r(e,require("./handlers/gcp"),module.exports);r(e,require("./handlers/huawei"),module.exports);r(e,require("./network"),module.exports);r(e,require("./resolvers/aws-context"),module.exports);r(e,require("./resolvers/callback"),module.exports);r(e,require("./resolvers/promise"),module.exports);r(e,require("./resolvers/dummy"),module.exports);r(e,require("./serverless-adapter"),module.exports);
|
|
2
|
+
//# sourceMappingURL=index.doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.doc.js","sources":["../src/index.doc.ts"],"sourcesContent":["export * from './@types';\nexport * from './@types/huawei';\nexport * from './adapters/apollo-server';\nexport * from './adapters/aws';\nexport * from './adapters/azure';\nexport * from './adapters/digital-ocean';\nexport * from './adapters/dummy';\nexport * from './adapters/huawei';\nexport * from './contracts';\nexport * from './core';\nexport * from './frameworks/apollo-server';\nexport * from './frameworks/body-parser';\nexport * from './frameworks/cors';\nexport * from './frameworks/deepkit';\nexport * from './frameworks/express';\nexport * from './frameworks/fastify';\nexport * from './frameworks/koa';\nexport * from './frameworks/hapi';\nexport * from './frameworks/lazy';\nexport * from './frameworks/trpc';\nexport * from './handlers/azure';\nexport * from './handlers/aws';\nexport * from './handlers/base';\nexport * from './handlers/default';\nexport * from './handlers/digital-ocean';\nexport * from './handlers/firebase';\nexport * from './handlers/gcp';\nexport * from './handlers/huawei';\nexport * from './network';\nexport * from './resolvers/aws-context';\nexport * from './resolvers/callback';\nexport * from './resolvers/promise';\nexport * from './resolvers/dummy';\nexport * from './serverless-adapter';\n"],"names":["index_doc_exports","__toCommonJS","__reExport"],"mappings":"6YAAAA,EAAA,CAAA,EAAA,OAAA,QAAAC,EAAAD,CAAA,EAAAE,EAAAF,EAAc,QAAd,UAAA,EAAA,OAAA,OAAA,EACAE,EAAAF,EAAc,QADd,iBAAA,EAAA,OAAA,OAAA,EAEAE,EAAAF,EAAc,QAFd,0BAAA,EAAA,OAAA,OAAA,EAGAE,EAAAF,EAAc,QAHd,gBAAA,EAAA,OAAA,OAAA,EAIAE,EAAAF,EAAc,QAJd,kBAAA,EAAA,OAAA,OAAA,EAKAE,EAAAF,EAAc,QALd,0BAAA,EAAA,OAAA,OAAA,EAMAE,EAAAF,EAAc,QANd,kBAAA,EAAA,OAAA,OAAA,EAOAE,EAAAF,EAAc,QAPd,mBAAA,EAAA,OAAA,OAAA,EAQAE,EAAAF,EAAc,QARd,aAAA,EAAA,OAAA,OAAA,EASAE,EAAAF,EAAc,QATd,QAAA,EAAA,OAAA,OAAA,EAUAE,EAAAF,EAAc,QAVd,4BAAA,EAAA,OAAA,OAAA,EAWAE,EAAAF,EAAc,QAXd,0BAAA,EAAA,OAAA,OAAA,EAYAE,EAAAF,EAAc,QAZd,mBAAA,EAAA,OAAA,OAAA,EAaAE,EAAAF,EAAc,QAbd,sBAAA,EAAA,OAAA,OAAA,EAcAE,EAAAF,EAAc,QAdd,sBAAA,EAAA,OAAA,OAAA,EAeAE,EAAAF,EAAc,QAfd,sBAAA,EAAA,OAAA,OAAA,EAgBAE,EAAAF,EAAc,QAhBd,kBAAA,EAAA,OAAA,OAAA,EAiBAE,EAAAF,EAAc,QAjBd,mBAAA,EAAA,OAAA,OAAA,EAkBAE,EAAAF,EAAc,QAlBd,mBAAA,EAAA,OAAA,OAAA,EAmBAE,EAAAF,EAAc,QAnBd,mBAAA,EAAA,OAAA,OAAA,EAoBAE,EAAAF,EAAc,QApBd,kBAAA,EAAA,OAAA,OAAA,EAqBAE,EAAAF,EAAc,QArBd,gBAAA,EAAA,OAAA,OAAA,EAsBAE,EAAAF,EAAc,QAtBd,iBAAA,EAAA,OAAA,OAAA,EAuBAE,EAAAF,EAAc,QAvBd,oBAAA,EAAA,OAAA,OAAA,EAwBAE,EAAAF,EAAc,QAxBd,0BAAA,EAAA,OAAA,OAAA,EAyBAE,EAAAF,EAAc,QAzBd,qBAAA,EAAA,OAAA,OAAA,EA0BAE,EAAAF,EAAc,QA1Bd,gBAAA,EAAA,OAAA,OAAA,EA2BAE,EAAAF,EAAc,QA3Bd,mBAAA,EAAA,OAAA,OAAA,EA4BAE,EAAAF,EAAc,QA5Bd,WAAA,EAAA,OAAA,OAAA,EA6BAE,EAAAF,EAAc,QA7Bd,yBAAA,EAAA,OAAA,OAAA,EA8BAE,EAAAF,EAAc,QA9Bd,sBAAA,EAAA,OAAA,OAAA,EA+BAE,EAAAF,EAAc,QA/Bd,qBAAA,EAAA,OAAA,OAAA,EAgCAE,EAAAF,EAAc,QAhCd,mBAAA,EAAA,OAAA,OAAA,EAiCAE,EAAAF,EAAc,QAjCd,sBAAA,EAAA,OAAA,OAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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("./@types"), exports);
|
|
18
|
-
__exportStar(require("./contracts"), exports);
|
|
19
|
-
__exportStar(require("./core"), exports);
|
|
20
|
-
__exportStar(require("./network"), exports);
|
|
21
|
-
__exportStar(require("./serverless-adapter"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var u=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,_=(r,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of i(e))!c.call(r,p)&&p!==a&&u(r,p,{get:()=>e[p],enumerable:!(s=n(e,p))||s.enumerable});return r},o=(r,e,a)=>(_(r,e,"default"),a&&_(a,e,"default")),O=r=>_(u({},"__esModule",{value:!0}),r),t={};module.exports=O(t);o(t,require("./@types"),module.exports);o(t,require("./contracts"),module.exports);o(t,require("./core"),module.exports);o(t,require("./network"),module.exports);o(t,require("./serverless-adapter"),module.exports);
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from './@types';\nexport * from './contracts';\nexport * from './core';\nexport * from './network';\nexport * from './serverless-adapter';\n"],"names":["src_exports","__toCommonJS","__reExport"],"mappings":"6YAAAA,EAAA,CAAA,EAAA,OAAA,QAAAC,EAAAD,CAAA,EAAAE,EAAAF,EAAc,QAAd,UAAA,EAAA,OAAA,OAAA,EACAE,EAAAF,EAAc,QADd,aAAA,EAAA,OAAA,OAAA,EAEAE,EAAAF,EAAc,QAFd,QAAA,EAAA,OAAA,OAAA,EAGAE,EAAAF,EAAc,QAHd,WAAA,EAAA,OAAA,OAAA,EAIAE,EAAAF,EAAc,QAJd,sBAAA,EAAA,OAAA,OAAA"}
|
package/lib/network/index.js
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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("./request"), exports);
|
|
18
|
-
__exportStar(require("./response"), exports);
|
|
19
|
-
__exportStar(require("./response-stream"), exports);
|
|
20
|
-
__exportStar(require("./utils"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var u=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,O=Object.prototype.hasOwnProperty,_=(r,e,p,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of i(e))!O.call(r,t)&&t!==p&&u(r,t,{get:()=>e[t],enumerable:!(s=n(e,t))||s.enumerable});return r},a=(r,e,p)=>(_(r,e,"default"),p&&_(p,e,"default")),c=r=>_(u({},"__esModule",{value:!0}),r),o={};module.exports=c(o);a(o,require("./request"),module.exports);a(o,require("./response"),module.exports);a(o,require("./response-stream"),module.exports);a(o,require("./utils"),module.exports);
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/network/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/network/index.ts"],"sourcesContent":["export * from './request';\nexport * from './response';\nexport * from './response-stream';\nexport * from './utils';\n"],"names":["network_exports","__toCommonJS","__reExport"],"mappings":"6YAAAA,EAAA,CAAA,EAAA,OAAA,QAAAC,EAAAD,CAAA,EAAAE,EAAAF,EAAc,QAAd,WAAA,EAAA,OAAA,OAAA,EACAE,EAAAF,EAAc,QADd,YAAA,EAAA,OAAA,OAAA,EAEAE,EAAAF,EAAc,QAFd,mBAAA,EAAA,OAAA,OAAA,EAGAE,EAAAF,EAAc,QAHd,SAAA,EAAA,OAAA,OAAA"}
|
package/lib/network/request.js
CHANGED
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.ServerlessRequest = exports.__ΩServerlessRequestProps = void 0;
|
|
4
|
-
const { __ΩSingleValueHeaders } = require('../@types');
|
|
5
|
-
// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http
|
|
6
|
-
const http_1 = require("http");
|
|
7
|
-
const core_1 = require("../core");
|
|
8
|
-
const HTTPS_PORT = 443;
|
|
9
|
-
const __ΩServerlessRequestProps = ['method', 'url', () => __ΩSingleValueHeaders, 'headers', 'body', 'remoteAddress', 'P&4!&4"n#4$P!WJ4%8&4&8M'];
|
|
10
|
-
exports.__ΩServerlessRequestProps = __ΩServerlessRequestProps;
|
|
11
|
-
/**
|
|
12
|
-
* The class that represents an {@link http#IncomingMessage} created by the library to represent an actual request to the framework.
|
|
13
|
-
*
|
|
14
|
-
* @breadcrumb Network / ServerlessRequest
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
class ServerlessRequest extends http_1.IncomingMessage {
|
|
18
|
-
constructor({ method, url, headers, body, remoteAddress, }) {
|
|
19
|
-
super({
|
|
20
|
-
encrypted: true,
|
|
21
|
-
readable: false,
|
|
22
|
-
remoteAddress,
|
|
23
|
-
address: () => ({ port: HTTPS_PORT }),
|
|
24
|
-
end: core_1.NO_OP,
|
|
25
|
-
destroy: core_1.NO_OP,
|
|
26
|
-
});
|
|
27
|
-
this.statusCode = 200;
|
|
28
|
-
this.statusMessage = 'OK';
|
|
29
|
-
this.complete = true;
|
|
30
|
-
this.httpVersion = '1.1';
|
|
31
|
-
this.httpVersionMajor = 1;
|
|
32
|
-
this.httpVersionMinor = 1;
|
|
33
|
-
this.method = method;
|
|
34
|
-
this.headers = headers;
|
|
35
|
-
this.body = body;
|
|
36
|
-
this.url = url;
|
|
37
|
-
this.ip = remoteAddress;
|
|
38
|
-
this._read = () => {
|
|
39
|
-
this.push(body);
|
|
40
|
-
this.push(null);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.ServerlessRequest = ServerlessRequest;
|
|
45
|
-
ServerlessRequest.__type = [() => http_1.IncomingMessage, () => __ΩServerlessRequestProps, 'param0', 'constructor', 'ip', 'body', 'P7!Pn"2#"0$&3%8P!WJ3&85'];
|
|
46
|
-
//# sourceMappingURL=request.js.map
|
|
1
|
+
"use strict";var i=Object.defineProperty,u=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,_=Object.prototype.hasOwnProperty,c=(t,e)=>{for(var s in e)i(t,s,{get:e[s],enumerable:!0})},O=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of h(e))!_.call(t,r)&&r!==s&&i(t,r,{get:()=>e[r],enumerable:!(o=u(e,r))||o.enumerable});return t},l=t=>O(i({},"__esModule",{value:!0}),t),n={};c(n,{ServerlessRequest:()=>d});module.exports=l(n);var v=require("http"),a=require("../core");const P=443;class d extends v.IncomingMessage{constructor({method:e,url:s,headers:o,body:r,remoteAddress:p}){super({encrypted:!0,readable:!1,remoteAddress:p,address:()=>({port:P}),end:a.NO_OP,destroy:a.NO_OP}),this.statusCode=200,this.statusMessage="OK",this.complete=!0,this.httpVersion="1.1",this.httpVersionMajor=1,this.httpVersionMinor=1,this.method=e,this.headers=o,this.body=r,this.url=s,this.ip=p,this._read=()=>{this.push(r),this.push(null)}}}
|
|
2
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","
|
|
1
|
+
{"version":3,"file":"request.js","sources":["../../src/network/request.ts"],"sourcesContent":["// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\nimport { IncomingMessage } from 'http';\nimport { AddressInfo } from 'net';\nimport { SingleValueHeaders } from '../@types';\nimport { NO_OP } from '../core';\n\nconst HTTPS_PORT = 443;\n\n/**\n * The properties to create a {@link ServerlessRequest}\n *\n * @breadcrumb Network / ServerlessRequest\n * @public\n */\nexport interface ServerlessRequestProps {\n /**\n * The HTTP Method of the request\n */\n method: string;\n\n /**\n * The URL requested\n */\n url: string;\n\n /**\n * The headers from the event source\n */\n headers: SingleValueHeaders;\n\n /**\n * The body from the event source\n */\n body?: Buffer | Uint8Array;\n\n /**\n * The IP Address from caller\n */\n remoteAddress?: string;\n}\n\n/**\n * The class that represents an {@link http#IncomingMessage} created by the library to represent an actual request to the framework.\n *\n * @breadcrumb Network / ServerlessRequest\n * @public\n */\nexport class ServerlessRequest extends IncomingMessage {\n constructor({\n method,\n url,\n headers,\n body,\n remoteAddress,\n }: ServerlessRequestProps) {\n super({\n encrypted: true,\n readable: false,\n remoteAddress,\n address: () => ({ port: HTTPS_PORT } as AddressInfo),\n end: NO_OP,\n destroy: NO_OP,\n } as any);\n\n this.statusCode = 200;\n this.statusMessage = 'OK';\n this.complete = true;\n this.httpVersion = '1.1';\n this.httpVersionMajor = 1;\n this.httpVersionMinor = 1;\n this.method = method;\n this.headers = headers;\n this.body = body;\n this.url = url;\n this.ip = remoteAddress;\n\n this._read = () => {\n this.push(body);\n this.push(null);\n };\n }\n\n ip?: string;\n body?: Buffer | Uint8Array;\n}\n"],"names":["request_exports","__export","ServerlessRequest","__toCommonJS","import_http","import_core","HTTPS_PORT","method","url","headers","body","remoteAddress"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,kBAAA,IAAAE,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAH,CAAA,EACA,IAAgCI,EAAA,QAAA,MAAA,EAGVC,EAAA,QAAA,SAAA,EAEtB,MAAMC,EAAa,IAyCZ,MAAMJ,UAA0BE,EAAgB,eAAA,CACrD,YAAY,CACV,OAAAG,EACA,IAAAC,EACA,QAAAC,EACA,KAAAC,EACA,cAAAC,CAAA,EACyB,CACnB,MAAA,CACJ,UAAW,GACX,SAAU,GACV,cAAAA,EACA,QAAS,KAAO,CAAE,KAAML,IACxB,IAAKD,EAAA,MACL,QAASA,EAAA,KAAA,CACH,EAER,KAAK,WAAa,IAClB,KAAK,cAAgB,KACrB,KAAK,SAAW,GAChB,KAAK,YAAc,MACnB,KAAK,iBAAmB,EACxB,KAAK,iBAAmB,EACxB,KAAK,OAASE,EACd,KAAK,QAAUE,EACf,KAAK,KAAOC,EACZ,KAAK,IAAMF,EACX,KAAK,GAAKG,EAEV,KAAK,MAAQ,IAAM,CACjB,KAAK,KAAKD,CAAI,EACd,KAAK,KAAK,IAAI,CAAA,CAElB,CAIF"}
|
|
@@ -1,88 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
return fn;
|
|
9
|
-
}
|
|
10
|
-
const http_1 = require("http");
|
|
11
|
-
const core_1 = require("../core");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
const endChunked = '0\r\n\r\n';
|
|
14
|
-
const headerEnd = '\r\n\r\n';
|
|
15
|
-
const endStatusSeparator = '\r\n';
|
|
16
|
-
const __ΩServerlessStreamResponseProps = ['method', 'statusCode', () => __ΩBothValueHeaders, 'headers', '', 'onReceiveHeaders', () => __ΩILogger, 'log', 'P&4!8P\'2"n#2$!/%4&n\'4(M'];
|
|
17
|
-
exports.__ΩServerlessStreamResponseProps = __ΩServerlessStreamResponseProps;
|
|
18
|
-
/**
|
|
19
|
-
* The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.
|
|
20
|
-
* This response is specially built to deal with transfer-encoding: chunked
|
|
21
|
-
*
|
|
22
|
-
* @breadcrumb Network / ServerlessStreamResponse
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
class ServerlessStreamResponse extends http_1.ServerResponse {
|
|
26
|
-
constructor({ method, onReceiveHeaders, log, }) {
|
|
27
|
-
super({ method });
|
|
28
|
-
this.useChunkedEncodingByDefault = true;
|
|
29
|
-
this.chunkedEncoding = true;
|
|
30
|
-
let internalWritable = null;
|
|
31
|
-
let isFirstCall = true;
|
|
32
|
-
// this ignore is used because I need to ignore these write calls:
|
|
33
|
-
// https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L934-L935
|
|
34
|
-
// https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L937
|
|
35
|
-
let writesToIgnore = 0;
|
|
36
|
-
const socket = {
|
|
37
|
-
_writableState: {},
|
|
38
|
-
writable: true,
|
|
39
|
-
on: core_1.NO_OP,
|
|
40
|
-
removeListener: core_1.NO_OP,
|
|
41
|
-
destroy: core_1.NO_OP,
|
|
42
|
-
cork: core_1.NO_OP,
|
|
43
|
-
uncork: core_1.NO_OP,
|
|
44
|
-
write: __assignType((data, encoding, cb) => {
|
|
45
|
-
// very unlikely, I don't even know how to reproduce this, but exist on types
|
|
46
|
-
// istanbul ignore if
|
|
47
|
-
if (typeof encoding === 'function') {
|
|
48
|
-
cb = encoding;
|
|
49
|
-
encoding = null;
|
|
50
|
-
}
|
|
51
|
-
log.debug('SERVERLESS_ADAPTER:RESPONSE_STREAM:DATA', () => ({
|
|
52
|
-
data: Buffer.isBuffer(data) ? data.toString('utf8') : data,
|
|
53
|
-
encoding,
|
|
54
|
-
}));
|
|
55
|
-
if (!isFirstCall && internalWritable) {
|
|
56
|
-
if (data === endChunked) {
|
|
57
|
-
internalWritable.end(cb);
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
if (writesToIgnore > 0) {
|
|
61
|
-
writesToIgnore--;
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
internalWritable.write(data, cb);
|
|
65
|
-
writesToIgnore = 3;
|
|
66
|
-
}
|
|
67
|
-
else if (isFirstCall) {
|
|
68
|
-
isFirstCall = false;
|
|
69
|
-
const stringData = (0, utils_1.getString)(data);
|
|
70
|
-
const endStatusIndex = stringData.indexOf(endStatusSeparator);
|
|
71
|
-
const status = +stringData.slice(0, endStatusIndex).split(' ')[1];
|
|
72
|
-
const headerData = stringData.slice(endStatusIndex + 2, stringData.indexOf(headerEnd));
|
|
73
|
-
const headers = (0, core_1.parseHeaders)(headerData);
|
|
74
|
-
log.debug('SERVERLESS_ADAPTER:RESPONSE_STREAM:FRAMEWORK_HEADERS', {
|
|
75
|
-
headers,
|
|
76
|
-
});
|
|
77
|
-
writesToIgnore = 1;
|
|
78
|
-
internalWritable = onReceiveHeaders(status, headers);
|
|
79
|
-
}
|
|
80
|
-
return true;
|
|
81
|
-
}, ['data', '', 'encoding', 'cb', 'PPW&J2!P&,P$/"J2#8P$/"2$8"/"']),
|
|
82
|
-
};
|
|
83
|
-
this.assignSocket(socket);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.ServerlessStreamResponse = ServerlessStreamResponse;
|
|
87
|
-
ServerlessStreamResponse.__type = [() => http_1.ServerResponse, () => __ΩServerlessStreamResponseProps, 'param0', 'constructor', 'P7!Pn"2#"0$5'];
|
|
88
|
-
//# sourceMappingURL=response-stream.js.map
|
|
1
|
+
"use strict";var l=Object.defineProperty,d=Object.getOwnPropertyDescriptor,R=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,h=(t,e)=>{for(var s in e)l(t,s,{get:e[s],enumerable:!0})},y=(t,e,s,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!g.call(t,r)&&r!==s&&l(t,r,{get:()=>e[r],enumerable:!(u=d(e,r))||u.enumerable});return t},b=t=>y(l({},"__esModule",{value:!0}),t),f={};h(f,{ServerlessStreamResponse:()=>m});module.exports=b(f);var w=require("http"),o=require("../core"),A=require("./utils");const D=`0\r
|
|
2
|
+
\r
|
|
3
|
+
`,N=`\r
|
|
4
|
+
\r
|
|
5
|
+
`,k=`\r
|
|
6
|
+
`;class m extends w.ServerResponse{constructor({method:e,onReceiveHeaders:s,log:u}){super({method:e}),this.useChunkedEncodingByDefault=!0,this.chunkedEncoding=!0;let r=null,p=!0,i=0;const E={_writableState:{},writable:!0,on:o.NO_OP,removeListener:o.NO_OP,destroy:o.NO_OP,cork:o.NO_OP,uncork:o.NO_OP,write:(n,a,c)=>{if(typeof a=="function"&&(c=a,a=null),u.debug("SERVERLESS_ADAPTER:RESPONSE_STREAM:DATA",()=>({data:Buffer.isBuffer(n)?n.toString("utf8"):n,encoding:a})),!p&&r){if(n===D)return r.end(c),!0;if(i>0)return i--,!0;r.write(n,c),i=3}else if(p){p=!1;const _=(0,A.getString)(n),S=_.indexOf(k),P=+_.slice(0,S).split(" ")[1],v=_.slice(S+2,_.indexOf(N)),O=(0,o.parseHeaders)(v);u.debug("SERVERLESS_ADAPTER:RESPONSE_STREAM:FRAMEWORK_HEADERS",{headers:O}),i=1,r=s(P,O)}return!0}};this.assignSocket(E)}}
|
|
7
|
+
//# sourceMappingURL=response-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-stream.js","
|
|
1
|
+
{"version":3,"file":"response-stream.js","sources":["../../src/network/response-stream.ts"],"sourcesContent":["import { ServerResponse } from 'http';\nimport { Socket } from 'net';\nimport { Writable } from 'stream';\nimport { BothValueHeaders } from '../@types';\nimport { ILogger, NO_OP, parseHeaders } from '../core';\nimport { getString } from './utils';\n\nconst endChunked = '0\\r\\n\\r\\n';\nconst headerEnd = '\\r\\n\\r\\n';\nconst endStatusSeparator = '\\r\\n';\n\n/**\n * The properties to create a {@link ServerlessStreamResponse}.\n *\n * @breadcrumb Network / ServerlessStreamResponse\n * @public\n */\nexport interface ServerlessStreamResponseProps {\n /**\n * The HTTP Method from request\n */\n method?: string;\n\n /**\n * The callback to receive the headers when they are written to the stream\n * You need to return a writable stream be able to continue writing the response\n *\n * @param statusCode - The status code of the response\n * @param headers - The headers of the response\n */\n onReceiveHeaders: (statusCode: number, headers: BothValueHeaders) => Writable;\n\n /**\n * Instance of the logger\n */\n log: ILogger;\n}\n\n/**\n * The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.\n * This response is specially built to deal with transfer-encoding: chunked\n *\n * @breadcrumb Network / ServerlessStreamResponse\n * @public\n */\nexport class ServerlessStreamResponse extends ServerResponse {\n constructor({\n method,\n onReceiveHeaders,\n log,\n }: ServerlessStreamResponseProps) {\n super({ method } as any);\n\n this.useChunkedEncodingByDefault = true;\n this.chunkedEncoding = true;\n\n let internalWritable: Writable | null = null;\n let isFirstCall = true;\n // this ignore is used because I need to ignore these write calls:\n // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L934-L935\n // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L937\n let writesToIgnore = 0;\n\n const socket: Partial<Socket> & { _writableState: any } = {\n _writableState: {},\n writable: true,\n on: NO_OP,\n removeListener: NO_OP,\n destroy: NO_OP,\n cork: NO_OP,\n uncork: NO_OP,\n write: (\n data: Uint8Array | string,\n encoding?: string | null | (() => void),\n cb?: () => void,\n ): any => {\n // very unlikely, I don't even know how to reproduce this, but exist on types\n // istanbul ignore if\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n log.debug('SERVERLESS_ADAPTER:RESPONSE_STREAM:DATA', () => ({\n data: Buffer.isBuffer(data) ? data.toString('utf8') : data,\n encoding,\n }));\n\n if (!isFirstCall && internalWritable) {\n if (data === endChunked) {\n internalWritable.end(cb);\n\n return true;\n }\n\n if (writesToIgnore > 0) {\n writesToIgnore--;\n return true;\n }\n\n internalWritable.write(data, cb);\n writesToIgnore = 3;\n } else if (isFirstCall) {\n isFirstCall = false;\n\n const stringData = getString(data);\n const endStatusIndex = stringData.indexOf(endStatusSeparator);\n const status = +stringData.slice(0, endStatusIndex).split(' ')[1];\n\n const headerData = stringData.slice(\n endStatusIndex + 2,\n stringData.indexOf(headerEnd),\n );\n const headers = parseHeaders(headerData);\n log.debug('SERVERLESS_ADAPTER:RESPONSE_STREAM:FRAMEWORK_HEADERS', {\n headers,\n });\n\n writesToIgnore = 1;\n internalWritable = onReceiveHeaders(status, headers);\n }\n\n return true;\n },\n };\n\n this.assignSocket(socket as unknown as Socket);\n }\n}\n"],"names":["response_stream_exports","__export","ServerlessStreamResponse","__toCommonJS","import_http","import_core","import_utils","endChunked","headerEnd","endStatusSeparator","method","onReceiveHeaders","log","internalWritable","isFirstCall","writesToIgnore","socket","data","encoding","cb","stringData","endStatusIndex","status","headerData","headers"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,yBAAA,IAAAE,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAH,CAAA,EAAA,IAA+BI,EAAA,QAAA,MAAA,EAIcC,EAAA,QAAA,SAAA,EACnBC,EAAA,QAAA,SAAA,EAE1B,MAAMC,EAAa;AAAA;AAAA,EACbC,EAAY;AAAA;AAAA,EACZC,EAAqB;AAAA,EAoCpB,MAAMP,UAAiCE,EAAe,cAAA,CAC3D,YAAY,CACV,OAAAM,EACA,iBAAAC,EACA,IAAAC,CAAA,EACgC,CAC1B,MAAA,CAAE,OAAAF,EAAe,EAEvB,KAAK,4BAA8B,GACnC,KAAK,gBAAkB,GAEvB,IAAIG,EAAoC,KACpCC,EAAc,GAIdC,EAAiB,EAErB,MAAMC,EAAoD,CACxD,eAAgB,CAAC,EACjB,SAAU,GACV,GAAIX,EAAA,MACJ,eAAgBA,EAAA,MAChB,QAASA,EAAA,MACT,KAAMA,EAAA,MACN,OAAQA,EAAA,MACR,MAAO,CACLY,EACAC,EACAC,IACQ,CAaJ,GAVA,OAAOD,GAAa,aACjBC,EAAAD,EACMA,EAAA,MAGTN,EAAA,MAAM,0CAA2C,KAAO,CAC1D,KAAM,OAAO,SAASK,CAAI,EAAIA,EAAK,SAAS,MAAM,EAAIA,EACtD,SAAAC,CACA,EAAA,EAEE,CAACJ,GAAeD,EAAkB,CACpC,GAAII,IAASV,EACX,OAAAM,EAAiB,IAAIM,CAAE,EAEhB,GAGT,GAAIJ,EAAiB,EACnB,OAAAA,IACO,GAGQF,EAAA,MAAMI,EAAME,CAAE,EACdJ,EAAA,UACRD,EAAa,CACRA,EAAA,GAER,MAAAM,KAAad,aAAUW,CAAI,EAC3BI,EAAiBD,EAAW,QAAQX,CAAkB,EACtDa,EAAS,CAACF,EAAW,MAAM,EAAGC,CAAc,EAAE,MAAM,GAAG,EAAE,CAAC,EAE1DE,EAAaH,EAAW,MAC5BC,EAAiB,EACjBD,EAAW,QAAQZ,CAAS,CAAA,EAExBgB,KAAUnB,gBAAakB,CAAU,EACvCX,EAAI,MAAM,uDAAwD,CAChE,QAAAY,CAAA,CACD,EAEgBT,EAAA,EACEF,EAAAF,EAAiBW,EAAQE,CAAO,EAG9C,MAAA,EACT,CAAA,EAGF,KAAK,aAAaR,CAA2B,CAC/C,CACF"}
|
package/lib/network/response.js
CHANGED
|
@@ -1,127 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
fn.__type = args;
|
|
6
|
-
return fn;
|
|
7
|
-
}
|
|
8
|
-
const __ΩRecord = ['K', 'T', 'l\'e#"Rb!b"Pde"!N#!'];
|
|
9
|
-
// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http
|
|
10
|
-
const http_1 = require("http");
|
|
11
|
-
const core_1 = require("../core");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
const headerEnd = '\r\n\r\n';
|
|
14
|
-
const BODY = Symbol('Response body');
|
|
15
|
-
const HEADERS = Symbol('Response headers');
|
|
16
|
-
function addData(stream, data) {
|
|
17
|
-
if (Buffer.isBuffer(data) ||
|
|
18
|
-
typeof data === 'string' ||
|
|
19
|
-
data instanceof Uint8Array)
|
|
20
|
-
stream[BODY].push(Buffer.from(data));
|
|
21
|
-
else
|
|
22
|
-
throw new Error(`response.write() of unexpected type: ${typeof data}`);
|
|
23
|
-
}
|
|
24
|
-
addData.__type = [() => ServerlessResponse, 'stream', 'data', 'addData', 'PP7!2"PW&J2#"/$'];
|
|
25
|
-
const __ΩServerlessResponseProps = ['method', 'P&4!8M'];
|
|
26
|
-
exports.__ΩServerlessResponseProps = __ΩServerlessResponseProps;
|
|
27
|
-
/**
|
|
28
|
-
* The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.
|
|
29
|
-
* Once it's happens, we use the properties from this response to built the response to the cloud.
|
|
30
|
-
*
|
|
31
|
-
* @breadcrumb Network / ServerlessResponse
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
class ServerlessResponse extends http_1.ServerResponse {
|
|
35
|
-
constructor({ method }) {
|
|
36
|
-
super({ method });
|
|
37
|
-
this[BODY] = [];
|
|
38
|
-
this[HEADERS] = {};
|
|
39
|
-
this.useChunkedEncodingByDefault = false;
|
|
40
|
-
this.chunkedEncoding = false;
|
|
41
|
-
this._header = '';
|
|
42
|
-
const socket = {
|
|
43
|
-
_writableState: {},
|
|
44
|
-
writable: true,
|
|
45
|
-
on: core_1.NO_OP,
|
|
46
|
-
removeListener: core_1.NO_OP,
|
|
47
|
-
destroy: core_1.NO_OP,
|
|
48
|
-
cork: core_1.NO_OP,
|
|
49
|
-
uncork: core_1.NO_OP,
|
|
50
|
-
write: __assignType((data, encoding, cb) => {
|
|
51
|
-
if (typeof encoding === 'function') {
|
|
52
|
-
cb = encoding;
|
|
53
|
-
encoding = null;
|
|
54
|
-
}
|
|
55
|
-
if (this._header === '' || this._wroteHeader)
|
|
56
|
-
addData(this, data);
|
|
57
|
-
else {
|
|
58
|
-
const string = (0, utils_1.getString)(data);
|
|
59
|
-
const index = string.indexOf(headerEnd);
|
|
60
|
-
if (index !== -1) {
|
|
61
|
-
const remainder = string.slice(index + headerEnd.length);
|
|
62
|
-
if (remainder)
|
|
63
|
-
addData(this, remainder);
|
|
64
|
-
this._wroteHeader = true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (typeof cb === 'function')
|
|
68
|
-
cb();
|
|
69
|
-
}, ['data', '', 'encoding', 'cb', 'PPW&J2!P&,P$/"J2#8P$/"2$8"/"']),
|
|
70
|
-
};
|
|
71
|
-
this.assignSocket(socket);
|
|
72
|
-
}
|
|
73
|
-
get headers() {
|
|
74
|
-
return this[HEADERS];
|
|
75
|
-
}
|
|
76
|
-
static from(res) {
|
|
77
|
-
const response = new ServerlessResponse({ method: res.method });
|
|
78
|
-
response.statusCode = res.statusCode || 0;
|
|
79
|
-
response[HEADERS] = res.headers;
|
|
80
|
-
response[BODY] = res.body ? [Buffer.from(res.body)] : [];
|
|
81
|
-
response.end();
|
|
82
|
-
return response;
|
|
83
|
-
}
|
|
84
|
-
static body(res) {
|
|
85
|
-
return Buffer.concat(res[BODY]);
|
|
86
|
-
}
|
|
87
|
-
static headers(res) {
|
|
88
|
-
const headers = res.getHeaders();
|
|
89
|
-
return Object.assign(headers, res[HEADERS]);
|
|
90
|
-
}
|
|
91
|
-
setHeader(key, value) {
|
|
92
|
-
if (this._wroteHeader)
|
|
93
|
-
this[HEADERS][key] = value;
|
|
94
|
-
else
|
|
95
|
-
super.setHeader(key, value);
|
|
96
|
-
}
|
|
97
|
-
writeHead(statusCode, statusMessage, obj) {
|
|
98
|
-
const headersObjOrArray = typeof statusMessage === 'string' ? obj : statusMessage;
|
|
99
|
-
const arrayHeaders = Array.isArray(headersObjOrArray)
|
|
100
|
-
? headersObjOrArray
|
|
101
|
-
: [headersObjOrArray || {}];
|
|
102
|
-
for (const headers of arrayHeaders) {
|
|
103
|
-
for (const name in headers) {
|
|
104
|
-
this.setHeader(name, headers[name]);
|
|
105
|
-
if (!this._wroteHeader) {
|
|
106
|
-
// we only need to initiate super.headers once
|
|
107
|
-
// writeHead will add the other headers itself
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return this.callNativeWriteHead(statusCode, statusMessage, obj);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* I use ignore here because in nodejs 12.x, statusMessage can be string | OutgoingHttpHeaders
|
|
116
|
-
* But in nodejs \>=14.x, statusMessage can also be OutgoingHttpHeaders[]
|
|
117
|
-
* I take care of these cases above, but here I can't handle it well, so I give up
|
|
118
|
-
* nodejs 12.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v12/http.d.ts#L229
|
|
119
|
-
* nodejs 14.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v14/http.d.ts#L263
|
|
120
|
-
*/
|
|
121
|
-
callNativeWriteHead(statusCode, statusMessage, obj) {
|
|
122
|
-
return super.writeHead(statusCode, statusMessage, obj);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.ServerlessResponse = ServerlessResponse;
|
|
126
|
-
ServerlessResponse.__type = [() => http_1.ServerResponse, () => __ΩServerlessResponseProps, 'param0', 'constructor', '_header', () => __ΩRecord, '_headers', '_wroteHeader', () => BODY, () => __ΩRecord, () => HEADERS, 'res', 'from', () => ServerlessResponse, 'body', 'key', 'value', 'setHeader', 'statusCode', 'statusMessage', 'obj', 'writeHead', 'callNativeWriteHead', 'P7!Pn"2#"0$&3%""o\'8)3(8"F3)""o*#3+!P!2,"0-sPP7.2,!0/sP&20P\'&&F9J21"02P\'23P&""FJ248P""FJ258"06P\'23P&""FJ248P""FJ258!07<5'];
|
|
127
|
-
//# sourceMappingURL=response.js.map
|
|
1
|
+
"use strict";var p=Object.defineProperty,y=Object.getOwnPropertyDescriptor,O=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,w=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},b=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of O(e))!v.call(r,s)&&s!==t&&p(r,s,{get:()=>e[s],enumerable:!(o=y(e,s))||o.enumerable});return r},g=r=>b(p({},"__esModule",{value:!0}),r),_={};w(_,{ServerlessResponse:()=>P});module.exports=g(_);var m=require("http"),a=require("../core"),H=require("./utils");const d=`\r
|
|
2
|
+
\r
|
|
3
|
+
`,f=Symbol("Response body"),c=Symbol("Response headers");function h(r,e){if(Buffer.isBuffer(e)||typeof e=="string"||e instanceof Uint8Array)r[f].push(Buffer.from(e));else throw new Error(`response.write() of unexpected type: ${typeof e}`)}const l=class extends m.ServerResponse{constructor({method:r}){super({method:r}),this[f]=[],this[c]={},this.useChunkedEncodingByDefault=!1,this.chunkedEncoding=!1,this._header="";const e={_writableState:{},writable:!0,on:a.NO_OP,removeListener:a.NO_OP,destroy:a.NO_OP,cork:a.NO_OP,uncork:a.NO_OP,write:(t,o,s)=>{if(typeof o=="function"&&(s=o,o=null),this._header===""||this._wroteHeader)h(this,t);else{const n=(0,H.getString)(t),i=n.indexOf(d);if(i!==-1){const u=n.slice(i+d.length);u&&h(this,u),this._wroteHeader=!0}}typeof s=="function"&&s()}};this.assignSocket(e)}get headers(){return this[c]}static from(r){const e=new l({method:r.method});return e.statusCode=r.statusCode||0,e[c]=r.headers,e[f]=r.body?[Buffer.from(r.body)]:[],e.end(),e}static body(r){return Buffer.concat(r[f])}static headers(r){const e=r.getHeaders();return Object.assign(e,r[c])}setHeader(r,e){this._wroteHeader?this[c][r]=e:super.setHeader(r,e)}writeHead(r,e,t){const o=typeof e=="string"?t:e,s=Array.isArray(o)?o:[o||{}];for(const n of s)for(const i in n)if(this.setHeader(i,n[i]),!this._wroteHeader)break;return this.callNativeWriteHead(r,e,t)}callNativeWriteHead(r,e,t){return super.writeHead(r,e,t)}};let P=l;
|
|
4
|
+
//# sourceMappingURL=response.js.map
|