@h4ad/serverless-adapter 2.11.0 → 2.13.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/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +56 -0
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +86 -0
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +1 -0
- package/lib/adapters/apollo-server/index.d.ts +1 -0
- package/lib/adapters/apollo-server/index.js +18 -0
- package/lib/adapters/apollo-server/index.js.map +1 -0
- package/lib/adapters/azure/http-trigger-v4.adapter.js +1 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +71 -0
- package/lib/frameworks/apollo-server/apollo-server.framework.js +87 -0
- package/lib/frameworks/apollo-server/apollo-server.framework.js.map +1 -0
- package/lib/frameworks/apollo-server/index.d.ts +1 -0
- package/lib/frameworks/apollo-server/index.js +18 -0
- package/lib/frameworks/apollo-server/index.js.map +1 -0
- 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/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/network/request.d.ts +1 -0
- package/lib/network/response.d.ts +1 -0
- package/package.json +33 -12
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
|
|
22
|
+
Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Deepkit, Express, Koa, Hapi,
|
|
23
|
+
Fastify, tRPC and Apollo Server), 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
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
|
|
2
|
+
import { ILogger } from '../../core';
|
|
3
|
+
/**
|
|
4
|
+
* The options for {@link ApolloServerMutationAdapter}
|
|
5
|
+
*
|
|
6
|
+
* @breadcrumb Adapters / Apollo Server / ApolloServerMutationAdapter
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare type ApolloServerMutationAdapterOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Specify the name of mutation that will be called when an event was received
|
|
12
|
+
*/
|
|
13
|
+
mutationName: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify the mutation result schema.
|
|
16
|
+
* Use this to customize the behavior when you need to return a specific object to be handled by the Adapter, like SQS with Batch Mode.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue `{ __typename }`
|
|
19
|
+
*/
|
|
20
|
+
mutationResultQuery?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The adapter that wraps another adapter to force a transformation of the event data as a mutation to Apollo Server be able to handle.
|
|
24
|
+
*
|
|
25
|
+
* @breadcrumb Adapters / Apollo Server / ApolloServerMutationAdapter
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare class ApolloServerMutationAdapter<TEvent, TContext, TResponse, TBaseAdapter extends AdapterContract<TEvent, TContext, TResponse>> implements AdapterContract<TEvent, TContext, TResponse> {
|
|
29
|
+
protected readonly baseAdapter: TBaseAdapter;
|
|
30
|
+
protected readonly options: ApolloServerMutationAdapterOptions;
|
|
31
|
+
/**
|
|
32
|
+
* The default constructor
|
|
33
|
+
*/
|
|
34
|
+
constructor(baseAdapter: TBaseAdapter, options: ApolloServerMutationAdapterOptions);
|
|
35
|
+
/**
|
|
36
|
+
* {@inheritDoc}
|
|
37
|
+
*/
|
|
38
|
+
canHandle(event: unknown, context: TContext, log: ILogger): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritDoc}
|
|
41
|
+
*/
|
|
42
|
+
getAdapterName(): string;
|
|
43
|
+
/**
|
|
44
|
+
* {@inheritDoc}
|
|
45
|
+
*/
|
|
46
|
+
getRequest(event: TEvent, context: TContext, log: ILogger): AdapterRequest;
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc}
|
|
49
|
+
*/
|
|
50
|
+
getResponse(props: GetResponseAdapterProps<TEvent>): TResponse;
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc}
|
|
53
|
+
*/
|
|
54
|
+
onErrorWhileForwarding(props: OnErrorProps<TEvent, TResponse>): void;
|
|
55
|
+
}
|
|
56
|
+
export declare type __ΩApolloServerMutationAdapterOptions = any[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApolloServerMutationAdapter = exports.__ΩApolloServerMutationAdapterOptions = void 0;
|
|
4
|
+
const { __ΩILogger } = require('../../core');
|
|
5
|
+
const { __ΩAdapterRequest } = require('../../contracts');
|
|
6
|
+
const { __ΩGetResponseAdapterProps } = require('../../contracts');
|
|
7
|
+
const { __ΩOnErrorProps } = require('../../contracts');
|
|
8
|
+
const core_1 = require("../../core");
|
|
9
|
+
const __ΩApolloServerMutationAdapterOptions = ['mutationName', 'mutationResultQuery', 'P&4!&4"8M'];
|
|
10
|
+
exports.__ΩApolloServerMutationAdapterOptions = __ΩApolloServerMutationAdapterOptions;
|
|
11
|
+
/**
|
|
12
|
+
* The adapter that wraps another adapter to force a transformation of the event data as a mutation to Apollo Server be able to handle.
|
|
13
|
+
*
|
|
14
|
+
* @breadcrumb Adapters / Apollo Server / ApolloServerMutationAdapter
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class ApolloServerMutationAdapter {
|
|
18
|
+
//#region Constructor
|
|
19
|
+
/**
|
|
20
|
+
* The default constructor
|
|
21
|
+
*/
|
|
22
|
+
constructor(baseAdapter, options) {
|
|
23
|
+
this.baseAdapter = baseAdapter;
|
|
24
|
+
this.options = options;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region Public Methods
|
|
28
|
+
/**
|
|
29
|
+
* {@inheritDoc}
|
|
30
|
+
*/
|
|
31
|
+
canHandle(event, context, log) {
|
|
32
|
+
return this.baseAdapter.canHandle(event, context, log);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* {@inheritDoc}
|
|
36
|
+
*/
|
|
37
|
+
getAdapterName() {
|
|
38
|
+
return this.baseAdapter.getAdapterName() + 'Mutation';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* {@inheritDoc}
|
|
42
|
+
*/
|
|
43
|
+
getRequest(event, context, log) {
|
|
44
|
+
var _a;
|
|
45
|
+
const request = this.baseAdapter.getRequest(event, context, log);
|
|
46
|
+
request.method = 'POST';
|
|
47
|
+
const operationName = this.options.mutationName;
|
|
48
|
+
const mutationResultQuery = (0, core_1.getDefaultIfUndefined)(this.options.mutationResultQuery, '{ __typename }');
|
|
49
|
+
const mutationBody = JSON.stringify({
|
|
50
|
+
operationName,
|
|
51
|
+
query: `mutation ${operationName} ($event: String) { ${operationName} (event: $event) ${mutationResultQuery} }`,
|
|
52
|
+
variables: {
|
|
53
|
+
event: ((_a = request.body) === null || _a === void 0 ? void 0 : _a.toString()) || '',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const [buffer, contentLength] = (0, core_1.getEventBodyAsBuffer)(mutationBody, false);
|
|
57
|
+
request.body = buffer;
|
|
58
|
+
request.headers['content-type'] = 'application/json';
|
|
59
|
+
request.headers['content-length'] = String(contentLength);
|
|
60
|
+
return request;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* {@inheritDoc}
|
|
64
|
+
*/
|
|
65
|
+
getResponse(props) {
|
|
66
|
+
const { data, errors } = JSON.parse(props.body);
|
|
67
|
+
if (!errors) {
|
|
68
|
+
return this.baseAdapter.getResponse({
|
|
69
|
+
...props,
|
|
70
|
+
body: JSON.stringify(data[this.options.mutationName]),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// when error happens, is the responsability of base adapter
|
|
74
|
+
// to deal with error status code.
|
|
75
|
+
return this.baseAdapter.getResponse(props);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* {@inheritDoc}
|
|
79
|
+
*/
|
|
80
|
+
onErrorWhileForwarding(props) {
|
|
81
|
+
return this.baseAdapter.onErrorWhileForwarding(props);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.ApolloServerMutationAdapter = ApolloServerMutationAdapter;
|
|
85
|
+
ApolloServerMutationAdapter.__type = ['TEvent', 'TContext', 'TResponse', 'TBaseAdapter', 'baseAdapter', () => __ΩApolloServerMutationAdapterOptions, 'options', 'constructor', 'event', 'context', () => __ΩILogger, 'log', 'canHandle', 'getAdapterName', () => __ΩILogger, () => __ΩAdapterRequest, 'getRequest', () => __ΩGetResponseAdapterProps, 'props', 'getResponse', () => __ΩOnErrorProps, 'onErrorWhileForwarding', 'b!b"b#b$Pe"$2%<9n&2\'<9"0(P#2)e""2*n+2,)0-P&0.Pe"!2)e""2*n/2,n001Pe"!o2"23e"#04Pe"!e"#o5#23$065e!!e!"e!#6$'];
|
|
86
|
+
//# sourceMappingURL=apollo-server-mutation.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-server-mutation.adapter.js","sourceRoot":"","sources":["../../../src/adapters/apollo-server/apollo-server-mutation.adapter.ts"],"names":[],"mappings":";;;+BAYO,YAAY;sCALZ,iBAAiB;+CAAjB,iBAAiB;oCAAjB,iBAAiB;AACxB,qCAIoB;;;AAyBpB;;;;;GAKG;AACH,MAAa,2BAA2B;IAOtC,qBAAqB;IAErB;;OAEG;IACH,YACqB,WAAyB,EACzB,OAA2C;QAD3C,gBAAW,GAAX,WAAW,CAAc;QACzB,YAAO,GAAP,OAAO,CAAoC;IAC7D,CAAC;IAEJ,YAAY;IAEZ,wBAAwB;IAExB;;OAEG;IACI,SAAS,CAAC,KAAc,EAAE,OAAiB,EAAE,GAAY;QAC9D,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,GAAG,UAAU,CAAC;IACxD,CAAC;IAED;;OAEG;IACI,UAAU,CACf,KAAa,EACb,OAAiB,EACjB,GAAY;;QAEZ,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAEjE,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;QAExB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAChD,MAAM,mBAAmB,GAAG,IAAA,4BAAqB,EAC/C,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAChC,gBAAgB,CACjB,CAAC;QAEF,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC;YAClC,aAAa;YACb,KAAK,EAAE,YAAY,a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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("./apollo-server-mutation.adapter"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/apollo-server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-trigger-v4.adapter.js","sourceRoot":"","sources":["../../../src/adapters/azure/http-trigger-v4.adapter.ts"],"names":[],"mappings":";;;sCAeO,iBAAiB;+CAAjB,iBAAiB;oCAAjB,iBAAiB;wCANS,cAAc;;;;;AAT/C,iBAAiB;AAEjB,6BAA0B;AAc1B,qCAKoB;;;AAmBpB;;;;;;;;;;;;;GAaG;AACH,MAAa,oBAAoB;IAG/B,qBAAqB;IAErB;;;;OAIG;IACH,YAA+B,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;IAAG,CAAC;IAExE,YAAY;IAEZ,wBAAwB;IAExB;;OAEG;IACI,cAAc;QACnB,OAAO,oBAAoB,CAAC,IAAI,CAAC;IACnC,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,KAAc,EAAE,OAAgB;QAC/C,MAAM,UAAU,GAAG,KAAyC,CAAC;QAC7D,MAAM,YAAY,GAAG,OAAuC,CAAC;QAE7D,OAAO,CAAC,CAAC,CACP,UAAU;YACV,UAAU,CAAC,MAAM;YACjB,UAAU,CAAC,OAAO;YAClB,UAAU,CAAC,GAAG;YACd,UAAU,CAAC,KAAK;YAChB,YAAY;YACZ,YAAY,CAAC,YAAY;YACzB,YAAY,CAAC,kBAAkB;YAC/B,YAAY,CAAC,GAAG;YAChB,YAAY,CAAC,GAAG,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"http-trigger-v4.adapter.js","sourceRoot":"","sources":["../../../src/adapters/azure/http-trigger-v4.adapter.ts"],"names":[],"mappings":";;;sCAeO,iBAAiB;+CAAjB,iBAAiB;oCAAjB,iBAAiB;wCANS,cAAc;;;;;AAT/C,iBAAiB;AAEjB,6BAA0B;AAc1B,qCAKoB;;;AAmBpB;;;;;;;;;;;;;GAaG;AACH,MAAa,oBAAoB;IAG/B,qBAAqB;IAErB;;;;OAIG;IACH,YAA+B,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;IAAG,CAAC;IAExE,YAAY;IAEZ,wBAAwB;IAExB;;OAEG;IACI,cAAc;QACnB,OAAO,oBAAoB,CAAC,IAAI,CAAC;IACnC,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,KAAc,EAAE,OAAgB;QAC/C,MAAM,UAAU,GAAG,KAAyC,CAAC;QAC7D,MAAM,YAAY,GAAG,OAAuC,CAAC;QAE7D,OAAO,CAAC,CAAC,CACP,UAAU;YACV,UAAU,CAAC,MAAM;YACjB,UAAU,CAAC,OAAO;YAClB,UAAU,CAAC,GAAG;YACd,UAAU,CAAC,KAAK;YAChB,YAAY;YACZ,YAAY,CAAC,YAAY;YACzB,YAAY,CAAC,kBAAkB;YAC/B,YAAY,CAAC,GAAG;YAChB,CAAC,CAAC,YAAY,CAAC,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UAAU;oBACb,iBAAiB,CAAC,QAAQ,GAAG,cAAoC,CAAC;oBAClE,MAAM;gBACR,KAAK,SAAS;oBACZ,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;oBAClD,MAAM;aACT;YAED,OAAO,iBAAiB,CAAC;QAC3B,CAAC,0EACD,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAY,CAClC,CAAC;IACJ,CAAC;;AA7NH,oDAgOC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { ApolloServer, BaseContext } from '@apollo/server';
|
|
4
|
+
import { FrameworkContract } from '../../contracts';
|
|
5
|
+
import { ServerlessRequest } from '../../network';
|
|
6
|
+
/**
|
|
7
|
+
* The default context of Apollo Server when you integrate and don't pass any context.
|
|
8
|
+
*
|
|
9
|
+
* @breadcrumb Frameworks / ApolloServerFramework
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface DefaultServerlessApolloServerContext extends BaseContext {
|
|
13
|
+
/**
|
|
14
|
+
* The request reference
|
|
15
|
+
*/
|
|
16
|
+
request: IncomingMessage;
|
|
17
|
+
/**
|
|
18
|
+
* The response reference
|
|
19
|
+
*/
|
|
20
|
+
response: ServerResponse;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The arguments used to create a Context inside {@link ApolloServerOptions}
|
|
24
|
+
*
|
|
25
|
+
* @breadcrumb Frameworks / ApolloServerFramework
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare type ApolloServerContextArguments = {
|
|
29
|
+
/**
|
|
30
|
+
* The request reference
|
|
31
|
+
*/
|
|
32
|
+
request: IncomingMessage;
|
|
33
|
+
/**
|
|
34
|
+
* The response reference
|
|
35
|
+
*/
|
|
36
|
+
response: ServerResponse;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The options to customize {@link ApolloServerFramework}
|
|
40
|
+
*
|
|
41
|
+
* @breadcrumb Frameworks / ApolloServerFramework
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export interface ApolloServerOptions<TContext extends BaseContext> {
|
|
45
|
+
/**
|
|
46
|
+
* Define a function to create the context of Apollo Server
|
|
47
|
+
*
|
|
48
|
+
* @param options - Default options passed by library
|
|
49
|
+
*/
|
|
50
|
+
context?: (options: ApolloServerContextArguments) => Promise<TContext>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The framework that forwards requests to Apollo Server
|
|
54
|
+
*
|
|
55
|
+
* @breadcrumb Frameworks / ApolloServerFramework
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare class ApolloServerFramework<TContext extends BaseContext> implements FrameworkContract<ApolloServer<TContext>> {
|
|
59
|
+
protected readonly options?: ApolloServerOptions<TContext> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Construtor padrão
|
|
62
|
+
*/
|
|
63
|
+
constructor(options?: ApolloServerOptions<TContext> | undefined);
|
|
64
|
+
/**
|
|
65
|
+
* {@inheritDoc}
|
|
66
|
+
*/
|
|
67
|
+
sendRequest(app: ApolloServer<TContext>, request: ServerlessRequest, response: ServerResponse): void;
|
|
68
|
+
}
|
|
69
|
+
export declare type __ΩDefaultServerlessApolloServerContext = any[];
|
|
70
|
+
export declare type __ΩApolloServerContextArguments = any[];
|
|
71
|
+
export declare type __ΩApolloServerOptions = any[];
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApolloServerFramework = exports.__ΩApolloServerOptions = exports.__ΩApolloServerContextArguments = exports.__ΩDefaultServerlessApolloServerContext = void 0;
|
|
4
|
+
function __assignType(fn, args) {
|
|
5
|
+
fn.__type = args;
|
|
6
|
+
return fn;
|
|
7
|
+
}
|
|
8
|
+
const server_1 = require("@apollo/server");
|
|
9
|
+
const network_1 = require("../../network");
|
|
10
|
+
const core_1 = require("../../core");
|
|
11
|
+
const __ΩDefaultServerlessApolloServerContext = ['request', 'response', 'P"!4!!4"M'];
|
|
12
|
+
exports.__ΩDefaultServerlessApolloServerContext = __ΩDefaultServerlessApolloServerContext;
|
|
13
|
+
const __ΩApolloServerContextArguments = ['request', 'response', 'P!4!!4"M'];
|
|
14
|
+
exports.__ΩApolloServerContextArguments = __ΩApolloServerContextArguments;
|
|
15
|
+
const __ΩApolloServerOptions = ['TContext', () => __ΩApolloServerContextArguments, 'options', '', 'context', 'b!PPn"2#e#!`/$4%8M'];
|
|
16
|
+
exports.__ΩApolloServerOptions = __ΩApolloServerOptions;
|
|
17
|
+
/**
|
|
18
|
+
* The framework that forwards requests to Apollo Server
|
|
19
|
+
*
|
|
20
|
+
* @breadcrumb Frameworks / ApolloServerFramework
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
class ApolloServerFramework {
|
|
24
|
+
//#region Constructor
|
|
25
|
+
/**
|
|
26
|
+
* Construtor padrão
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.options = options;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
/**
|
|
33
|
+
* {@inheritDoc}
|
|
34
|
+
*/
|
|
35
|
+
sendRequest(app, request, response) {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
const headers = new server_1.HeaderMap();
|
|
38
|
+
for (const [key, value] of Object.entries(request.headers)) {
|
|
39
|
+
if (value === undefined)
|
|
40
|
+
continue;
|
|
41
|
+
headers.set(key, Array.isArray(value) ? value.join(', ') : value.toString());
|
|
42
|
+
}
|
|
43
|
+
const defaultContext = __assignType(context => Promise.resolve(context), ['context', '', 'P"2!"/"']);
|
|
44
|
+
const context = () => {
|
|
45
|
+
var _a;
|
|
46
|
+
return (0, core_1.getDefaultIfUndefined)((_a = this.options) === null || _a === void 0 ? void 0 : _a.context, defaultContext)({ request, response });
|
|
47
|
+
};
|
|
48
|
+
const search = ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith('http'))
|
|
49
|
+
? (_b = new URL(request.url).search) !== null && _b !== void 0 ? _b : ''
|
|
50
|
+
: ((_c = request.url) === null || _c === void 0 ? void 0 : _c.split('?')[1]) || '';
|
|
51
|
+
// we don't need to handle catch because of https://www.apollographql.com/docs/apollo-server/integrations/building-integrations/#handle-errors
|
|
52
|
+
app
|
|
53
|
+
.executeHTTPGraphQLRequest({
|
|
54
|
+
httpGraphQLRequest: {
|
|
55
|
+
method: request.method.toUpperCase(),
|
|
56
|
+
headers,
|
|
57
|
+
body: request.body,
|
|
58
|
+
search,
|
|
59
|
+
},
|
|
60
|
+
context,
|
|
61
|
+
})
|
|
62
|
+
.then(__assignType(async (httpGraphQLResponse) => {
|
|
63
|
+
// this section was copy and pasted from https://github.com/apollographql/apollo-server/blob/main/packages/server/src/express4/index.ts#L95
|
|
64
|
+
for (const [key, value] of httpGraphQLResponse.headers)
|
|
65
|
+
response.setHeader(key, value);
|
|
66
|
+
response.statusCode = httpGraphQLResponse.status || 200;
|
|
67
|
+
if (httpGraphQLResponse.body.kind === 'complete') {
|
|
68
|
+
response.end(httpGraphQLResponse.body.string);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
for await (const chunk of httpGraphQLResponse.body.asyncIterator) {
|
|
72
|
+
response.write(chunk);
|
|
73
|
+
// Express/Node doesn't define a way of saying "it's time to send this
|
|
74
|
+
// data over the wire"... but the popular `compression` middleware
|
|
75
|
+
// (which implements `accept-encoding: gzip` and friends) does, by
|
|
76
|
+
// monkey-patching a `flush` method onto the response. So we call it
|
|
77
|
+
// if it's there.
|
|
78
|
+
if (typeof response.flush === 'function')
|
|
79
|
+
response.flush();
|
|
80
|
+
}
|
|
81
|
+
response.end();
|
|
82
|
+
}, ['httpGraphQLResponse', '', 'P"2!"/"']));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.ApolloServerFramework = ApolloServerFramework;
|
|
86
|
+
ApolloServerFramework.__type = ['TContext', () => __ΩApolloServerOptions, 'options', 'constructor', () => server_1.ApolloServer, 'app', () => network_1.ServerlessRequest, 'request', 'response', 'sendRequest', () => server_1.ApolloServer, 'b!Pe"!o""2#8<9"0$PPe#!7%2&P7\'2(!2)$0*5Pe"!7+6"'];
|
|
87
|
+
//# sourceMappingURL=apollo-server.framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-server.framework.js","sourceRoot":"","sources":["../../../src/frameworks/apollo-server/apollo-server.framework.ts"],"names":[],"mappings":";;;;;;;AAGA,2CAAsE;AAEtE,2CAAkD;AAClD,qCAAmD;;;;;;;AAqDnD;;;;;GAKG;AACH,MAAa,qBAAqB;IAGhC,qBAAqB;IAErB;;OAEG;IACH,YAA+B,OAAuC;QAAvC,YAAO,GAAP,OAAO,CAAgC;IAAG,CAAC;IAE1E,YAAY;IAEZ;;OAEG;IACI,WAAW,CAChB,GAA2B,EAC3B,OAA0B,EAC1B,QAAwB;;QAExB,MAAM,OAAO,GAAG,IAAI,kBAAS,EAAE,CAAC;QAEhC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1D,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAElC,OAAO,CAAC,GAAG,CACT,GAAG,EACH,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAC3D,CAAC;SACH;QAED,MAAM,cAAc,gBAAwC,OAAO,CAAC,EAAE,CACpE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,6BAAA,CAAC;QAE3B,MAAM,OAAO,GAAG,GAAG,EAAE;;YACnB,OAAA,IAAA,4BAAqB,EACnB,MAAA,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E;gBACpE,iBAAiB;gBACjB,IAAI,OAAQ,QAAgB,CAAC,KAAK,KAAK,UAAU;oBAC9C,QAAgB,CAAC,KAAK,EAAE,CAAC;aAC7B;YAED,QAAQ,CAAC,GAAG,EAAE,CAAC;QACjB,CAAC,0CAAC,CAAC;IACP,CAAC;;AAjFH,sDAkFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './apollo-server.framework';
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./apollo-server.framework"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/apollo-server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Options } 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/octet-stream
|
|
6
|
+
*
|
|
7
|
+
* @remarks {@link https://github.com/expressjs/body-parser#bodyparserrawoptions}
|
|
8
|
+
*
|
|
9
|
+
* @breadcrumb Frameworks / BodyParserFramework / RawBodyParserFramework
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare type RawBodyParserFrameworkOptions = Options & BodyParserOptions;
|
|
13
|
+
/**
|
|
14
|
+
* The body-parser class used to parse application/octet-stream.
|
|
15
|
+
*
|
|
16
|
+
* @breadcrumb Frameworks / BodyParserFramework / RawBodyParserFramework
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class RawBodyParserFramework<TApp> extends BaseBodyParserFramework<TApp> implements FrameworkContract<TApp> {
|
|
20
|
+
protected readonly framework: FrameworkContract<TApp>;
|
|
21
|
+
/**
|
|
22
|
+
* Default Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(framework: FrameworkContract<TApp>, options?: RawBodyParserFrameworkOptions);
|
|
25
|
+
}
|
|
26
|
+
export declare type __ΩRawBodyParserFrameworkOptions = any[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawBodyParserFramework = exports.__ΩRawBodyParserFrameworkOptions = 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 __ΩRawBodyParserFrameworkOptions = [() => __ΩBodyParserOptions, 'P!n!K'];
|
|
10
|
+
exports.__ΩRawBodyParserFrameworkOptions = __ΩRawBodyParserFrameworkOptions;
|
|
11
|
+
/**
|
|
12
|
+
* The body-parser class used to parse application/octet-stream.
|
|
13
|
+
*
|
|
14
|
+
* @breadcrumb Frameworks / BodyParserFramework / RawBodyParserFramework
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class RawBodyParserFramework 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.raw)(options), options);
|
|
24
|
+
this.framework = framework;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.RawBodyParserFramework = RawBodyParserFramework;
|
|
28
|
+
RawBodyParserFramework.__type = ['TApp', () => base_body_parser_framework_1.BaseBodyParserFramework, () => __ΩFrameworkContract, 'framework', () => __ΩRawBodyParserFrameworkOptions, 'options', 'constructor', 'b!Pe"!7"Pe"!o#"2$<9n%2&8"0\'5e!!6"'];
|
|
29
|
+
//# sourceMappingURL=raw-body-parser.framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-body-parser.framework.js","sourceRoot":"","sources":["../../../src/frameworks/body-parser/raw-body-parser.framework.ts"],"names":[],"mappings":";;;yCAGkC,iBAAiB;yCAI5C,8BAA8B;AAPrC,iBAAiB;AAEjB,6CAA2C;AAE3C,6EAGsC;;;AActC;;;;;GAKG;AACH,MAAa,sBACX,SAAQ,oDAA6B;IAGrC,qBAAqB;IAErB;;OAEG;IACH,YACqB,SAAkC,EACrD,OAAuC;QAEvC,KAAK,CAAC,SAAS,EAAE,IAAA,iBAAG,EAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QAHrB,cAAS,GAAT,SAAS,CAAyB;IAIvD,CAAC;;AAdH,wDAiBC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OptionsText } from 'body-parser';
|
|
2
|
+
import { FrameworkContract } from '../../contracts';
|
|
3
|
+
import { BaseBodyParserFramework, BodyParserOptions } from './base-body-parser.framework';
|
|
4
|
+
/**
|
|
5
|
+
* The body-parser options for text/plain
|
|
6
|
+
*
|
|
7
|
+
* @remarks {@link https://github.com/expressjs/body-parser#bodyparsertextoptions}
|
|
8
|
+
*
|
|
9
|
+
* @breadcrumb Frameworks / BodyParserFramework / TextBodyParserFramework
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare type TextBodyParserFrameworkOptions = OptionsText & BodyParserOptions;
|
|
13
|
+
/**
|
|
14
|
+
* The body-parser class used to parse text/plain.
|
|
15
|
+
*
|
|
16
|
+
* @breadcrumb Frameworks / BodyParserFramework / TextBodyParserFramework
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class TextBodyParserFramework<TApp> extends BaseBodyParserFramework<TApp> implements FrameworkContract<TApp> {
|
|
20
|
+
protected readonly framework: FrameworkContract<TApp>;
|
|
21
|
+
/**
|
|
22
|
+
* Default Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(framework: FrameworkContract<TApp>, options?: TextBodyParserFrameworkOptions);
|
|
25
|
+
}
|
|
26
|
+
export declare type __ΩTextBodyParserFrameworkOptions = any[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextBodyParserFramework = exports.__ΩTextBodyParserFrameworkOptions = 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 __ΩTextBodyParserFrameworkOptions = [() => __ΩBodyParserOptions, 'P!n!K'];
|
|
10
|
+
exports.__ΩTextBodyParserFrameworkOptions = __ΩTextBodyParserFrameworkOptions;
|
|
11
|
+
/**
|
|
12
|
+
* The body-parser class used to parse text/plain.
|
|
13
|
+
*
|
|
14
|
+
* @breadcrumb Frameworks / BodyParserFramework / TextBodyParserFramework
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class TextBodyParserFramework 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.text)(options), options);
|
|
24
|
+
this.framework = framework;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.TextBodyParserFramework = TextBodyParserFramework;
|
|
28
|
+
TextBodyParserFramework.__type = ['TApp', () => base_body_parser_framework_1.BaseBodyParserFramework, () => __ΩFrameworkContract, 'framework', () => __ΩTextBodyParserFrameworkOptions, 'options', 'constructor', 'b!Pe"!7"Pe"!o#"2$<9n%2&8"0\'5e!!6"'];
|
|
29
|
+
//# sourceMappingURL=text-body-parser.framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-body-parser.framework.js","sourceRoot":"","sources":["../../../src/frameworks/body-parser/text-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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OptionsUrlencoded } 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/x-www-form-urlencoded
|
|
6
|
+
*
|
|
7
|
+
* @remarks {@link https://github.com/expressjs/body-parser#bodyparserurlencodedoptions}
|
|
8
|
+
*
|
|
9
|
+
* @breadcrumb Frameworks / BodyParserFramework / UrlencodedBodyParserFramework
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare type UrlencodedBodyParserFrameworkOptions = OptionsUrlencoded & BodyParserOptions;
|
|
13
|
+
/**
|
|
14
|
+
* The body-parser class used to parse application/x-www-form-urlencoded.
|
|
15
|
+
*
|
|
16
|
+
* @breadcrumb Frameworks / BodyParserFramework / UrlencodedBodyParserFramework
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class UrlencodedBodyParserFramework<TApp> extends BaseBodyParserFramework<TApp> implements FrameworkContract<TApp> {
|
|
20
|
+
protected readonly framework: FrameworkContract<TApp>;
|
|
21
|
+
/**
|
|
22
|
+
* Default Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(framework: FrameworkContract<TApp>, options?: UrlencodedBodyParserFrameworkOptions);
|
|
25
|
+
}
|
|
26
|
+
export declare type __ΩUrlencodedBodyParserFrameworkOptions = any[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UrlencodedBodyParserFramework = exports.__ΩUrlencodedBodyParserFrameworkOptions = 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 __ΩUrlencodedBodyParserFrameworkOptions = [() => __ΩBodyParserOptions, 'P!n!K'];
|
|
10
|
+
exports.__ΩUrlencodedBodyParserFrameworkOptions = __ΩUrlencodedBodyParserFrameworkOptions;
|
|
11
|
+
/**
|
|
12
|
+
* The body-parser class used to parse application/x-www-form-urlencoded.
|
|
13
|
+
*
|
|
14
|
+
* @breadcrumb Frameworks / BodyParserFramework / UrlencodedBodyParserFramework
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class UrlencodedBodyParserFramework 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.urlencoded)(options), options);
|
|
24
|
+
this.framework = framework;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.UrlencodedBodyParserFramework = UrlencodedBodyParserFramework;
|
|
28
|
+
UrlencodedBodyParserFramework.__type = ['TApp', () => base_body_parser_framework_1.BaseBodyParserFramework, () => __ΩFrameworkContract, 'framework', () => __ΩUrlencodedBodyParserFrameworkOptions, 'options', 'constructor', 'b!Pe"!7"Pe"!o#"2$<9n%2&8"0\'5e!!6"'];
|
|
29
|
+
//# sourceMappingURL=urlencoded-body-parser.framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlencoded-body-parser.framework.js","sourceRoot":"","sources":["../../../src/frameworks/body-parser/urlencoded-body-parser.framework.ts"],"names":[],"mappings":";;;yCAGkC,iBAAiB;yCAI5C,8BAA8B;AAPrC,iBAAiB;AAEjB,6CAA4D;AAE5D,6EAGsC;;;AAetC;;;;;GAKG;AACH,MAAa,6BACX,SAAQ,oDAA6B;IAGrC,qBAAqB;IAErB;;OAEG;IACH,YACqB,SAAkC,EACrD,OAA8C;QAE9C,KAAK,CAAC,SAAS,EAAE,IAAA,wBAAU,EAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QAH5B,cAAS,GAAT,SAAS,CAAyB;IAIvD,CAAC;;AAdH,sEAiBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
/**
|
|
3
|
+
* Just return the current body as it was parsed.
|
|
4
|
+
*
|
|
5
|
+
* @remarks This function is intended to be used with BodyParserFrameworks.
|
|
6
|
+
*
|
|
7
|
+
* @param app - The instance of fastify
|
|
8
|
+
* @param contentType - The content type to be anuled
|
|
9
|
+
*
|
|
10
|
+
* @breadcrumb Frameworks / FastifyFramework / Helpers
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function setNoOpForContentType(app: FastifyInstance, contentType: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setNoOpForContentType = void 0;
|
|
4
|
+
function __assignType(fn, args) {
|
|
5
|
+
fn.__type = args;
|
|
6
|
+
return fn;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
/**
|
|
10
|
+
* Just return the current body as it was parsed.
|
|
11
|
+
*
|
|
12
|
+
* @remarks This function is intended to be used with BodyParserFrameworks.
|
|
13
|
+
*
|
|
14
|
+
* @param app - The instance of fastify
|
|
15
|
+
* @param contentType - The content type to be anuled
|
|
16
|
+
*
|
|
17
|
+
* @breadcrumb Frameworks / FastifyFramework / Helpers
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
function setNoOpForContentType(app, contentType) {
|
|
21
|
+
app.addContentTypeParser(contentType, __assignType((_, req, done) => {
|
|
22
|
+
return done(null, req.body);
|
|
23
|
+
}, ['_', 'req', 'done', '', 'P"2!"2""2#"/$']));
|
|
24
|
+
}
|
|
25
|
+
exports.setNoOpForContentType = setNoOpForContentType;
|
|
26
|
+
setNoOpForContentType.__type = ['app', 'contentType', 'setNoOpForContentType', 'P"2!&2"$/#'];
|
|
27
|
+
//# sourceMappingURL=no-op-content-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-op-content-parser.js","sourceRoot":"","sources":["../../../../src/frameworks/fastify/helpers/no-op-content-parser.ts"],"names":[],"mappings":";;;;;;;AAIA,YAAY;AAEZ;;;;;;;;;;GAUG;AACH,SAAgB,qBAAqB,CACnC,GAAoB,EACpB,WAAmB;IAEnB,GAAG,CAAC,oBAAoB,CAAC,WAAW,eAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACrD,OAAO,IAAI,CAAC,IAAI,EAAG,GAAW,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,6CAAC,CAAC;AACL,CAAC;AAPD,sDAOC"}
|
package/lib/network/request.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h4ad/serverless-adapter",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Azure,
|
|
3
|
+
"version": "2.13.0",
|
|
4
|
+
"description": "Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Azure, Digital Ocean and many other clouds.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"lib/**/*"
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"lambda edge",
|
|
46
46
|
"alb",
|
|
47
47
|
"lambda",
|
|
48
|
+
"apollo server",
|
|
48
49
|
"express",
|
|
49
50
|
"koa",
|
|
50
51
|
"hapi",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
},
|
|
72
73
|
"homepage": "https://github.com/H4ad/serverless-adapter#readme",
|
|
73
74
|
"devDependencies": {
|
|
75
|
+
"@apollo/server": "*",
|
|
74
76
|
"@azure/functions": "^3.2.0",
|
|
75
77
|
"@deepkit/app": ">= 1.0.1-alpha.74",
|
|
76
78
|
"@deepkit/core": ">= 1.0.1-alpha.74",
|
|
@@ -79,11 +81,11 @@
|
|
|
79
81
|
"@deepkit/type": ">= 1.0.1-alpha.74",
|
|
80
82
|
"@deepkit/type-compiler": ">= 1.0.1-alpha.74",
|
|
81
83
|
"@hapi/hapi": "^20.2.2",
|
|
82
|
-
"@microsoft/api-documenter": "7.
|
|
83
|
-
"@microsoft/api-extractor": "7.
|
|
84
|
-
"@microsoft/api-extractor-model": "7.
|
|
85
|
-
"@microsoft/tsdoc": "0.14.
|
|
86
|
-
"@rushstack/node-core-library": "
|
|
84
|
+
"@microsoft/api-documenter": "7.19.24",
|
|
85
|
+
"@microsoft/api-extractor": "7.33.6",
|
|
86
|
+
"@microsoft/api-extractor-model": "7.25.2",
|
|
87
|
+
"@microsoft/tsdoc": "0.14.2",
|
|
88
|
+
"@rushstack/node-core-library": "3.53.2",
|
|
87
89
|
"@trpc/server": "^9.26.2",
|
|
88
90
|
"@types/aws-lambda": "^8.10.92",
|
|
89
91
|
"@types/body-parser": "^1.19.2",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
"@types/supertest": "^2.0.12",
|
|
97
99
|
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
|
98
100
|
"@typescript-eslint/parser": "^5.12.1",
|
|
99
|
-
"body-parser": "^1.
|
|
101
|
+
"body-parser": "^1.20.1",
|
|
100
102
|
"codecov": "^3.8.1",
|
|
101
103
|
"commitizen": "^4.2.4",
|
|
102
104
|
"cors": "^2.8.5",
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
"eslint-plugin-prettier": "^4.0.0",
|
|
110
112
|
"eslint-plugin-tsdoc": "^0.2.14",
|
|
111
113
|
"express": "^4.18.1",
|
|
112
|
-
"fastify": "^4.
|
|
114
|
+
"fastify": "^4.10.2",
|
|
113
115
|
"fastify-3": "npm:fastify@3.29.0",
|
|
114
116
|
"firebase-admin": "^11.0.1",
|
|
115
117
|
"firebase-admin-8": "npm:firebase-admin@^8.0.0",
|
|
@@ -123,20 +125,23 @@
|
|
|
123
125
|
"stream-mock": "^2.0.5",
|
|
124
126
|
"supertest": "^6.2.3",
|
|
125
127
|
"ts-jest": "^28.0.7",
|
|
126
|
-
"ts-node": "^10.
|
|
127
|
-
"typedoc": "^0.
|
|
128
|
-
"typescript": "
|
|
128
|
+
"ts-node": "^10.9.1",
|
|
129
|
+
"typedoc": "^0.23.21",
|
|
130
|
+
"typescript": "~4.7.4"
|
|
129
131
|
},
|
|
130
132
|
"peerDependencies": {
|
|
133
|
+
"@apollo/server": ">= 4.0.0",
|
|
131
134
|
"@azure/functions": ">= 2.0.0",
|
|
132
135
|
"@deepkit/http": ">= 1.0.1-alpha.74",
|
|
133
136
|
"@hapi/hapi": ">= 20.0.0",
|
|
134
137
|
"@trpc/server": ">= 9.0.0",
|
|
135
138
|
"@types/aws-lambda": ">= 8.10.92",
|
|
139
|
+
"@types/body-parser": ">= 1.19.2",
|
|
136
140
|
"@types/cors": ">= 2.8.12",
|
|
137
141
|
"@types/express": ">= 4.15.4",
|
|
138
142
|
"@types/hapi": ">= 18.0.7",
|
|
139
143
|
"@types/koa": ">= 2.11.2",
|
|
144
|
+
"body-parser": ">= 1.20.0",
|
|
140
145
|
"cors": ">= 2.8.5",
|
|
141
146
|
"express": ">= 4.15.4",
|
|
142
147
|
"fastify": ">= 3.0.0",
|
|
@@ -144,10 +149,14 @@
|
|
|
144
149
|
"firebase-admin": ">= 8.0.0",
|
|
145
150
|
"firebase-admin-8": "npm:firebase-admin@^8.0.0",
|
|
146
151
|
"firebase-functions": ">= 3.0.0",
|
|
152
|
+
"http-errors": ">= 2.0.0",
|
|
147
153
|
"koa": ">= 2.5.1",
|
|
148
154
|
"reflect-metadata": "^0.1.13"
|
|
149
155
|
},
|
|
150
156
|
"peerDependenciesMeta": {
|
|
157
|
+
"@apollo/server": {
|
|
158
|
+
"optional": true
|
|
159
|
+
},
|
|
151
160
|
"@azure/functions": {
|
|
152
161
|
"optional": true
|
|
153
162
|
},
|
|
@@ -172,6 +181,12 @@
|
|
|
172
181
|
"@types/koa": {
|
|
173
182
|
"optional": true
|
|
174
183
|
},
|
|
184
|
+
"body-parser": {
|
|
185
|
+
"optional": true
|
|
186
|
+
},
|
|
187
|
+
"cors": {
|
|
188
|
+
"optional": true
|
|
189
|
+
},
|
|
175
190
|
"express": {
|
|
176
191
|
"optional": true
|
|
177
192
|
},
|
|
@@ -190,8 +205,14 @@
|
|
|
190
205
|
"firebase-functions": {
|
|
191
206
|
"optional": true
|
|
192
207
|
},
|
|
208
|
+
"http-errors": {
|
|
209
|
+
"optional": true
|
|
210
|
+
},
|
|
193
211
|
"koa": {
|
|
194
212
|
"optional": true
|
|
213
|
+
},
|
|
214
|
+
"reflect-metadata": {
|
|
215
|
+
"optional": true
|
|
195
216
|
}
|
|
196
217
|
},
|
|
197
218
|
"config": {
|