Skip to content

Commit acd1cb4

Browse files
committed
feat: added dynamic path override functionality
1 parent 0b8c5f1 commit acd1cb4

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

lib/apiGateway/schema.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,14 @@ const roleArn = stringOrGetAtt('roleArn', 'Arn')
9191

9292
const acceptParameters = Joi.object().pattern(Joi.string(), Joi.boolean().required())
9393

94+
/**
95+
* Changes for dynamic Path Override
96+
*/
97+
const pathoverride = Joi.string()
98+
9499
const proxy = Joi.object({
95100
path,
101+
pathoverride,
96102
method,
97103
cors,
98104
authorizationType,

lib/package/s3/compileMethodsToS3.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,21 @@ module.exports = {
142142
'Fn::GetAtt': ['ApigatewayToS3Role', 'Arn']
143143
}
144144

145+
/**
146+
* Dynamic Path Override
147+
*/
148+
let pather = '{bucket}/{object}'
149+
150+
if (_.has(http, 'pathoverride')) {
151+
pather = '{bucket}/' + http.pathoverride
152+
}
153+
145154
const integration = {
146155
IntegrationHttpMethod: httpMethod,
147156
Type: 'AWS',
148157
Credentials: roleArn,
149158
Uri: {
150-
'Fn::Sub': ['arn:aws:apigateway:${AWS::Region}:s3:path/{bucket}/{object}', {}]
159+
'Fn::Sub': ['arn:aws:apigateway:${AWS::Region}:s3:path/' + pather, {}]
151160
},
152161
PassthroughBehavior: 'WHEN_NO_MATCH',
153162
RequestParameters: _.merge(requestParams, http.requestParameters)

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "serverless-apigateway-service-proxy",
3-
"version": "1.3.0",
4-
"description": "The Serverless Framewrok plugin for supporting AWS service proxy integration of API Gateway",
2+
"name": "@hans_seek/serverless-apigateway-service-proxy",
3+
"version": "1.3.1",
4+
"description": "This is a fork of https://www.npmjs.com/package/serverless-apigateway-service-proxy. The Serverless Framewrok plugin for supporting AWS service proxy integration of API Gateway",
55
"main": "lib/index.js",
66
"scripts": {
77
"lint": "eslint .",
@@ -31,7 +31,7 @@
3131
"<rootDir>/__tests__/setup-tests.js"
3232
]
3333
},
34-
"author": "horike37",
34+
"author": "Hans Roessler",
3535
"license": "MIT",
3636
"devDependencies": {
3737
"@commitlint/cli": "^8.1.0",
@@ -61,6 +61,6 @@
6161
},
6262
"repository": {
6363
"type": "git",
64-
"url": "https://github.com/horike37/serverless-apigateway-service-proxy.git"
64+
"url": "https://github.com/Hans-Seek/serverless-apigateway-service-proxy.git"
6565
}
6666
}

0 commit comments

Comments
 (0)