@yopdev/dev-server 2.0.0-beta.2 → 2.0.0-beta.4

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.
@@ -4,7 +4,7 @@ import { HttpSettings } from './http-server';
4
4
  import { Authorizer, Route } from './lambda-http-proxy';
5
5
  import { Callback, Service, Startable } from './services';
6
6
  import { LambdaPayloadVersion } from './mappers';
7
- export declare const newLambdaProxyFromCloudFormationTemplate: <Context, AuthorizerContext, Event_1, HandlerResponse>(name: string, settings: HttpSettings, lambdaPayloadVersion: () => LambdaPayloadVersion<AuthorizerContext, Event_1, HandlerResponse>, config: CloudFormationLambdaProxyConfig<Context, AuthorizerContext, Event_1, HandlerResponse>, callback: Callback<string>) => Startable<Service<string>>;
7
+ export declare const newLambdaProxyFromCloudFormationTemplate: <Context, AuthorizerContext, Event_1, HandlerResponse>(name: string, settings: HttpSettings, payloadVersion: LambdaPayloadVersion<AuthorizerContext, Event_1, HandlerResponse>, config: CloudFormationLambdaProxyConfig<Context, AuthorizerContext, Event_1, HandlerResponse>, callback: Callback<string>) => Startable<Service<string>>;
8
8
  type CloudFormationLambdaProxyConfig<Context, AuthorizerContext, Event, HandlerResponse> = {
9
9
  authorizer?: (config: DevServerConfig) => Authorizer<AuthorizerContext> | undefined;
10
10
  extraRoutes: Route<Context, AuthorizerContext, Event, HandlerResponse>[];
@@ -6,10 +6,10 @@ const lambda_http_proxy_1 = require("./lambda-http-proxy");
6
6
  const PATH_VARIABLE_CAPTURE = /{(.*?)}/g;
7
7
  const QUERY_STRING_OR_LOCATION_REG_EXP = '(?:([?#].*))?';
8
8
  const PROXY_PATH_PARAM = 'proxy';
9
- const newLambdaProxyFromCloudFormationTemplate = (name, settings, lambdaPayloadVersion, config, callback) => new CloudFormationLambdaProxy(name, settings, config.extraRoutes, lambdaPayloadVersion, config, callback);
9
+ const newLambdaProxyFromCloudFormationTemplate = (name, settings, payloadVersion, config, callback) => new CloudFormationLambdaProxy(name, settings, config.extraRoutes, payloadVersion, config, callback);
10
10
  exports.newLambdaProxyFromCloudFormationTemplate = newLambdaProxyFromCloudFormationTemplate;
11
11
  class CloudFormationLambdaProxy extends cloudformation_1.CloudFormationSetup {
12
- constructor(name, settings, extraRoutes, lambdaPayloadVersion, config, callback) {
12
+ constructor(name, settings, extraRoutes, payloadVersion, config, callback) {
13
13
  super(name, (event) => event.Type === 'HttpApi', async (event, handler) => Promise.resolve(this.pathWithCapturingGroups(event.Properties.Path)).then((pathWithCapturingGroups) => ({
14
14
  method: new RegExp(event.Properties.Method),
15
15
  path: new RegExp(`^${pathWithCapturingGroups}${QUERY_STRING_OR_LOCATION_REG_EXP}?$`),
@@ -36,7 +36,6 @@ class CloudFormationLambdaProxy extends cloudformation_1.CloudFormationSetup {
36
36
  .map(([k, v]) => [k, decodeURIComponent(v)])));
37
37
  return handler(event, context?.());
38
38
  };
39
- const payloadVersion = lambdaPayloadVersion();
40
39
  this.mapper = payloadVersion.mapper;
41
40
  this.authorizer = config?.authorizer;
42
41
  this.pathParameterResolver = payloadVersion.resolver;
@@ -131,11 +131,15 @@ class DefaultLambdaMapper {
131
131
  headers['content-type'] = request.headers['content-type'];
132
132
  if (request.headers['accept'])
133
133
  headers['accept'] = request.headers['accept'];
134
- if (request.headers['authorization'])
135
- headers['authorization'] = request.headers['authorization'];
134
+ const authorizationHeaderValue = request.headers['authorization'];
135
+ if (authorizationHeaderValue) {
136
+ headers['authorization'] = authorizationHeaderValue;
137
+ this.authorizationHeaderValue = authorizationHeaderValue;
138
+ }
136
139
  this.headers = headers;
137
140
  this.url = url;
138
141
  this.time = 1428582896000;
142
+ this.method = request.method;
139
143
  }
140
144
  }
141
145
  class StringResponse extends lambda_http_proxy_1.Response {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yopdev/dev-server",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.4",
4
4
  "scripts": {
5
5
  "compile": "tsc",
6
6
  "pretest": "npm run compile",