Skip to content

Commit ff3f89d

Browse files
feat: add s3 proxy to index
1 parent 923b40d commit ff3f89d

File tree

5 files changed

+79
-5
lines changed

5 files changed

+79
-5
lines changed

lib/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ const compileMethodsToSqs = require('./package/sqs/compileMethodsToSqs')
2121
const compileIamRoleToSqs = require('./package/sqs/compileIamRoleToSqs')
2222
const validateSqsServiceProxy = require('./package/sqs/validateSqsServiceProxy')
2323
const compileSqsServiceProxy = require('./package/sqs/compileSqsServiceProxy')
24+
// S3
25+
const compileMethodsToS3 = require('./package/s3/compileMethodsToS3')
26+
const compileIamRoleToS3 = require('./package/s3/compileIamRoleToS3')
27+
const validateS3ServiceProxy = require('./package/s3/validateS3ServiceProxy')
28+
const compileS3ServiceProxy = require('./package/s3/compileS3ServiceProxy')
2429

2530
class ServerlessApigatewayServiceProxy {
2631
constructor(serverless, options) {
@@ -45,6 +50,10 @@ class ServerlessApigatewayServiceProxy {
4550
compileIamRoleToSqs,
4651
compileSqsServiceProxy,
4752
validateSqsServiceProxy,
53+
compileMethodsToS3,
54+
compileIamRoleToS3,
55+
compileS3ServiceProxy,
56+
validateS3ServiceProxy,
4857
getStackInfo,
4958
validate,
5059
methods,
@@ -66,6 +75,9 @@ class ServerlessApigatewayServiceProxy {
6675
// SQS getProxy
6776
await this.compileSqsServiceProxy()
6877

78+
// S3 getProxy
79+
await this.compileS3ServiceProxy()
80+
6981
await this.mergeDeployment()
7082
}
7183
},

lib/index.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ describe('#index()', () => {
6464
path: '/sqs',
6565
method: 'post'
6666
}
67+
},
68+
{
69+
s3: {
70+
path: '/s3',
71+
method: 'post'
72+
}
6773
}
6874
]
6975
}
@@ -86,6 +92,9 @@ describe('#index()', () => {
8692
const compileSqsServiceProxyStub = sinon
8793
.stub(serverlessApigatewayServiceProxy, 'compileSqsServiceProxy')
8894
.returns(BbPromise.resolve())
95+
const compileS3ServiceProxyStub = sinon
96+
.stub(serverlessApigatewayServiceProxy, 'compileS3ServiceProxy')
97+
.returns(BbPromise.resolve())
8998
const mergeDeploymentStub = sinon
9099
.stub(serverlessApigatewayServiceProxy, 'mergeDeployment')
91100
.returns(BbPromise.resolve())
@@ -99,6 +108,7 @@ describe('#index()', () => {
99108
expect(compileCorsStub.calledOnce).to.be.equal(true)
100109
expect(compileKinesisServiceProxyStub.calledOnce).to.be.equal(true)
101110
expect(compileSqsServiceProxyStub.calledOnce).to.be.equal(true)
111+
expect(compileS3ServiceProxyStub.calledOnce).to.be.equal(true)
102112
expect(mergeDeploymentStub.calledOnce).to.be.equal(true)
103113
})
104114

@@ -108,6 +118,7 @@ describe('#index()', () => {
108118
serverlessApigatewayServiceProxy.compileCors.restore()
109119
serverlessApigatewayServiceProxy.compileKinesisServiceProxy.restore()
110120
serverlessApigatewayServiceProxy.compileSqsServiceProxy.restore()
121+
serverlessApigatewayServiceProxy.compileS3ServiceProxy.restore()
111122
serverlessApigatewayServiceProxy.mergeDeployment.restore()
112123
})
113124

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict'
2+
3+
module.exports = {
4+
async compileS3ServiceProxy() {
5+
this.validateS3ServiceProxy()
6+
this.compileIamRoleToS3()
7+
this.compileMethodsToS3()
8+
}
9+
}

package-lock.json

Lines changed: 46 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
]
1818
},
1919
"dependencies": {
20+
"@hapi/joi": "^15.1.0",
2021
"serverless": "^1.48.2"
2122
},
2223
"author": "horike37",

0 commit comments

Comments
 (0)