This commit is contained in:
Oliver Bryan
2026-01-01 06:56:35 +00:00
parent 44fe15cf9d
commit 54a32676b4
4 changed files with 240 additions and 1 deletions

View File

@@ -3,4 +3,10 @@ DATABASE_URL=postgres://eussi:password@localhost:5432/issue
# comma separated list of allowed origins
CORS_ORIGIN=http://localhost:1420
JWT_SECRET=TOP_SECRET_JWT_MUST_CHANGE
JWT_SECRET=TOP_SECRET_JWT_MUST_CHANGE
S3_PUBLIC_URL=https://issuebucket.ob248.com
S3_ENDPOINT=https://account_id.r2.cloudflarestorage.com/issue
S3_ACCESS_KEY_ID=your_access_key_id
S3_SECRET_ACCESS_KEY=your_secret_access_key
S3_BUCKET_NAME=issue

View File

@@ -22,6 +22,7 @@
"typescript": "^5"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.958.0",
"@issue/shared": "workspace:*",
"bcrypt": "^6.0.0",
"dotenv": "^17.2.3",

View 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 };