-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paths3.ts
More file actions
29 lines (25 loc) · 855 Bytes
/
s3.ts
File metadata and controls
29 lines (25 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Express } from 'express';
import { createApp, S3Bucket } from '../src';
import { S3Client } from '@aws-sdk/client-s3';
/**
* This simple example shows how to add a seshat endpoint
* serving a s3 bucket to an existing express app.
*
* In this specific example, we are serving the "my-s3-bucket" bucket
* present in the minio setup running in docker (see docker-compose.yaml)
*/
export default (expressApp: Express) => {
expressApp.use('/s3', createApp({
bucket: new S3Bucket({ s3client, bucket: 'my-s3-bucket' }),
}));
};
/** Exposing the s3 client so that other examples can reuse it */
export const s3client = new S3Client({
region: 'eu-west1',
credentials: {
accessKeyId: 'access-key',
secretAccessKey: 'secret-key',
},
endpoint: process.env.S3_ENDPOINT || 'http://127.0.0.1:9000',
forcePathStyle: true,
});