lambder 1.0.142 → 1.0.143

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.d.ts CHANGED
@@ -22,6 +22,7 @@ export type LambderRenderContext<TApiPayload = any> = {
22
22
  lambdaContext: Context;
23
23
  _otherInternal: {
24
24
  isApiCall: boolean;
25
+ requestVersion: string | null;
25
26
  setHeaderFnAccumulator: {
26
27
  key: string;
27
28
  value: string | string[];
package/dist/Lambder.js CHANGED
@@ -31,13 +31,14 @@ export const createContext = (event, lambdaContext, apiPath) => {
31
31
  const isApiCall = method === "POST" && apiPath && path === apiPath && post.apiName;
32
32
  const apiName = isApiCall ? post.apiName : null;
33
33
  const apiPayload = isApiCall ? post.payload : null;
34
+ const requestVersion = isApiCall ? post.version : null;
34
35
  return {
35
36
  host, path, pathParams, method,
36
37
  get, post, cookie, event,
37
38
  apiName, apiPayload,
38
39
  headers, session, lambdaContext,
39
40
  _otherInternal: {
40
- isApiCall,
41
+ isApiCall, requestVersion,
41
42
  setHeaderFnAccumulator: [],
42
43
  addHeaderFnAccumulator: [],
43
44
  logToApiResponseAccumulator: [],
@@ -237,7 +238,7 @@ export default class Lambder {
237
238
  const firstMatchedAction = this.actionList.find(action => action.conditionFn(ctx));
238
239
  if (firstMatchedAction) {
239
240
  // Check version if provided by the client and the server
240
- if (this.apiVersion && ctx.post?.apiVersion) {
241
+ if (this.apiVersion && ctx._otherInternal.requestVersion) {
241
242
  if (ctx.post.apiVersion !== this.apiVersion) {
242
243
  const responseBuilder = this.getResponseBuilder();
243
244
  return resolve(responseBuilder.versionExpired());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambder",
3
- "version": "1.0.142",
3
+ "version": "1.0.143",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Lambder.ts CHANGED
@@ -28,6 +28,7 @@ export type LambderRenderContext<TApiPayload = any> = {
28
28
  lambdaContext: Context;
29
29
  _otherInternal: {
30
30
  isApiCall: boolean,
31
+ requestVersion: string|null;
31
32
  setHeaderFnAccumulator: { key:string, value:string|string[] }[];
32
33
  addHeaderFnAccumulator: { key:string, value:string }[];
33
34
  logToApiResponseAccumulator: any[];
@@ -77,6 +78,7 @@ export const createContext = (
77
78
  const isApiCall = method === "POST" && apiPath && path === apiPath && post.apiName;
78
79
  const apiName:string = isApiCall ? post.apiName : null;
79
80
  const apiPayload:string = isApiCall ? post.payload : null;
81
+ const requestVersion:string = isApiCall ? post.version : null;
80
82
 
81
83
  return {
82
84
  host, path, pathParams, method,
@@ -84,7 +86,7 @@ export const createContext = (
84
86
  apiName, apiPayload,
85
87
  headers, session, lambdaContext,
86
88
  _otherInternal: {
87
- isApiCall,
89
+ isApiCall, requestVersion,
88
90
  setHeaderFnAccumulator: [],
89
91
  addHeaderFnAccumulator: [],
90
92
  logToApiResponseAccumulator: [],
@@ -378,7 +380,7 @@ export default class Lambder<TContract extends ApiContractShape = any> {
378
380
  const firstMatchedAction = this.actionList.find(action => action.conditionFn(ctx));
379
381
  if(firstMatchedAction){
380
382
  // Check version if provided by the client and the server
381
- if(this.apiVersion && ctx.post?.apiVersion){
383
+ if(this.apiVersion && ctx._otherInternal.requestVersion){
382
384
  if(ctx.post.apiVersion !== this.apiVersion){
383
385
  const responseBuilder = this.getResponseBuilder();
384
386
  return resolve(responseBuilder.versionExpired());