Skip to content

Commit 4f749b9

Browse files
committed
implement auth to the construct model
1 parent a604d8a commit 4f749b9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/rest-api-construct/src/construct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class RestApiConstruct extends Construct {
9292
// Add resource and methods for this route
9393
const resource = this.addNestedResource(this.api.root, path);
9494
for (const method of methods) {
95-
resource.addMethod(method, new apiGateway.LambdaIntegration(handler));
95+
resource.addMethod(method.method, new apiGateway.LambdaIntegration(handler));
9696
}
9797
}
9898
}

packages/rest-api-construct/src/types.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,22 @@ export type RestApiConstructProps = {
1616
apiProps: RestApiPathConfig[];
1717
};
1818

19+
export type AuthorizerConfig =
20+
| { type: 'none' } // public
21+
| { type: 'userPool' } // signed-in users
22+
| { type: 'userPool'; groups: string[] }; // signed-in + group restriction
23+
24+
25+
export type MethodsProps = {
26+
method: HttpMethod;
27+
authorizer?: AuthorizerConfig;
28+
};
29+
1930
export type RestApiPathConfig = {
2031
path: string;
21-
methods: HttpMethod[];
32+
methods: MethodsProps[];
2233
lambdaEntry: LambdaSource;
34+
defaultAuthorizer?: AuthorizerConfig;
2335
};
2436

2537
export type HttpMethod =

0 commit comments

Comments
 (0)