text changes and remove infra folder

This commit is contained in:
jackiettran
2026-01-21 19:00:55 -05:00
parent 23ca97cea9
commit 420e0efeb4
39 changed files with 1170 additions and 3640 deletions

View File

@@ -14,7 +14,7 @@ let schedulerClient = null;
function getSchedulerClient() {
if (!schedulerClient) {
schedulerClient = new SchedulerClient({
region: process.env.AWS_REGION || "us-east-1",
region: process.env.AWS_REGION,
});
}
return schedulerClient;
@@ -34,7 +34,7 @@ async function deleteSchedule(scheduleName) {
new DeleteScheduleCommand({
Name: scheduleName,
GroupName: groupName,
})
}),
);
logger.info("Deleted schedule after execution", {
@@ -74,7 +74,9 @@ function getEmailContent(checkType, rental) {
title: "Rental Start Condition Check",
message: `Please take photos when you receive "${itemName}" to document its condition. This protects you in case of any disputes.`,
deadline: email.formatEmailDate(
new Date(new Date(rental.startDateTime).getTime() + 24 * 60 * 60 * 1000)
new Date(
new Date(rental.startDateTime).getTime() + 24 * 60 * 60 * 1000,
),
),
},
rental_end_renter: {
@@ -90,7 +92,7 @@ function getEmailContent(checkType, rental) {
title: "Post-Rental Condition Check",
message: `Please take photos and mark the return status for "${itemName}". This completes the rental process.`,
deadline: email.formatEmailDate(
new Date(new Date(rental.endDateTime).getTime() + 48 * 60 * 60 * 1000)
new Date(new Date(rental.endDateTime).getTime() + 48 * 60 * 60 * 1000),
),
},
};
@@ -162,7 +164,7 @@ async function processReminder(rentalId, checkType, scheduleName) {
const templatePath = path.join(
__dirname,
"templates",
"conditionCheckReminderToUser.html"
"conditionCheckReminderToUser.html",
);
const template = await email.loadTemplate(templatePath);
@@ -178,7 +180,7 @@ async function processReminder(rentalId, checkType, scheduleName) {
const result = await email.sendEmail(
emailContent.recipient.email,
emailContent.subject,
htmlBody
htmlBody,
);
if (!result.success) {

View File

@@ -11,7 +11,7 @@ let sesClient = null;
function getSESClient() {
if (!sesClient) {
sesClient = new SESClient({
region: process.env.AWS_REGION || "us-east-1",
region: process.env.AWS_REGION,
});
}
return sesClient;
@@ -69,12 +69,14 @@ async function loadTemplate(templatePath) {
try {
return await fs.readFile(templatePath, "utf-8");
} catch (error) {
console.error(JSON.stringify({
level: "error",
message: "Failed to load email template",
templatePath,
error: error.message,
}));
console.error(
JSON.stringify({
level: "error",
message: "Failed to load email template",
templatePath,
error: error.message,
}),
);
throw error;
}
}
@@ -90,12 +92,14 @@ async function loadTemplate(templatePath) {
async function sendEmail(to, subject, htmlBody, textBody = null) {
// Check if email sending is enabled
if (process.env.EMAIL_ENABLED !== "true") {
console.log(JSON.stringify({
level: "info",
message: "Email sending disabled, skipping",
to,
subject,
}));
console.log(
JSON.stringify({
level: "info",
message: "Email sending disabled, skipping",
to,
subject,
}),
);
return { success: true, messageId: "disabled" };
}
@@ -146,23 +150,27 @@ async function sendEmail(to, subject, htmlBody, textBody = null) {
const command = new SendEmailCommand(params);
const result = await client.send(command);
console.log(JSON.stringify({
level: "info",
message: "Email sent successfully",
to,
subject,
messageId: result.MessageId,
}));
console.log(
JSON.stringify({
level: "info",
message: "Email sent successfully",
to,
subject,
messageId: result.MessageId,
}),
);
return { success: true, messageId: result.MessageId };
} catch (error) {
console.error(JSON.stringify({
level: "error",
message: "Failed to send email",
to,
subject,
error: error.message,
}));
console.error(
JSON.stringify({
level: "error",
message: "Failed to send email",
to,
subject,
error: error.message,
}),
);
return { success: false, error: error.message };
}