I am trying to schedule cronjobs which will run at specified time, i am using hapi-cron-job of hapi, when i try to register the plugin, i am getting below error.
[1] "plugin.register" must be of type function
at Object.exports.apply (D:\my_dir\Repositories\repo-cronjobs\node_modules\@hapi\hapi\lib\config.js:19:15)
at internals.Server.register (D:\my_dir\Repositories\repo-cronjobs\node_modules\@hapi\hapi\lib\server.js:454:31)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Please find the configuration while registering the plugin.
server.js
const { plugins } = require('./register/index');
await server
.register(plugins)
.then(() => {})
.catch(err => {
console.error('Plugin registeration failed!');
console.error(err);
});
index.js
module.exports.plugins = [
// I have here other pluguns, passing this array for registration in server.js
require("./hapi-cron-job-plugin")
];
hapi-cron-job-plugin.js
const hapiCronJob = require('hapi-cron-job')
const plugin = {
register: require('hapi-cron-job'),
options: {
jobs: [
{
name: "diplay time",
enabled: true,
immediate: true,
schedule: "every 1 s",
execute: alertSystemAdminAndDispatcher,
environments: ['development', 'staging']
}
],
}
}
module.exports = plugin;
nodeJS version: v14.17.3
Hapi-cron-job: "hapi-cron-job": "^2.0.1"