From 8541e694545327c1b5079d1c09a820fea4dd9c76 Mon Sep 17 00:00:00 2001 From: James Relyea Date: Wed, 19 Jan 2022 12:10:25 -0500 Subject: [PATCH 1/2] Add command line option for disabling scheduled events. --- README.md | 1 + package.json | 1 + src/ServerlessOffline.js | 2 +- src/config/commandOptions.js | 4 ++++ src/config/defaultOptions.js | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c86d73fbe..acba764a1 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ All CLI options are optional: --corsDisallowCredentials When provided, the default Access-Control-Allow-Credentials header value will be passed as 'false'. Default: true --corsExposedHeaders Used as additional Access-Control-Exposed-Headers header value for responses. Delimit multiple values with commas. Default: 'WWW-Authenticate,Server-Authorization' --disableCookieValidation Used to disable cookie-validation on hapi.js-server +--disableScheduledEvents Disables all scheduled events. Overrides configurations in serverless.yml. --dockerHost The host name of Docker. Default: localhost --dockerHostServicePath Defines service path which is used by SLS running inside Docker container --dockerNetwork The network that the Docker container will connect to diff --git a/package.json b/package.json index 5ca4fd20d..757ec05d7 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "Gert Jansen van Rensburg (https://github.com/gertjvr)", "Guillaume Carbonneau (https://github.com/guillaume)", "György Balássy (https://github.com/balassy)", + "James Relyea (https://github.com/james-relyea)", "Jarda Snajdr (https://github.com/jsnajdr)", "Jaryd Carolin (https://github.com/horyd)", "Jeff Hall (https://github.com/electrikdevelopment)", diff --git a/src/ServerlessOffline.js b/src/ServerlessOffline.js index 2e0d8c44b..ecbf19e9e 100644 --- a/src/ServerlessOffline.js +++ b/src/ServerlessOffline.js @@ -94,7 +94,7 @@ export default class ServerlessOffline { eventModules.push(this._createHttp(httpEvents)) } - if (scheduleEvents.length > 0) { + if (!this.#options.disableScheduledEvents && scheduleEvents.length > 0) { eventModules.push(this._createSchedule(scheduleEvents)) } diff --git a/src/config/commandOptions.js b/src/config/commandOptions.js index 09f4d8d6b..0fc6aeccc 100644 --- a/src/config/commandOptions.js +++ b/src/config/commandOptions.js @@ -28,6 +28,10 @@ export default { usage: 'Used to disable cookie-validation on hapi.js-server', type: 'boolean', }, + disableScheduledEvents: { + usage: + 'Disables all scheduled events. Overrides configurations in serverless.yml.', + }, enforceSecureCookies: { usage: 'Enforce secure cookies', type: 'boolean', diff --git a/src/config/defaultOptions.js b/src/config/defaultOptions.js index e8a511786..7468d8cd2 100644 --- a/src/config/defaultOptions.js +++ b/src/config/defaultOptions.js @@ -8,6 +8,7 @@ export default { corsAllowOrigin: '*', corsExposedHeaders: 'WWW-Authenticate,Server-Authorization', disableCookieValidation: false, + disableScheduledEvents: false, dockerHost: 'localhost', dockerHostServicePath: null, dockerNetwork: null, From 81acad5fb123a89e5ba40f9b7fe54c40476728a4 Mon Sep 17 00:00:00 2001 From: James Relyea Date: Thu, 20 Jan 2022 08:01:49 -0500 Subject: [PATCH 2/2] Add missing command type for disableScheduledEvents --- src/config/commandOptions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config/commandOptions.js b/src/config/commandOptions.js index 0fc6aeccc..70b66c154 100644 --- a/src/config/commandOptions.js +++ b/src/config/commandOptions.js @@ -30,7 +30,8 @@ export default { }, disableScheduledEvents: { usage: - 'Disables all scheduled events. Overrides configurations in serverless.yml.', + 'Disables all scheduled events. Overrides configurations in serverless.yml. Default: false', + type: 'boolean', }, enforceSecureCookies: { usage: 'Enforce secure cookies',