forked from mtusi2026/mtusi2026lab6
chore: port lab5 solution as lab6 base
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
BucketAlreadyOwnedByYou,
|
||||
CreateBucketCommand,
|
||||
S3Client,
|
||||
} from '@aws-sdk/client-s3';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
export default async function globalSetup(): Promise<void> {
|
||||
execSync('npx prisma migrate deploy', { stdio: 'inherit' });
|
||||
const client = new S3Client({
|
||||
endpoint: process.env.S3_ENDPOINT,
|
||||
region: 'us-east-1',
|
||||
forcePathStyle: true,
|
||||
credentials: {
|
||||
accessKeyId: process.env.S3_ACCESS_KEY_ID!,
|
||||
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY!,
|
||||
},
|
||||
});
|
||||
try {
|
||||
await client.send(new CreateBucketCommand({ Bucket: process.env.S3_BUCKET! }));
|
||||
} catch (error) {
|
||||
if (!(error instanceof BucketAlreadyOwnedByYou)) {
|
||||
throw error;
|
||||
}
|
||||
} finally {
|
||||
client.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user