Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
feat: ✨ add dynamodb libs and table to stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ecxyzzy committed Feb 5, 2024
1 parent 5140300 commit ebcd1ca
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 50 deletions.
9 changes: 7 additions & 2 deletions apps/api/bronya.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { PrismaClient } from "@libs/db";
import { logger, warmingRequestBody } from "@libs/lambda";
import { LambdaIntegration, ResponseType } from "aws-cdk-lib/aws-apigateway";
import { Certificate } from "aws-cdk-lib/aws-certificatemanager";
import { RuleTargetInput, Rule, Schedule } from "aws-cdk-lib/aws-events";
import { AttributeType, Table } from "aws-cdk-lib/aws-dynamodb";
import { Rule, RuleTargetInput, Schedule } from "aws-cdk-lib/aws-events";
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
import { Architecture, Code, Function as AwsLambdaFunction, Runtime } from "aws-cdk-lib/aws-lambda";
import { ARecord, HostedZone, RecordTarget } from "aws-cdk-lib/aws-route53";
import { ApiGateway } from "aws-cdk-lib/aws-route53-targets";
import { App, Stack, Duration } from "aws-cdk-lib/core";
import { App, Duration, Stack } from "aws-cdk-lib/core";
import { config } from "dotenv";
import type { BuildOptions } from "esbuild";

Expand Down Expand Up @@ -171,6 +172,7 @@ export const constructs: ApiConstructProps = {
*/
class ApiStack extends Stack {
public api: Api;
public cache: Table;

constructor(scope: App, id: string, stage: string) {
super(scope, id);
Expand Down Expand Up @@ -205,6 +207,9 @@ class ApiStack extends Stack {
},
esbuild: esbuildOptions,
});
this.cache = new Table(this, `${id}-${stage}-cache`, {
partitionKey: { name: "cacheKey", type: AttributeType.STRING },
});
}
}

Expand Down
2 changes: 2 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
},
"dependencies": {
"@apollo/server": "4.10.0",
"@aws-sdk/client-dynamodb": "3.501.0",
"@aws-sdk/client-lambda": "3.501.0",
"@aws-sdk/lib-dynamodb": "3.501.0",
"@graphql-tools/load-files": "7.0.0",
"@graphql-tools/merge": "9.0.1",
"@graphql-tools/utils": "10.0.13",
Expand Down
168 changes: 120 additions & 48 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ebcd1ca

Please sign in to comment.