Skip to content

Commit 63e6a65

Browse files
committed
Allow to set AWS region
1 parent 262c619 commit 63e6a65

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const S3Notifier = require('fastboot-s3-notifier');
1313

1414
let notifier = new S3Notifier({
1515
bucket: S3_BUCKET,
16-
key: S3_KEY
16+
key: S3_KEY,
17+
region: AWS_REGION // optional
1718
});
1819

1920
let server = new FastBootAppServer({

index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ const AWS = require('aws-sdk');
44

55
const DEFAULT_POLL_TIME = 3 * 1000;
66

7-
const s3 = new AWS.S3({
8-
apiVersion: '2006-03-01',
9-
signatureVersion: 'v4'
10-
});
11-
127
class S3Notifier {
138
constructor(options) {
149
this.ui = options.ui;
@@ -20,6 +15,12 @@ class S3Notifier {
2015
Bucket: this.bucket,
2116
Key: this.key
2217
};
18+
19+
this.s3 = new AWS.S3({
20+
apiVersion: '2006-03-01',
21+
signatureVersion: 'v4',
22+
region: options.region
23+
});
2324
}
2425

2526
subscribe(notify) {
@@ -30,7 +31,7 @@ class S3Notifier {
3031
}
3132

3233
getCurrentLastModified() {
33-
return s3.headObject(this.params).promise()
34+
return this.s3.headObject(this.params).promise()
3435
.then(data => {
3536
this.lastModified = data.LastModified;
3637
})
@@ -46,7 +47,7 @@ class S3Notifier {
4647
}
4748

4849
poll() {
49-
s3.headObject(this.params).promise()
50+
this.s3.headObject(this.params).promise()
5051
.then(data => {
5152
this.compareLastModifieds(data.LastModified);
5253
this.schedulePoll();

0 commit comments

Comments
 (0)