File tree Expand file tree Collapse file tree 6 files changed +23
-15
lines changed
lib/deploy/events/apiGateway Expand file tree Collapse file tree 6 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ const BbPromise = require('bluebird');
55
66module . exports = {
77 compileApiKeys ( ) {
8- if ( this . serverless . service . provider . apiKeys ) {
9- if ( ! Array . isArray ( this . serverless . service . provider . apiKeys ) ) {
8+ const apiKeys = _ . get ( this . serverless . service . provider . apiGateway , 'apiKeys' )
9+ || this . serverless . service . provider . apiKeys ;
10+ if ( apiKeys ) {
11+ if ( ! Array . isArray ( apiKeys ) ) {
1012 throw new this . serverless . classes . Error ( 'apiKeys property must be an array' ) ;
1113 }
1214
13- _ . forEach ( this . serverless . service . provider . apiKeys , ( apiKey , i ) => {
15+ _ . forEach ( apiKeys , ( apiKey , i ) => {
1416 const apiKeyNumber = i + 1 ;
1517
1618 if ( typeof apiKey !== 'string' ) {
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ describe('#methods()', () => {
1616 region : 'us-east-1' ,
1717 } ;
1818 serverless . setProvider ( 'aws' , new AwsProvider ( serverless ) ) ;
19- serverless . service . provider . apiKeys = [ '1234567890' ] ;
19+ if ( ! serverless . service . provider . apiGateway ) serverless . service . provider . apiGateway = { } ;
20+ serverless . service . provider . apiGateway . apiKeys = [ '1234567890' ] ;
2021 serverless . service . provider . compiledCloudFormationTemplate = {
2122 Resources : { } ,
2223 } ;
@@ -79,12 +80,12 @@ describe('#methods()', () => {
7980 } ) ) ;
8081
8182 it ( 'throw error if apiKey property is not an array' , ( ) => {
82- serverlessStepFunctions . serverless . service . provider . apiKeys = 2 ;
83+ serverlessStepFunctions . serverless . service . provider . apiGateway . apiKeys = 2 ;
8384 expect ( ( ) => serverlessStepFunctions . compileApiKeys ( ) ) . to . throw ( Error ) ;
8485 } ) ;
8586
8687 it ( 'throw error if an apiKey is not a string' , ( ) => {
87- serverlessStepFunctions . serverless . service . provider . apiKeys = [ 2 ] ;
88+ serverlessStepFunctions . serverless . service . provider . apiGateway . apiKeys = [ 2 ] ;
8889 expect ( ( ) => serverlessStepFunctions . compileApiKeys ( ) ) . to . throw ( Error ) ;
8990 } ) ;
9091} ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ const BbPromise = require('bluebird');
55
66module . exports = {
77 compileUsagePlan ( ) {
8- if ( this . serverless . service . provider . usagePlan || this . serverless . service . provider . apiKeys ) {
8+ if ( this . serverless . service . provider . usagePlan
9+ || _ . get ( this . serverless . service . provider . apiGateway , 'apiKeys' )
10+ || this . serverless . service . provider . apiKeys ) {
911 this . apiGatewayUsagePlanLogicalId = this . provider . naming . getUsagePlanLogicalId ( ) ;
1012 _ . merge ( this . serverless . service . provider . compiledCloudFormationTemplate . Resources , {
1113 [ this . apiGatewayUsagePlanLogicalId ] : {
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ describe('#compileUsagePlan()', () => {
1717 } ;
1818 serverless . service . service = 'first-service' ;
1919 serverless . setProvider ( 'aws' , new AwsProvider ( serverless ) ) ;
20- serverless . service . provider . apiKeys = [ '1234567890' ] ;
20+ if ( ! serverless . service . provider . apiGateway ) serverless . service . provider . apiGateway = { } ;
21+ serverless . service . provider . apiGateway . apiKeys = [ '1234567890' ] ;
2122 serverless . service . provider . compiledCloudFormationTemplate = {
2223 Resources : { } ,
2324 } ;
@@ -36,7 +37,7 @@ describe('#compileUsagePlan()', () => {
3637 } ) ;
3738
3839 it ( 'should compile default usage plan resource' , ( ) => {
39- serverless . service . provider . apiKeys = [ '1234567890' ] ;
40+ serverless . service . provider . apiGateway . apiKeys = [ '1234567890' ] ;
4041 return serverlessStepFunctions . compileUsagePlan ( ) . then ( ( ) => {
4142 expect (
4243 serverlessStepFunctions . serverless . service . provider . compiledCloudFormationTemplate
Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ const BbPromise = require('bluebird');
55
66module . exports = {
77 compileUsagePlanKeys ( ) {
8- if ( this . serverless . service . provider . apiKeys ) {
9- if ( ! Array . isArray ( this . serverless . service . provider . apiKeys ) ) {
8+ const apiKeys = _ . get ( this . serverless . service . provider . apiGateway , 'apiKeys' )
9+ || this . serverless . service . provider . apiKeys ;
10+ if ( apiKeys ) {
11+ if ( ! Array . isArray ( apiKeys ) ) {
1012 throw new this . serverless . classes . Error ( 'apiKeys property must be an array' ) ;
1113 }
1214
13- _ . forEach ( this . serverless . service . provider . apiKeys , ( apiKey , i ) => {
15+ _ . forEach ( apiKeys , ( apiKey , i ) => {
1416 const usagePlanKeyNumber = i + 1 ;
1517
1618 if ( typeof apiKey !== 'string' ) {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ describe('#compileUsagePlanKeys()', () => {
1919 serverless . service . service = 'first-service' ;
2020 serverless . service . provider = {
2121 name : 'aws' ,
22- apiKeys : [ '1234567890' ] ,
22+ apiGateway : { apiKeys : [ '1234567890' ] } ,
2323 } ;
2424 serverless . service . provider . compiledCloudFormationTemplate = {
2525 Resources : { } ,
@@ -66,12 +66,12 @@ describe('#compileUsagePlanKeys()', () => {
6666 } ) ) ;
6767
6868 it ( 'throw error if apiKey property is not an array' , ( ) => {
69- serverlessStepFunctions . serverless . service . provider . apiKeys = 2 ;
69+ serverlessStepFunctions . serverless . service . provider . apiGateway . apiKeys = 2 ;
7070 expect ( ( ) => serverlessStepFunctions . compileUsagePlanKeys ( ) ) . to . throw ( Error ) ;
7171 } ) ;
7272
7373 it ( 'throw error if an apiKey is not a string' , ( ) => {
74- serverlessStepFunctions . serverless . service . provider . apiKeys = [ 2 ] ;
74+ serverlessStepFunctions . serverless . service . provider . apiGateway . apiKeys = [ 2 ] ;
7575 expect ( ( ) => serverlessStepFunctions . compileUsagePlanKeys ( ) ) . to . throw ( Error ) ;
7676 } ) ;
7777} ) ;
You can’t perform that action at this time.
0 commit comments