feat: Add new API handlers for user, project, and task management; update package dependencies

This commit is contained in:
2024-11-21 11:21:21 +02:00
parent 132f526179
commit 86c671ccd8
15 changed files with 1288 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import { DynamoDB } from "aws-sdk";
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 });
export const handler = async (event: any): Promise<any> => {
const { name, description, startDate, endDate } = event.body;
try {
const newProject = {
type: "projects",
projectId: `project#${uuidv4()}`,
name,
description,
startDate,
endDate,
};
const params = {
TableName: TASKER_PROJECT_TABLE_NAME,
Item: newProject,
};
await docClient.put(params).promise();
return {
status: 201,
body: JSON.stringify(newProject),
};
} catch (error: any) {
return {
status: 500,
body: JSON.stringify({
message: `Error creating project: ${error.message}`,
}),
};
}
};