lambder 1.0.49 → 1.0.51
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 +6 -3
- package/dist/Lambder.js +1 -1
- package/package.json +1 -1
- package/src/Lambder.ts +6 -4
package/dist/Lambder.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { APIGatewayProxyEvent, APIGatewayProxyEventHeaders, Context } from "aws-lambda";
|
|
2
2
|
import Resolver from "./Resolver.js";
|
|
3
3
|
import ResponseBuilder, { ResolverResponse } from "./ResponseBuilder.js";
|
|
4
|
+
type Path = `/${string}`;
|
|
4
5
|
type Session = {
|
|
5
6
|
userId: string;
|
|
6
7
|
userIdHash: string;
|
|
@@ -62,13 +63,15 @@ export default class Lambder {
|
|
|
62
63
|
setRouteFallbackHandler(routeFallbackHandler: RouteFallbackHandlerFunction): void;
|
|
63
64
|
setApiFallbackHandler(apiFallbackHandler: ApiFallbackHandlerFunction): void;
|
|
64
65
|
setGlobalErrorHandler(globalErrorHandler: GlobalErrorHandlerFunction): void;
|
|
65
|
-
getPatternMatch(pattern: string, path: string):
|
|
66
|
+
getPatternMatch(pattern: string, path: string): {
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
};
|
|
66
69
|
testPatternMatch(pattern: string, path: string): boolean;
|
|
67
70
|
private validateSession;
|
|
68
71
|
private handleNoMatchedAction;
|
|
69
72
|
addModule(moduleFn: Function): Promise<void>;
|
|
70
|
-
addRoute(condition:
|
|
71
|
-
addSessionRoute(condition:
|
|
73
|
+
addRoute(condition: Path | ConditionFunction | RegExp, actionFn: ActionFunction): void;
|
|
74
|
+
addSessionRoute(condition: Path | ConditionFunction | RegExp, actionFn: ActionFunction): void;
|
|
72
75
|
addApi(condition: string | ConditionFunction | RegExp, actionFn: ActionFunction): void;
|
|
73
76
|
addSessionApi(condition: string | ConditionFunction | RegExp, actionFn: ActionFunction): void;
|
|
74
77
|
addHook(hookEvent: 'created', hookFn: HookCreatedFunction, priority?: number): Promise<void>;
|
package/dist/Lambder.js
CHANGED
|
@@ -64,7 +64,7 @@ export default class Lambder {
|
|
|
64
64
|
const result = (match(pattern, { decode: decodeURIComponent }))(path);
|
|
65
65
|
if (!result)
|
|
66
66
|
return {};
|
|
67
|
-
return result?.params;
|
|
67
|
+
return result?.params || {};
|
|
68
68
|
}
|
|
69
69
|
testPatternMatch(pattern, path) {
|
|
70
70
|
return (match(pattern, { decode: decodeURIComponent }))(path) !== false;
|
package/package.json
CHANGED
package/src/Lambder.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { APIGatewayProxyEvent, APIGatewayProxyEventHeaders, Context } from
|
|
|
6
6
|
import Resolver from "./Resolver.js";
|
|
7
7
|
import ResponseBuilder, { ResolverResponse } from "./ResponseBuilder.js";
|
|
8
8
|
|
|
9
|
+
type Path = `/${string}`;
|
|
10
|
+
|
|
9
11
|
type Session = {
|
|
10
12
|
userId: string,
|
|
11
13
|
userIdHash: string;
|
|
@@ -116,10 +118,10 @@ export default class Lambder {
|
|
|
116
118
|
setGlobalErrorHandler(globalErrorHandler: GlobalErrorHandlerFunction){
|
|
117
119
|
this.globalErrorHandler = globalErrorHandler;
|
|
118
120
|
}
|
|
119
|
-
getPatternMatch(pattern: string, path: string){
|
|
121
|
+
getPatternMatch(pattern: string, path: string): { [key:string]: any }{
|
|
120
122
|
const result = (match(pattern, { decode: decodeURIComponent }))(path);
|
|
121
123
|
if(!result) return {};
|
|
122
|
-
return result?.params;
|
|
124
|
+
return result?.params || {};
|
|
123
125
|
}
|
|
124
126
|
testPatternMatch(pattern: string, path: string): boolean{
|
|
125
127
|
return (match(pattern, { decode: decodeURIComponent }))(path) !== false;
|
|
@@ -152,7 +154,7 @@ export default class Lambder {
|
|
|
152
154
|
async addModule(moduleFn: Function): Promise<void>{
|
|
153
155
|
await moduleFn(this);
|
|
154
156
|
}
|
|
155
|
-
addRoute(condition:
|
|
157
|
+
addRoute(condition: Path|ConditionFunction|RegExp, actionFn: ActionFunction):void{
|
|
156
158
|
this.actionList.push({
|
|
157
159
|
conditionFn: (ctx:RenderContext) => (
|
|
158
160
|
ctx.method === "GET" &&
|
|
@@ -173,7 +175,7 @@ export default class Lambder {
|
|
|
173
175
|
});
|
|
174
176
|
};
|
|
175
177
|
|
|
176
|
-
addSessionRoute(condition:
|
|
178
|
+
addSessionRoute(condition: Path|ConditionFunction|RegExp, actionFn: ActionFunction):void{
|
|
177
179
|
this.actionList.push({
|
|
178
180
|
conditionFn: (ctx:RenderContext) => (
|
|
179
181
|
ctx.method === "GET" &&
|