Skip to content
Open
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: 13 additions & 9 deletions lib/stackops/apiGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const BbPromise = require('bluebird');
const utils = require('../utils');

const stageMethodConfigMappings = {
cacheDataEncrypted: { prop: 'CacheDataEncrypted', validate: _.isBoolean, default: false },
cacheDataEncrypted: { prop: 'CacheDataEncrypted', validate: _.isBoolean },
cacheTtlInSeconds: { prop: 'CacheTtlInSeconds', validate: _.isInteger },
cachingEnabled: { prop: 'CachingEnabled', validate: _.isBoolean, default: false },
dataTraceEnabled: { prop: 'DataTraceEnabled', validate: _.isBoolean, default: false },
loggingLevel: { prop: 'LoggingLevel', validate: value => _.includes([ 'OFF', 'INFO', 'ERROR' ], value), default: 'OFF' },
metricsEnabled: { prop: 'MetricsEnabled', validate: _.isBoolean, default: false },
cachingEnabled: { prop: 'CachingEnabled', validate: _.isBoolean },
dataTraceEnabled: { prop: 'DataTraceEnabled', validate: _.isBoolean },
loggingLevel: { prop: 'LoggingLevel', validate: value => _.includes([ 'OFF', 'INFO', 'ERROR' ], value) },
metricsEnabled: { prop: 'MetricsEnabled', validate: _.isBoolean },
throttlingBurstLimit: { prop: 'ThrottlingBurstLimit', validate: _.isInteger },
throttlingRateLimit: { prop: 'ThrottlingRateLimit', validate: _.isNumber }
};
Expand Down Expand Up @@ -79,7 +79,13 @@ const internal = {
const eventStageConfig = _.defaults({}, httpEvent.aliasStage, funcStageConfig);
if (!_.isEmpty(eventStageConfig)) {
const methodType = _.toUpper(httpEvent.method);
const methodSetting = {};
const methodSetting = {
CacheDataEncrypted: false,
CachingEnabled: false,
DataTraceEnabled: false,
LoggingLevel: 'OFF',
MetricsEnabled: false
};
const methods = methodType === 'ANY' ? [
'DELETE',
'GET',
Expand All @@ -96,9 +102,7 @@ const internal = {
} else if (!stageMethodConfigMappings[key].validate(value)) {
throw new this.serverless.classes.Error(`Invalid value for stage config '${key}: ${value}' at method '${methodType} /${httpEvent.path}'`);
}
if (!_.has(stageMethodConfigMappings[key], 'default') || stageMethodConfigMappings[key].default !== value) {
methodSetting[stageMethodConfigMappings[key].prop] = value;
}
methodSetting[stageMethodConfigMappings[key].prop] = value;
});
if (!_.isEmpty(methodSetting)) {
methodSetting.ResourcePath = '/' + _.replace('/' + _.trimStart(httpEvent.path, '/'), /\//g, '~1');
Expand Down