lambder 1.0.87 → 1.0.89

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
@@ -25,6 +25,7 @@ type LambderRenderContext = {
25
25
  session: LambderSession | null;
26
26
  lambdaContext: Context;
27
27
  };
28
+ type LambderModuleFunction = (lambderInstance: Lambder) => void | Promise<void>;
28
29
  type ConditionFunction = (ctx: LambderRenderContext) => boolean;
29
30
  type ActionFunction = (ctx: LambderRenderContext, resolver: LambderResolver) => LambderResolverResponse | Promise<LambderResolverResponse>;
30
31
  type HookCreatedFunction = (lambderInstance: Lambder) => Promise<void>;
@@ -58,7 +59,10 @@ export default class Lambder {
58
59
  testPatternMatch(pattern: string, path: string): boolean;
59
60
  private validateSession;
60
61
  private handleNoMatchedAction;
61
- addModule(moduleFn: Function): Promise<void>;
62
+ addModule(moduleFn: LambderModuleFunction): Promise<void>;
63
+ addModuleImport(moduleImport: Promise<{
64
+ default: LambderModuleFunction;
65
+ }>): Promise<void>;
62
66
  addRoute(condition: Path | ConditionFunction | RegExp, actionFn: ActionFunction): void;
63
67
  addSessionRoute(condition: Path | ConditionFunction | RegExp, actionFn: ActionFunction): void;
64
68
  addApi(apiName: string | ConditionFunction | RegExp, actionFn: ActionFunction): void;
package/dist/Lambder.js CHANGED
@@ -114,6 +114,9 @@ export default class Lambder {
114
114
  async addModule(moduleFn) {
115
115
  await moduleFn(this);
116
116
  }
117
+ async addModuleImport(moduleImport) {
118
+ await (await moduleImport).default(this);
119
+ }
117
120
  addRoute(condition, actionFn) {
118
121
  this.actionList.push({
119
122
  conditionFn: (ctx) => (ctx.method === "GET" &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambder",
3
- "version": "1.0.87",
3
+ "version": "1.0.89",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Lambder.ts CHANGED
@@ -33,6 +33,9 @@ type LambderRenderContext = {
33
33
  lambdaContext: Context;
34
34
  };
35
35
 
36
+ type LambderModuleFunction = (lambderInstance: Lambder) => void | Promise<void>;
37
+
38
+
36
39
  type ConditionFunction = (ctx: LambderRenderContext) => boolean;
37
40
  type ActionFunction = (ctx: LambderRenderContext, resolver: LambderResolver) => LambderResolverResponse|Promise<LambderResolverResponse>;
38
41
  type ActionObject = { conditionFn: ConditionFunction, actionFn: ActionFunction };
@@ -158,9 +161,14 @@ export default class Lambder {
158
161
  }
159
162
  }
160
163
 
161
- async addModule(moduleFn: Function): Promise<void>{
164
+ async addModule(moduleFn: LambderModuleFunction): Promise<void>{
162
165
  await moduleFn(this);
163
166
  }
167
+
168
+ async addModuleImport(moduleImport: Promise<{ default: LambderModuleFunction }>): Promise<void>{
169
+ await (await moduleImport).default(this);
170
+ }
171
+
164
172
  addRoute(condition: Path|ConditionFunction|RegExp, actionFn: ActionFunction):void{
165
173
  this.actionList.push({
166
174
  conditionFn: (ctx:LambderRenderContext) => (