Skip to content

feat: update experimental template t flatten structure and use new dynamodb apis #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Function } from "fl-exp";
import { $AWS } from "functionless";
import { LambdaFunction } from "fl-exp";
import * as uuid from "uuid";

import { AppTable } from "./table";

export default Function(async (event: { message: string }) => {
export default LambdaFunction(async (event: { message: string }) => {
const id = uuid.v4();
await $AWS.DynamoDB.PutItem({
Table: AppTable,
await AppTable.put({
Item: {
pk: {
S: "todo",
Expand Down
17 changes: 17 additions & 0 deletions templates/devx-experimental/src/delete-todo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { LambdaFunction } from "fl-exp";
import { AppTable } from "./table";

export default LambdaFunction(async (event: { id: string }) => {
await AppTable.delete({
Key: {
pk: {
S: "todo",
},
sk: {
S: event.id,
},
},
});

return "DELETED";
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Function } from "fl-exp";
import { $AWS } from "functionless";

import { AppTable } from "./table";

export default Function(async (event: {}) => {
const response = await $AWS.DynamoDB.Query({
Table: AppTable,
export default LambdaFunction(async (event: {}) => {
const response = AppTable.query({
KeyConditionExpression: "#pk = :pk",
ExpressionAttributeNames: {
"#pk": "pk",
Expand All @@ -23,4 +21,4 @@ export default Function(async (event: {}) => {
message: item.message.S,
};
});
});
});
3 changes: 0 additions & 3 deletions templates/devx-experimental/src/my-stack/_stack.ts

This file was deleted.

20 changes: 0 additions & 20 deletions templates/devx-experimental/src/my-stack/delete-todo.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AttributeType, BillingMode } from "aws-cdk-lib/aws-dynamodb";
import { Table } from "fl-exp";

interface TableItem<T extends string> {
Expand All @@ -15,13 +14,12 @@ interface Todo extends TableItem<"todo"> {
export const AppTable = Table<Todo, "pk", "sk">({
partitionKey: {
name: "pk",
type: AttributeType.STRING,
type: "S",
},
sortKey: {
name: "sk",
type: AttributeType.STRING,
type: "S",
},
billingMode: BillingMode.PAY_PER_REQUEST,
});

export default AppTable;