feat: Update .gitignore, add Lambda layer configuration, and refactor DynamoDB handlers to use AWS SDK v3
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import { DynamoDB } from "aws-sdk";
|
||||
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
||||
import { DynamoDBDocument, PutCommandInput } from "@aws-sdk/lib-dynamodb";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
const SLS_REGION = process.env.SLS_REGION;
|
||||
const TASKER_PROJECT_TABLE_NAME = process.env.TASKER_PROJECT_TABLE_NAME || "";
|
||||
|
||||
const docClient = new DynamoDB.DocumentClient({ region: SLS_REGION });
|
||||
const client = new DynamoDBClient({ region: SLS_REGION });
|
||||
const docClient = DynamoDBDocument.from(client);
|
||||
|
||||
export const handler = async (event: any): Promise<any> => {
|
||||
const { name, description, startDate, endDate } = event.body;
|
||||
try {
|
||||
const newProject = {
|
||||
type: "projects",
|
||||
category: "projects",
|
||||
projectId: `project#${uuidv4()}`,
|
||||
name,
|
||||
description,
|
||||
@@ -18,12 +20,12 @@ export const handler = async (event: any): Promise<any> => {
|
||||
endDate,
|
||||
};
|
||||
|
||||
const params = {
|
||||
const params: PutCommandInput = {
|
||||
TableName: TASKER_PROJECT_TABLE_NAME,
|
||||
Item: newProject,
|
||||
};
|
||||
|
||||
await docClient.put(params).promise();
|
||||
await docClient.put(params);
|
||||
|
||||
return {
|
||||
status: 201,
|
||||
|
||||
Reference in New Issue
Block a user