image processing lambda

This commit is contained in:
jackiettran
2026-01-14 12:11:50 -05:00
parent f5fdcbfb82
commit da82872297
15 changed files with 8090 additions and 17 deletions

View File

@@ -0,0 +1,59 @@
/**
* Local testing script for the image processor lambda.
*
* Usage:
* npm run local -- <stagingKey> [bucket]
*
* Example:
* npm run local -- staging/items/test-image.jpg my-bucket
*
* Note: Requires .env.dev file with DATABASE_URL and AWS credentials configured.
*/
const { handler } = require("./index");
async function main() {
// Filter out dotenv config args from process.argv
const args = process.argv.slice(2).filter(arg => !arg.startsWith("dotenv_config_path"));
// Get staging key from command line args
const stagingKey = args[0] || "staging/items/test-image.jpg";
const bucket = args[1] || process.env.S3_BUCKET;
console.log("Testing image processor lambda locally...");
console.log(`Bucket: ${bucket}`);
console.log(`Staging Key: ${stagingKey}`);
console.log("---");
// Simulate S3 event
const event = {
Records: [
{
eventSource: "aws:s3",
eventName: "ObjectCreated:Put",
s3: {
bucket: {
name: bucket,
},
object: {
key: stagingKey,
},
},
},
],
};
console.log("Event:", JSON.stringify(event, null, 2));
console.log("---");
try {
const result = await handler(event);
console.log("Result:", JSON.stringify(result, null, 2));
process.exit(0);
} catch (error) {
console.error("Error:", error);
process.exit(1);
}
}
main();