feat: Update .gitignore, add Lambda layer configuration, and refactor DynamoDB handlers to use AWS SDK v3
This commit is contained in:
@@ -1,32 +1,34 @@
|
||||
import { fetchRandomTeamId } from "@/lib/util";
|
||||
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_USER_TABLE_NAME = process.env.TASKER_USER_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 { username, cognitoId, profilePictureUrl = "i0.jpg" } = event.body;
|
||||
const { username, cognitoId } = event.body;
|
||||
const teamId = fetchRandomTeamId();
|
||||
|
||||
try {
|
||||
const newUser = {
|
||||
type: "users",
|
||||
category: "users",
|
||||
cognitoId,
|
||||
userId: `user#${uuidv4()}`,
|
||||
username,
|
||||
profilePictureUrl,
|
||||
profilePictureUrl: "i0.jpg",
|
||||
teamId,
|
||||
};
|
||||
|
||||
const params = {
|
||||
const params: PutCommandInput = {
|
||||
TableName: TASKER_USER_TABLE_NAME,
|
||||
Item: newUser,
|
||||
};
|
||||
|
||||
await docClient.put(params).promise();
|
||||
await docClient.put(params);
|
||||
|
||||
return {
|
||||
status: 201,
|
||||
|
||||
Reference in New Issue
Block a user