Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,28 @@ custom:
stageSettings:
CacheClusterEnabled: true
CacheClusterSize: '0.5'
TracingEnabled: Boolean
Variables:
foo: bar
baz: xyzzy
# MethodSettings:Use this to overwrite above global settings at each method level.
# Type: List of MethodSetting
MethodSettings:
LoggingLevel: INFO
CachingEnabled: true
CacheTtlInSeconds: 3600
# see below...
- CacheDataEncrypted: Boolean
CacheTtlInSeconds: Integer
CachingEnabled: Boolean
DataTraceEnabled: Boolean
HttpMethod: String
LoggingLevel: String
MetricsEnabled: Boolean
ResourcePath: String
ThrottlingBurstLimit: Integer
ThrottlingRateLimit: Double
...
- CacheDataEncrypted: Boolean
CacheTtlInSeconds: Integer
CachingEnabled: Boolean
...
#...
```

Expand Down
15 changes: 11 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,23 @@ module.exports = function (serverless) {
AccessLogSetting: stageSettings.AccessLogSetting || {},
CacheClusterEnabled: stageSettings.CacheClusterEnabled || false,
CacheClusterSize: stageSettings.CacheClusterSize || '0.5',
TracingEnabled: stageSettings.TracingEnabled || false,
ClientCertificateId: stageSettings.ClientCertificateId || undefined,
DocumentationVersion: stageSettings.DocumentationVersion || undefined,
MethodSettings: methodSettings.map((item) => (
_.defaults(
item || {},
{
DataTraceEnabled: true,
HttpMethod: '*',
ResourcePath: '/*',
MetricsEnabled: false
HttpMethod: stageSettings.HttpMethod || '*',
ResourcePath: stageSettings.ResourcePath || '/*',
CachingEnabled: stageSettings.CachingEnabled || false,
CacheDataEncrypted: stageSettings.CacheDataEncrypted || false,
CacheTtlInSeconds: stageSettings.CacheTtlInSeconds || undefined,
DataTraceEnabled: stageSettings.DataTraceEnabled || false,
LoggingLevel: stageSettings.LoggingLevel || 'OFF',
MetricsEnabled: stageSettings.MetricsEnabled || false,
ThrottlingBurstLimit: stageSettings.ThrottlingBurstLimit || undefined,
ThrottlingRateLimit: stageSettings.ThrottlingRateLimit || undefined
}
)
))
Expand Down
43 changes: 35 additions & 8 deletions test/spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('The `serverless-api-stage` plugin', function () {
AccessLogSetting: {},
CacheClusterEnabled: false,
CacheClusterSize: '0.5',
TracingEnabled: false,
ClientCertificateId: undefined,
DocumentationVersion: undefined,
DeploymentId: {
Expand All @@ -50,10 +51,16 @@ describe('The `serverless-api-stage` plugin', function () {
Variables: {},
MethodSettings: [
{
DataTraceEnabled: true,
HttpMethod: '*',
ResourcePath: '/*',
MetricsEnabled: false
CachingEnabled: false,
CacheDataEncrypted: false,
CacheTtlInSeconds: undefined,
DataTraceEnabled: false,
LoggingLevel: 'OFF',
MetricsEnabled: false,
ThrottlingBurstLimit: undefined,
ThrottlingRateLimit: undefined
}
]
}
Expand All @@ -77,6 +84,7 @@ describe('The `serverless-api-stage` plugin', function () {
},
CacheClusterEnabled: true,
CacheClusterSize: '1.0',
TracingEnabled: true,
ClientCertificateId: undefined,
DocumentationVersion: undefined,
Variables: {
Expand All @@ -87,7 +95,8 @@ describe('The `serverless-api-stage` plugin', function () {
MetricsEnabled: true,
HttpMethod: 'GET',
CacheTtlInSeconds: 3600,
CachingEnabled: true
CachingEnabled: true,
DataTraceEnabled: true
}
});
pluginInstance = new ApiStagePlugin(serverless);
Expand Down Expand Up @@ -194,6 +203,7 @@ describe('The `serverless-api-stage` plugin', function () {
},
CacheClusterEnabled: true,
CacheClusterSize: '1.0',
TracingEnabled: true,
ClientCertificateId: undefined,
DocumentationVersion: undefined,
DeploymentId: {
Expand All @@ -207,10 +217,13 @@ describe('The `serverless-api-stage` plugin', function () {
LoggingLevel: 'INFO',
CacheTtlInSeconds: 3600,
CachingEnabled: true,
CacheDataEncrypted: false,
DataTraceEnabled: true,
HttpMethod: 'GET',
ResourcePath: '/*',
MetricsEnabled: true
MetricsEnabled: true,
ThrottlingBurstLimit: undefined,
ThrottlingRateLimit: undefined
}
]
}
Expand Down Expand Up @@ -331,6 +344,7 @@ describe('The `serverless-api-stage` plugin', function () {
AccessLogSetting: {},
CacheClusterEnabled: false,
CacheClusterSize: '0.5',
TracingEnabled: false,
DeploymentId: {
Ref: 'Deployment'
},
Expand All @@ -339,10 +353,16 @@ describe('The `serverless-api-stage` plugin', function () {
Variables: {},
MethodSettings: [
{
DataTraceEnabled: true,
HttpMethod: '*',
ResourcePath: '/*',
MetricsEnabled: false
CachingEnabled: false,
CacheDataEncrypted: false,
CacheTtlInSeconds: undefined,
DataTraceEnabled: false,
LoggingLevel: 'OFF',
MetricsEnabled: false,
ThrottlingBurstLimit: undefined,
ThrottlingRateLimit: undefined
}
]
}
Expand Down Expand Up @@ -463,6 +483,7 @@ describe('The `serverless-api-stage` plugin', function () {
AccessLogSetting: {},
CacheClusterEnabled: false,
CacheClusterSize: '0.5',
TracingEnabled: false,
DeploymentId: {
Ref: 'Deployment'
},
Expand All @@ -471,10 +492,16 @@ describe('The `serverless-api-stage` plugin', function () {
Variables: {},
MethodSettings: [
{
DataTraceEnabled: true,
HttpMethod: '*',
ResourcePath: '/*',
MetricsEnabled: false
CachingEnabled: false,
CacheDataEncrypted: false,
CacheTtlInSeconds: undefined,
DataTraceEnabled: false,
LoggingLevel: 'OFF',
MetricsEnabled: false,
ThrottlingBurstLimit: undefined,
ThrottlingRateLimit: undefined
}
]
}
Expand Down