Comparing version 1.3.0 to 1.3.1
23
index.js
@@ -23,11 +23,11 @@ /* jslint node: true, esversion: 6 */ | ||
this.bucket = p.bucket; | ||
this.options = | ||
Object.getOwnPropertyNames(p) | ||
.filter(name => name !== 'bucket') | ||
.reduce((obj, name) => { | ||
const withName = {}; | ||
withName[name] = p[name]; | ||
return Object.assign({}, obj, withName); | ||
}, {}); | ||
this.options = Object.getOwnPropertyNames(p) | ||
.filter(name => name !== 'bucket') | ||
.reduce((obj, name) => { | ||
const withName = {}; | ||
withName[name] = p[name]; | ||
return Object.assign({}, obj, withName); | ||
}, {}); | ||
} | ||
init(done) { | ||
@@ -42,2 +42,3 @@ this.s3 = new AWS.S3(Object.assign({ apiVersion: '2006-03-01' }, this.options)); | ||
} | ||
createReadStream(key) { | ||
@@ -58,2 +59,3 @@ this.isInitialized(); | ||
} | ||
isInitialized() { | ||
@@ -65,5 +67,7 @@ if (!this.s3) { | ||
} | ||
static stripLeadingSlash(str) { | ||
return str.replace(/^\/+/, ''); | ||
} | ||
healthCheck(done) { | ||
@@ -75,2 +79,3 @@ const s3request = this.s3.headBucket({ Bucket: this.bucket }, (error, data) => { | ||
} | ||
healthCheckStream(res) { | ||
@@ -85,2 +90,3 @@ const s3request = this.s3.headBucket({ Bucket: this.bucket }); | ||
} | ||
head(req, res) { | ||
@@ -91,2 +97,3 @@ const stream = this.createReadStream(req.url); | ||
} | ||
get(req, res) { | ||
@@ -93,0 +100,0 @@ const stream = this.createReadStream(req.url); |
{ | ||
"name": "s3proxy", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Streaming web proxy for AWS S3", | ||
"main": "index.js", | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"chai-http": "^3.0.0", | ||
"eslint": "^4.7.0", | ||
"eslint-config-airbnb-base": "^12.0.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"express": "^4.15.4", | ||
"express-request-id": "^1.4.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.5.3", | ||
"morgan": "^1.9.0" | ||
"chai": "^4.2.0", | ||
"chai-http": "^4.3.0", | ||
"eslint": "^6.0.1", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.18.0", | ||
"express": "^4.17.1", | ||
"express-request-id": "^1.4.1", | ||
"mocha": "^6.1.4", | ||
"morgan": "^1.9.1", | ||
"nyc": "^14.1.1" | ||
}, | ||
"dependencies": { | ||
"aws-sdk": "^2.118.0" | ||
"aws-sdk": "^2.484.0", | ||
"istanbul": "^0.4.5" | ||
}, | ||
"scripts": { | ||
"test": "make -j test", | ||
"istanbul": "istanbul", | ||
"nyc-coverage": "nyc --reporter=html --reporter=text", | ||
"mocha": "mocha" | ||
@@ -25,0 +26,0 @@ }, |
@@ -130,6 +130,31 @@ # s3proxy | ||
## init method | ||
S3Proxy is a subclass of EventEmitter. That means you can register event listeners on the async calls. | ||
``` | ||
proxy.on('init', () => { | ||
app.listen(); | ||
}); | ||
proxy.on('error', (error) => { | ||
console.error(error); | ||
}); | ||
proxy.init(); | ||
``` | ||
`init` also accepts a callback function: | ||
``` | ||
proxy.init((error) => { | ||
if (error) { | ||
console.error(error); | ||
} | ||
else { | ||
app.listen(); | ||
} | ||
}); | ||
``` | ||
## Development | ||
### Test execution | ||
The current test suite consists of some unit tests, but most of the tests are functional tests that require AWS S3 acces. | ||
It uses a pubic bucket called s3proxy-public. | ||
The current test suite consists of some unit tests, but most of the tests are functional tests that require AWS S3 access. | ||
It uses a public bucket called s3proxy-public. | ||
@@ -136,0 +161,0 @@ ``` |
20039
168
2
86
+ Addedistanbul@^0.4.5
+ Addedabbrev@1.0.9(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedasync@1.5.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addedescodegen@1.8.1(transitive)
+ Addedesprima@2.7.34.0.1(transitive)
+ Addedestraverse@1.9.3(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedfast-levenshtein@2.0.6(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedhandlebars@4.7.8(transitive)
+ Addedhas-flag@1.0.0(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedistanbul@0.4.5(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedlevn@0.3.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addednopt@3.0.6(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedoptionator@0.8.3(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprelude-ls@1.1.2(transitive)
+ Addedresolve@1.1.7(transitive)
+ Addedsource-map@0.2.00.6.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedsupports-color@3.2.3(transitive)
+ Addedtype-check@0.3.2(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedword-wrap@1.2.5(transitive)
+ Addedwordwrap@1.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
Updatedaws-sdk@^2.484.0