Skip to content

Commit

Permalink
feat: add aws endpoint support, support aws naming conventions
Browse files Browse the repository at this point in the history
resolves #29
  • Loading branch information
jasonraimondi committed Mar 13, 2024
1 parent 813d05b commit 3c4cc29
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ const imageStorageService = {

switch (process.env.STORAGE_PROVIDER) {
case "s3":
const accessKeyId = process.env.AWS_ACCESS_KEY_ID ?? process.env.AWS_ACCESS_KEY;
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY ?? process.env.AWS_SECRET_KEY;
const region = process.env.AWS_DEFAULT_REGION ?? process.env.AWS_REGION;

imageStorage = new AmazonS3StorageProvider(
new S3Client({
region: process.env.AWS_REGION,
region,
endpoint: process.env.AWS_ENDPOINT_URL_S3,
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_KEY,
accessKeyId,
secretAccessKey,
},
}),
process.env.AWS_BUCKET,
Expand Down
13 changes: 13 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify
import { ApplicationModule } from "./app.module";
import { winstonLogger } from "./winston-logger";


if (process.env.AWS_ACCESS_KEY) {
console.warn("AWS_ACCESS_KEY is deprecated, please use AWS_ACCESS_KEY_ID");
}

if (process.env.AWS_SECRET_KEY) {
console.warn("AWS_SECRET_KEY is deprecated, please use AWS_SECRET_ACCESS_KEY");
}

if (process.env.AWS_REGION) {
console.warn("AWS_REGION is deprecated, please use AWS_DEFAULT_REGION");
}

async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(ApplicationModule, new FastifyAdapter(), {
logger: winstonLogger,
Expand Down

0 comments on commit 3c4cc29

Please sign in to comment.