From 61cdc9bca0bded7f7b174f8195c4e8ee71e95305 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 5 Aug 2020 14:12:44 -0700 Subject: [PATCH] add error message when S3 config is missing I figure we can get even better messages than "Access denied" in case this happens again! Also, I need a new deployment to trigger the new env vars, so why not make it count? :) --- api/uploadLayerImage.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/uploadLayerImage.js b/api/uploadLayerImage.js index 040e962..35a2fe4 100644 --- a/api/uploadLayerImage.js +++ b/api/uploadLayerImage.js @@ -3,6 +3,16 @@ const Jimp = require("jimp"); const connectToDb = require("../src/server/db.js"); +if ( + !process.env["DTI_AWS_ACCESS_KEY_ID"] || + !process.env["DTI_AWS_SECRET_ACCESS_KEY"] +) { + throw new Error( + `must provide DTI_AWS_ACCESS_KEY_ID and DTI_AWS_SECRET_ACCESS_KEY ` + + `environment variables` + ); +} + const s3 = new AWS.S3({ accessKeyId: process.env["DTI_AWS_ACCESS_KEY_ID"], secretAccessKey: process.env["DTI_AWS_SECRET_ACCESS_KEY"],