Skip to content

Commit

Permalink
Merge pull request #2 from bobisjan/aws-region
Browse files Browse the repository at this point in the history
Allow to set AWS region
  • Loading branch information
tomdale authored Jun 27, 2017
2 parents 262c619 + 63e6a65 commit 6dafdf1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const S3Notifier = require('fastboot-s3-notifier');

let notifier = new S3Notifier({
bucket: S3_BUCKET,
key: S3_KEY
key: S3_KEY,
region: AWS_REGION // optional
});

let server = new FastBootAppServer({
Expand Down
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ const AWS = require('aws-sdk');

const DEFAULT_POLL_TIME = 3 * 1000;

const s3 = new AWS.S3({
apiVersion: '2006-03-01',
signatureVersion: 'v4'
});

class S3Notifier {
constructor(options) {
this.ui = options.ui;
Expand All @@ -20,6 +15,12 @@ class S3Notifier {
Bucket: this.bucket,
Key: this.key
};

this.s3 = new AWS.S3({
apiVersion: '2006-03-01',
signatureVersion: 'v4',
region: options.region
});
}

subscribe(notify) {
Expand All @@ -30,7 +31,7 @@ class S3Notifier {
}

getCurrentLastModified() {
return s3.headObject(this.params).promise()
return this.s3.headObject(this.params).promise()
.then(data => {
this.lastModified = data.LastModified;
})
Expand All @@ -46,7 +47,7 @@ class S3Notifier {
}

poll() {
s3.headObject(this.params).promise()
this.s3.headObject(this.params).promise()
.then(data => {
this.compareLastModifieds(data.LastModified);
this.schedulePoll();
Expand Down

0 comments on commit 6dafdf1

Please sign in to comment.