mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
s3 setup
This commit is contained in:
23
packages/backend/src/s3.ts
Normal file
23
packages/backend/src/s3.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { S3Client } from "@aws-sdk/client-s3";
|
||||
|
||||
const s3Endpoint = process.env.S3_ENDPOINT;
|
||||
const s3AccessKeyId = process.env.S3_ACCESS_KEY_ID;
|
||||
const s3SecretAccessKey = process.env.S3_SECRET_ACCESS_KEY;
|
||||
const s3BucketName = process.env.S3_BUCKET_NAME;
|
||||
const s3PublicUrl = process.env.S3_PUBLIC_URL;
|
||||
|
||||
if (!s3Endpoint || !s3AccessKeyId || !s3SecretAccessKey || !s3BucketName) {
|
||||
throw new Error("missing required S3 environment variables");
|
||||
}
|
||||
|
||||
export const s3Client = new S3Client({
|
||||
endpoint: s3Endpoint,
|
||||
region: "auto",
|
||||
credentials: {
|
||||
accessKeyId: s3AccessKeyId,
|
||||
secretAccessKey: s3SecretAccessKey,
|
||||
},
|
||||
});
|
||||
|
||||
export const bucketName = s3BucketName;
|
||||
export { s3Endpoint, s3PublicUrl };
|
||||
Reference in New Issue
Block a user