Skip to content

Commit 5861b75

Browse files
authored
Merge pull request #12 from andreafalzetti/fix/older-sls-version
fix: make configSchemaHandler optional
2 parents e3bf676 + 3c99b49 commit 5861b75

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

index.js

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,38 +62,34 @@ class ServerlessLambdaEdgePreExistingCloudFront {
6262
}
6363
}
6464

65-
this.serverless.configSchemaHandler.defineCustomProperties({
66-
type: 'object',
67-
properties: {
68-
lambdaEdgePreExistingCloudFront: {
69-
type: 'object',
70-
properties: {
71-
validStages: {
72-
type: 'array',
73-
items: { type: 'string' },
74-
uniqueItems: true
65+
if (this.serverless.configSchemaHandler) {
66+
this.serverless.configSchemaHandler.defineCustomProperties({
67+
type: 'object',
68+
properties: {
69+
lambdaEdgePreExistingCloudFront: {
70+
type: 'object',
71+
properties: {
72+
validStages: {
73+
type: 'array',
74+
items: { type: 'string' },
75+
uniqueItems: true
76+
}
7577
}
7678
}
79+
}
80+
})
81+
82+
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'preExistingCloudFront', {
83+
type: 'object',
84+
properties: {
85+
distributionId: { type: 'string' },
86+
eventType: { type: 'string' },
87+
pathPattern: { type: 'string' },
88+
includeBody: { type: 'boolean' }
7789
},
78-
}
79-
})
80-
81-
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'preExistingCloudFront', {
82-
type: 'object',
83-
properties: {
84-
distributionId: { type: 'string' },
85-
eventType: { type: 'string' },
86-
pathPattern: { type: 'string' },
87-
includeBody: { type: 'boolean' }
88-
},
89-
required: [
90-
'distributionId',
91-
'eventType',
92-
'pathPattern',
93-
'includeBody'
94-
]
95-
})
96-
90+
required: ['distributionId', 'eventType', 'pathPattern', 'includeBody']
91+
})
92+
}
9793
}
9894

9995
checkAllowedDeployStage() {
@@ -162,7 +158,6 @@ class ServerlessLambdaEdgePreExistingCloudFront {
162158
})
163159
return arn
164160
}
165-
166161
}
167162

168163
module.exports = ServerlessLambdaEdgePreExistingCloudFront

0 commit comments

Comments
 (0)