lambder 1.0.97 → 1.0.99

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/dist/Lambder.js CHANGED
@@ -11,8 +11,9 @@ export const createContext = (event, lambdaContext, apiPath) => {
11
11
  const method = event.httpMethod;
12
12
  const cookie = cookieParser.parse(event.headers.Cookie || event.headers.cookie || "");
13
13
  const headers = event.headers;
14
- let post = {};
15
14
  const session = null;
15
+ // Decode body for the post
16
+ let post = {};
16
17
  try {
17
18
  const decodedBody = event.isBase64Encoded ? (event.body ? Buffer.from(event.body, "base64").toString() : "{}") : (event.body || "{}");
18
19
  try {
@@ -23,12 +24,10 @@ export const createContext = (event, lambdaContext, apiPath) => {
23
24
  }
24
25
  }
25
26
  catch (e) { }
27
+ // Parse api variables
26
28
  const isAPICall = method === "POST" && apiPath && path === apiPath && post.apiName;
27
29
  const apiName = isAPICall ? post.apiName : null;
28
30
  const apiPayload = isAPICall ? post.payload : null;
29
- if (/^(((\d+\.)+\d+)|(([a-f\d]+:)+[a-f\d]+))$/.test(host)) {
30
- throw new Error("[404] Host cannot be an ip address: " + host);
31
- }
32
31
  return { host, path, pathParams, method, get, post, cookie, apiName, apiPayload, headers, session, lambdaContext };
33
32
  };
34
33
  export default class Lambder {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambder",
3
- "version": "1.0.97",
3
+ "version": "1.0.99",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Lambder.ts CHANGED
@@ -63,18 +63,19 @@ export const createContext = (
63
63
  const method = event.httpMethod;
64
64
  const cookie = cookieParser.parse(event.headers.Cookie || event.headers.cookie || "");
65
65
  const headers = event.headers;
66
- let post: Record<string, any> = {};
67
66
  const session = null;
67
+ // Decode body for the post
68
+ let post: Record<string, any> = {};
68
69
  try {
69
70
  const decodedBody = event.isBase64Encoded ? ( event.body ? Buffer.from(event.body,"base64").toString() : "{}" ) : ( event.body || "{}" );
70
71
  try { post = JSON.parse(decodedBody) || {}; }
71
72
  catch(e){ post = querystring.parse(decodedBody) || {}; }
72
73
  }catch(e){}
74
+ // Parse api variables
73
75
  const isAPICall = method === "POST" && apiPath && path === apiPath && post.apiName;
74
76
  const apiName:string = isAPICall ? post.apiName : null;
75
77
  const apiPayload:string = isAPICall ? post.payload : null;
76
78
 
77
- if(/^(((\d+\.)+\d+)|(([a-f\d]+:)+[a-f\d]+))$/.test(host)){ throw new Error("[404] Host cannot be an ip address: " + host); }
78
79
  return { host, path, pathParams, method, get, post, cookie, apiName, apiPayload, headers, session, lambdaContext };
79
80
  }
80
81