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? :)
This commit is contained in:
Emi Matchu 2020-08-05 14:12:44 -07:00
parent 197dfd4e11
commit 61cdc9bca0

View file

@ -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"],