From 9a47e93ad67bd1a0ed5870b2a7340f87fdbcf52c Mon Sep 17 00:00:00 2001 From: JoshBaneyCS Date: Tue, 29 Apr 2025 01:19:36 +0000 Subject: [PATCH] Delete s3.js --- s3.js | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 s3.js diff --git a/s3.js b/s3.js deleted file mode 100644 index 8b7f136..0000000 --- a/s3.js +++ /dev/null @@ -1,30 +0,0 @@ -// s3.js -require('dotenv').config(); -const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3'); -const { stringify } = require('csv-stringify/sync'); - -const s3 = new S3Client({ - region: process.env.AWS_REGION -}); - -/** - * Uploads a CSV to s3:///trends/.csv with public-read ACL. - * @param {string} key Date key like '20250423' - * @param {Array} rows Array of DB rows to stringify into CSV - * @returns {string} Public URL of the uploaded CSV - */ -async function uploadTrendsCsv(key, rows) { - // Convert rows to CSV string (includes header) - const csv = stringify(rows, { header: true }); - const cmd = new PutObjectCommand({ - Bucket: process.env.S3_BUCKET_NAME, - Key: `trends/${key}.csv`, - Body: csv, - ContentType: 'text/csv', - ACL: 'public-read' - }); - await s3.send(cmd); - return `${process.env.S3_BASE_URL}/${key}.csv`; -} - -module.exports = { uploadTrendsCsv };