mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
s3 setup
This commit is contained in:
@@ -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
|
||||
@@ -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",
|
||||
|
||||
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