1 | /**
|
2 | * @file Defines the AagExecutionContext class.
|
3 | *
|
4 | * @author Luke Chavers <luke@c2cschools.com>
|
5 | * @author Kevin Sanders <kevin@c2cschools.com>
|
6 | * @since 5.0.0
|
7 | * @license See LICENSE.md for details about licensing.
|
8 | * @copyright 2017 C2C Schools, LLC
|
9 | */
|
10 |
|
11 | ;
|
12 |
|
13 | // Important Note
|
14 | // --------------
|
15 | // This module only loads a single dependency, directly, which is the
|
16 | // parent class for the class defined within. This is intended to force
|
17 | // dependency loading through the parent class, by way of the `$dep()`
|
18 | // method, in order to centralize dependency definition and loading.
|
19 |
|
20 | const BaseHttpExecutionContext = require(
|
21 | "./abstract/BaseHttpExecutionContext"
|
22 | );
|
23 |
|
24 | /**
|
25 | * Represents an execution context whereby an endpoint is executed on
|
26 | * AWS Lambda by way of an AAG routed request.
|
27 | *
|
28 | * @memberOf ExecutionContext
|
29 | * @extends ExecutionContext.BaseHttpExecutionContext
|
30 | */
|
31 | class AagExecutionContext extends BaseHttpExecutionContext {
|
32 |
|
33 | // noinspection JSMethodCanBeStatic, JSUnusedGlobalSymbols
|
34 | /**
|
35 | * Overrides the serialization of the {@link Response.BaseResponse} object
|
36 | * by returning only the `body` of the response, as an object.
|
37 | *
|
38 | * @private
|
39 | * @param {Response.BaseResponse} response - The unformatted response.
|
40 | * @returns {Object} The formatted response.
|
41 | */
|
42 | _formatResponse( response ) {
|
43 |
|
44 | // https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format
|
45 |
|
46 | return response.toPlainObject( "strBody" );
|
47 | }
|
48 | }
|
49 |
|
50 | module.exports = AagExecutionContext;
|