2017-10-26 15:21:32 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const config = require('wild-config');
|
2017-10-26 19:57:19 +08:00
|
|
|
const log = require('npmlog');
|
2022-06-21 15:30:26 +08:00
|
|
|
const PluginHandler = require('zone-mta/lib/plugin-handler');
|
2017-10-26 19:57:19 +08:00
|
|
|
const db = require('./db');
|
2017-10-26 15:21:32 +08:00
|
|
|
|
2022-07-19 14:22:46 +08:00
|
|
|
module.exports.handler = {
|
|
|
|
// dummy handler
|
|
|
|
runHooks(...args) {
|
|
|
|
if (args.length && typeof args[args.length - 1] === 'function') {
|
|
|
|
args[args.length - 1]();
|
|
|
|
}
|
|
|
|
|
|
|
|
// assume promise
|
|
|
|
return new Promise(resolve => setImmediate(resolve));
|
|
|
|
}
|
|
|
|
};
|
2022-06-21 15:30:26 +08:00
|
|
|
|
|
|
|
module.exports.init = context => {
|
|
|
|
module.exports.handler = new PluginHandler({
|
|
|
|
logger: log,
|
|
|
|
pluginsPath: config.plugins.pluginsPath,
|
|
|
|
plugins: config.plugins.conf,
|
|
|
|
context,
|
|
|
|
log: config.log,
|
|
|
|
db
|
|
|
|
});
|
2017-10-26 15:21:32 +08:00
|
|
|
};
|