372310
config/plugin.js
'use strict';
const path = require('path');
// had enabled by egg
// exports.static = true;
exports.static = true;
exports.cors = {
enable: true,
package: 'egg-cors',
};
// 数据库插件
exports.mysql = {
enable: true,
package:'egg-mysql',
};
// 参数验证插件
exports.validate = {
enable: true,
package: 'egg-validate',
};
// 时间插件
exports.timeFormate = {
enable: true,
path: path.join(__dirname, '../lib/plugin/timeFormate')
}
lib/plugin/timeFormate/app.js
module.exports = app => {
app.addSingleton('timeFormate', timeFormate);
}
function timeFormate() {
console.log(111111111)
return '1111'
}
lib/plugin/timeFormate/package.json
{
"name": "egg-timeFormate",
"version": "1.0.0",
"eggPlugin": {
"name": "timeFormate"
}
}
最后调用的时候 就变这样了