@@ -11,6 +11,8 @@ import RunGenerator from '@components/run-generator.astro';
1111import NxCommands from ' @components/nx-commands.astro' ;
1212import InstallCommand from ' @components/install-command.astro' ;
1313import CreateNxWorkspaceCommand from ' @components/create-nx-workspace-command.astro' ;
14+ import E2EDiff from ' @components/e2e-diff.astro' ;
15+
1416import dungeonAdventureArchitecturePng from ' @assets/dungeon-game-architecture.png'
1517import dungeonAdventureErPng from ' @assets/dungeon-adventure-er.png'
1618import baselineWebsitePng from ' @assets/baseline-website.png'
@@ -137,7 +139,7 @@ import {
137139} from ' @trpc/server/adapters/aws-lambda' ;
138140import { echo } from ' ./procedures/echo.js' ;
139141import { t } from ' ./init.js' ;
140- import { APIGatewayProxyEventV2WithIAMAuthorizer } from ' aws-lambda' ;
142+ import { APIGatewayProxyEvent } from ' aws-lambda' ;
141143
142144export const router = t .router ;
143145
@@ -148,8 +150,14 @@ export const appRouter = router({
148150export const handler = awsLambdaRequestHandler ({
149151 router: appRouter ,
150152 createContext : (
151- ctx : CreateAWSLambdaContextOptions <APIGatewayProxyEventV2WithIAMAuthorizer >,
153+ ctx : CreateAWSLambdaContextOptions <APIGatewayProxyEvent >,
152154 ) => ctx ,
155+ responseMeta : () => ({
156+ headers: {
157+ ' Access-Control-Allow-Origin' : ' *' ,
158+ ' Access-Control-Allow-Methods' : ' *' ,
159+ },
160+ }),
153161});
154162
155163export type AppRouter = typeof appRouter ;
@@ -1015,41 +1023,8 @@ This is where we will instantiate our CDK constructs to build our dungeon advent
10151023
10161024Let's make an update to our ` packages/infra/src/stacks/application-stack.ts ` to instantiate some of our already generated constructs:
10171025
1018- ``` diff lang="ts"
1019- + import {
1020- + GameApi,
1021- + GameUI,
1022- + StoryApi,
1023- + UserIdentity,
1024- + } from ':dungeon-adventure/common-constructs';
1025- import * as cdk from 'aws-cdk-lib';
1026- import { Construct } from 'constructs';
1027-
1028- export class ApplicationStack extends cdk.Stack {
1029- constructor(scope: Construct, id: string, props?: cdk.StackProps) {
1030- super(scope, id, props);
1031-
1032- - // The code that defines your stack goes here
1033- + const userIdentity = new UserIdentity(this, 'UserIdentity');
1034- +
1035- + const gameApi = new GameApi(this, 'GameApi', {
1036- + integrations: GameApi.defaultIntegrations(this).build(),
1037- + });
1038- + const storyApi = new StoryApi(this, 'StoryApi', {
1039- + integrations: StoryApi.defaultIntegrations(this).build(),
1040- + });
1041- +
1042- + // grant our authenticated role access to invoke our APIs
1043- + [storyApi, gameApi].forEach((api) =>
1044- + api.grantInvokeAccess(userIdentity.identityPool.authenticatedRole),
1045- + );
1046- +
1047- + // Ensure this is instantiated last so our runtime-config.json can be automatically configured
1048- + new GameUI(this, 'GameUI');
1049- }
1050- }
10511026
1052- ```
1027+ < E2EDiff before = " dungeon-adventure/1/application-stack.ts.original.template " after = " dungeon-adventure/1/application-stack.ts.template " lang = " ts " />
10531028
10541029Notice here that we supply default integrations for our two APIs. By default, each operation in our API is mapped to an individual lambda function to handle that operation.
10551030
0 commit comments