@h4ad/serverless-adapter 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/lib/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/package.json +19 -4
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
[![Commitizen Friendly][commitizen-img]][commitizen-url]
|
|
20
20
|
[![Semantic Release][semantic-release-img]][semantic-release-url]
|
|
21
21
|
|
|
22
|
-
Run REST APIs and other web applications using your existing Node.js application framework (Deepkit, Express, Koa, Hapi,
|
|
23
|
-
Fastify and tRPC), on top of AWS Lambda, Azure,
|
|
22
|
+
Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Deepkit, Express, Koa, Hapi,
|
|
23
|
+
Fastify and tRPC), on top of AWS Lambda, Azure, Digital Ocean and many other clouds.
|
|
24
24
|
|
|
25
25
|
This library was a refactored version of [@vendia/serverless-express](https://github.com/vendia/serverless-express), I
|
|
26
26
|
create a new way to interact and extend event sources by creating contracts to abstract the integrations between each
|
|
@@ -38,6 +38,14 @@ Why you would use this libray instead of [@vendia/serverless-express](https://gi
|
|
|
38
38
|
- Well documented, any method, class, or interface has comments to explain the behavior.
|
|
39
39
|
- We have >99% coverage.
|
|
40
40
|
|
|
41
|
+
# Installing
|
|
42
|
+
|
|
43
|
+
To be able to use, first install the library:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm i --save @h4ad/serverless-adapter
|
|
47
|
+
```
|
|
48
|
+
|
|
41
49
|
# Usage
|
|
42
50
|
|
|
43
51
|
To start to use, first you need to know what you need to import, let's start showing the [ServerlessAdapter](/docs/api/ServerlessAdapter).
|
|
@@ -91,7 +99,6 @@ for existing and giving us a brilliant library that is the core of my current co
|
|
|
91
99
|
| <a href="https://liga.facens.br/"><img height="50" src="https://mlogu6g7z5ex.i.optimole.com/yEwfkqo-4R0ttNtd/w:auto/h:auto/q:mauto/f:avif/http://liga.facens.br/wp-content/uploads/2020/03/logo-1.png" title="The LIGA logo" width="100"/></a> |
|
|
92
100
|
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
93
101
|
|
|
94
|
-
|
|
95
102
|
[build-img]:https://github.com/H4ad/serverless-adapter/actions/workflows/release.yml/badge.svg
|
|
96
103
|
|
|
97
104
|
[build-url]:https://github.com/H4ad/serverless-adapter/actions/workflows/release.yml
|
|
@@ -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/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.12.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/**/*"
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@types/supertest": "^2.0.12",
|
|
97
97
|
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
|
98
98
|
"@typescript-eslint/parser": "^5.12.1",
|
|
99
|
-
"body-parser": "^1.
|
|
99
|
+
"body-parser": "^1.20.1",
|
|
100
100
|
"codecov": "^3.8.1",
|
|
101
101
|
"commitizen": "^4.2.4",
|
|
102
102
|
"cors": "^2.8.5",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"eslint-plugin-prettier": "^4.0.0",
|
|
110
110
|
"eslint-plugin-tsdoc": "^0.2.14",
|
|
111
111
|
"express": "^4.18.1",
|
|
112
|
-
"fastify": "^4.
|
|
112
|
+
"fastify": "^4.10.2",
|
|
113
113
|
"fastify-3": "npm:fastify@3.29.0",
|
|
114
114
|
"firebase-admin": "^11.0.1",
|
|
115
115
|
"firebase-admin-8": "npm:firebase-admin@^8.0.0",
|
|
@@ -133,10 +133,12 @@
|
|
|
133
133
|
"@hapi/hapi": ">= 20.0.0",
|
|
134
134
|
"@trpc/server": ">= 9.0.0",
|
|
135
135
|
"@types/aws-lambda": ">= 8.10.92",
|
|
136
|
+
"@types/body-parser": ">= 1.19.2",
|
|
136
137
|
"@types/cors": ">= 2.8.12",
|
|
137
138
|
"@types/express": ">= 4.15.4",
|
|
138
139
|
"@types/hapi": ">= 18.0.7",
|
|
139
140
|
"@types/koa": ">= 2.11.2",
|
|
141
|
+
"body-parser": ">= 1.20.0",
|
|
140
142
|
"cors": ">= 2.8.5",
|
|
141
143
|
"express": ">= 4.15.4",
|
|
142
144
|
"fastify": ">= 3.0.0",
|
|
@@ -144,6 +146,7 @@
|
|
|
144
146
|
"firebase-admin": ">= 8.0.0",
|
|
145
147
|
"firebase-admin-8": "npm:firebase-admin@^8.0.0",
|
|
146
148
|
"firebase-functions": ">= 3.0.0",
|
|
149
|
+
"http-errors": ">= 2.0.0",
|
|
147
150
|
"koa": ">= 2.5.1",
|
|
148
151
|
"reflect-metadata": "^0.1.13"
|
|
149
152
|
},
|
|
@@ -172,6 +175,12 @@
|
|
|
172
175
|
"@types/koa": {
|
|
173
176
|
"optional": true
|
|
174
177
|
},
|
|
178
|
+
"body-parser": {
|
|
179
|
+
"optional": true
|
|
180
|
+
},
|
|
181
|
+
"cors": {
|
|
182
|
+
"optional": true
|
|
183
|
+
},
|
|
175
184
|
"express": {
|
|
176
185
|
"optional": true
|
|
177
186
|
},
|
|
@@ -190,8 +199,14 @@
|
|
|
190
199
|
"firebase-functions": {
|
|
191
200
|
"optional": true
|
|
192
201
|
},
|
|
202
|
+
"http-errors": {
|
|
203
|
+
"optional": true
|
|
204
|
+
},
|
|
193
205
|
"koa": {
|
|
194
206
|
"optional": true
|
|
207
|
+
},
|
|
208
|
+
"reflect-metadata": {
|
|
209
|
+
"optional": true
|
|
195
210
|
}
|
|
196
211
|
},
|
|
197
212
|
"config": {
|