Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-offline-scheduler

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-offline-scheduler - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

index.js

@@ -22,3 +22,3 @@ 'use strict';

'schedule:run': () => this.scheduler.run(),
'offline:start:init': () => this.scheduler.run()
'after:offline:start:init': () => this.scheduler.run()
};

@@ -25,0 +25,0 @@ }

@@ -9,13 +9,14 @@ 'use strict';

const pathBases = [
'',
'.webpack'
];
class Scheduler {
constructor(serverless) {
this.serverless = serverless;
this.location = '';
}
run() {
const offlinePlugin = this.serverless.pluginManager.getPlugins()
.find(p => p.constructor && p.constructor.name === 'Offline')
if (offlinePlugin) {
this.location = offlinePlugin.options.location;
}
this.funcConfigs = this._getFuncConfigs();

@@ -26,11 +27,12 @@ for(const i in this.funcConfigs) {

const scheduleEvent = fConfig.events[j];
const func = this._requireFunction(fConfig.id);
if (!func) {
continue;
}
this._setEnvironmentVars(fConfig.id); //TODO: Set this individually for each schedule
this.serverless.cli.log(`scheduling ${fConfig.id} with ${scheduleEvent}`);
this.serverless.cli.log(`scheduler: scheduling ${fConfig.id} with ${scheduleEvent}`);
schedule.scheduleJob(scheduleEvent, () => {
this.serverless.cli.log(`Running scheduled job: ${fConfig.id}`)
const func = this._requireFunction(fConfig.id);
if (!func) {
this.serverless.cli.log(`scheduler: unable to find source for ${fName}`);
return;
}
this.serverless.cli.log(`scheduler: running scheduled job: ${fConfig.id}`)
func(

@@ -52,9 +54,6 @@ this._getEvent(),

const handlerFunction = handlerParts[1];
for (const base of pathBases) {
const funcPath = path.join(this.serverless.config.servicePath, base, filename);
if (fs.existsSync(funcPath)) {
return require(funcPath)[handlerFunction];
}
const funcPath = path.join(this.serverless.config.servicePath, this.location, filename);
if (fs.existsSync(funcPath)) {
return require(funcPath)[handlerFunction];
}
this.serverless.cli.log(`Unable to find source for ${fName}:${filename}`);
return null;

@@ -100,7 +99,7 @@ }

if (scheduleEvent.startsWith('rate(')) {
this.serverless.cli.log('Rate syntax not currently supported, will not schedule')
this.serverless.cli.log('scheduler: rate syntax not currently supported, will not schedule')
return null;
}
this.serverless.cli.log('Invalid, schedule syntax');
this.serverless.cli.log('scheduler: invalid, schedule syntax');
return null;

@@ -107,0 +106,0 @@ }

{
"name": "serverless-offline-scheduler",
"version": "0.1.4",
"version": "0.1.5",
"description": "Serverless plugin to run scheduled lambdas with serverless offline",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc