lambder 1.0.57 → 1.0.58

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.
@@ -5,7 +5,7 @@ type FetchTracker = {
5
5
  fetchEndCalled: boolean;
6
6
  };
7
7
  type EventHandlerFetchParams = {
8
- api: string;
8
+ apiName: string;
9
9
  payload?: any;
10
10
  headers?: Record<string, any>;
11
11
  };
@@ -33,7 +33,7 @@ export default class LambderCaller {
33
33
  this.fetchTrackerList.push(fetchTracker);
34
34
  if (this.fetchStartedHandler)
35
35
  await this.fetchStartedHandler({
36
- fetchParams: { api: apiName, payload, headers, },
36
+ fetchParams: { apiName, payload, headers, },
37
37
  activeFetchList: this.fetchTrackerList.filter(v => !v.done)
38
38
  });
39
39
  const version = this.apiVersion;
@@ -43,7 +43,7 @@ export default class LambderCaller {
43
43
  method: 'POST', mode: 'same-origin', cache: 'no-cache',
44
44
  credentials: 'same-origin', redirect: 'follow', referrerPolicy: 'origin',
45
45
  headers: { 'Content-Type': 'application/json', ...(headers || {}) },
46
- body: JSON.stringify({ api: apiName, version, token, siteHost, payload, }),
46
+ body: JSON.stringify({ apiName, version, token, siteHost, payload, }),
47
47
  }).then(res => {
48
48
  if (res.status >= 500)
49
49
  throw new Error("Request failed: " + res.status + " - " + res.statusText);
@@ -53,7 +53,7 @@ export default class LambderCaller {
53
53
  if (this.fetchEndedHandler) {
54
54
  fetchTracker.fetchEndCalled = true;
55
55
  await this.fetchEndedHandler({
56
- fetchParams: { api: apiName, payload, headers, },
56
+ fetchParams: { apiName, payload, headers, },
57
57
  fetchResult: data,
58
58
  activeFetchList: this.fetchTrackerList.filter(v => !v.done),
59
59
  });
@@ -100,7 +100,7 @@ export default class LambderCaller {
100
100
  fetchTracker.done = true;
101
101
  if (!fetchTracker.fetchEndCalled && this.fetchEndedHandler) {
102
102
  await this.fetchEndedHandler({
103
- fetchParams: { api: apiName, payload, headers, },
103
+ fetchParams: { apiName, payload, headers, },
104
104
  fetchResult: wrappedError,
105
105
  activeFetchList: this.fetchTrackerList.filter(v => !v.done)
106
106
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambder",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Lambder.ts CHANGED
@@ -65,7 +65,7 @@ export const createContext = (
65
65
  const headers = event.headers;
66
66
  let post: Record<string, any> = {};
67
67
  const session = null;
68
- const apiName = (method === "POST" && apiPath && path === apiPath && post.apiName) ? post.apiName : null;
68
+ const apiName:string = (method === "POST" && apiPath && path === apiPath && post.apiName) ? post.apiName : null;
69
69
  try {
70
70
  const decodedBody = event.isBase64Encoded ? ( event.body ? Buffer.from(event.body,"base64").toString() : "{}" ) : ( event.body || "{}" );
71
71
  try { post = JSON.parse(decodedBody) || {}; }
@@ -3,7 +3,7 @@ import Cookies from 'js-cookie';
3
3
  type VoidFunction = ()=>void|Promise<void>;
4
4
  type FetchTracker = { apiName: string, done: boolean, fetchEndCalled: boolean };
5
5
  type EventHandlerFetchParams = {
6
- api: string,
6
+ apiName: string,
7
7
  payload?: any,
8
8
  headers?: Record<string, any>
9
9
  };
@@ -94,7 +94,7 @@ export default class LambderCaller {
94
94
  try {
95
95
  this.fetchTrackerList.push(fetchTracker);
96
96
  if(this.fetchStartedHandler) await this.fetchStartedHandler({
97
- fetchParams: { api: apiName, payload, headers, },
97
+ fetchParams: { apiName, payload, headers, },
98
98
  activeFetchList: this.fetchTrackerList.filter(v=>!v.done)
99
99
  });
100
100
  const version = this.apiVersion;
@@ -104,7 +104,7 @@ export default class LambderCaller {
104
104
  method: 'POST', mode: 'same-origin', cache: 'no-cache',
105
105
  credentials: 'same-origin', redirect: 'follow', referrerPolicy: 'origin',
106
106
  headers: { 'Content-Type': 'application/json', ...(headers || {}) },
107
- body: JSON.stringify({ api: apiName, version, token, siteHost, payload, }),
107
+ body: JSON.stringify({ apiName, version, token, siteHost, payload, }),
108
108
  }).then(res=>{
109
109
  if(res.status >= 500) throw new Error("Request failed: " + res.status + " - " + res.statusText);
110
110
  return res.json();
@@ -113,7 +113,7 @@ export default class LambderCaller {
113
113
  if(this.fetchEndedHandler){
114
114
  fetchTracker.fetchEndCalled = true;
115
115
  await this.fetchEndedHandler({
116
- fetchParams: { api: apiName, payload, headers, },
116
+ fetchParams: { apiName, payload, headers, },
117
117
  fetchResult: data,
118
118
  activeFetchList: this.fetchTrackerList.filter(v=>!v.done),
119
119
  });
@@ -156,7 +156,7 @@ export default class LambderCaller {
156
156
  fetchTracker.done = true;
157
157
  if(!fetchTracker.fetchEndCalled && this.fetchEndedHandler){
158
158
  await this.fetchEndedHandler({
159
- fetchParams: { api: apiName, payload, headers, },
159
+ fetchParams: { apiName, payload, headers, },
160
160
  fetchResult: wrappedError,
161
161
  activeFetchList: this.fetchTrackerList.filter(v=>!v.done)
162
162
  });