Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fa5c9e
commit 8743116
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
lib/stacks/my-stack/database/items/create-items-dynamodb.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { RemovalPolicy } from 'aws-cdk-lib'; | ||
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; | ||
import { Construct } from 'constructs'; | ||
|
||
export function createItemsDynamoDB(scope: Construct): dynamodb.Table { | ||
const table = new dynamodb.Table(scope, 'turbogate-example-items', { | ||
tableName: 'items', | ||
partitionKey: { | ||
name: "id", | ||
type: dynamodb.AttributeType.STRING, | ||
}, | ||
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, | ||
removalPolicy: RemovalPolicy.DESTROY, | ||
}); | ||
return table; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import z from "zod"; | ||
|
||
export const zItemRecord = z | ||
.strictObject({ | ||
id: z.string().uuid().openapi({ description: 'The ID of the item. Generated by the backend upon creation.' }), | ||
name: z.string().min(5).max(20).openapi({ | ||
description: 'The name of the item. Does not have to be unique and can be changed at any given time.', | ||
example: 'Excellent Item', | ||
}), | ||
description: z.string().optional().openapi({ | ||
description: 'The description of the item. Can be changed at any given time.', | ||
example: 'This item is of exceptional excellence.', | ||
}), | ||
}) | ||
.openapi('Item', { description: 'An item.' }); | ||
|
||
export type ItemRecord = z.infer<typeof zItemRecord>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { Construct } from 'constructs'; | ||
import { createItemsDynamoDB } from './database/items/create-items-dynamodb'; | ||
|
||
export class MyStack extends cdk.Stack { | ||
constructor(scope: Construct, id: string, props?: cdk.StackProps) { | ||
super(scope, id, props); | ||
|
||
const itemsTable = createItemsDynamoDB(this); | ||
} | ||
} |