diff --git a/package.json b/package.json index 0a457eb..aa3b94b 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dependencies": { "koa": "^2.0.0", "koa-body": "^2.0.0", - "koa-compose": "^2.5.1", + "koa-compose": "^3.2.1", "koa-router": "^7.0.1", "koa-session2": "^1.0.8", "koa-static2": "^0.1.8", diff --git a/src/app.js b/src/app.js index 339bf92..f86cefa 100644 --- a/src/app.js +++ b/src/app.js @@ -8,7 +8,7 @@ import { import path from 'path' import MainRoutes from './routes/main-routes' import ErrorRoutes from './routes/error-routes' -// import PluginLoader from './tool/PluginLoader' +import PluginLoader from './lib/PluginLoader' const app = new Koa2() const env = process.env.NODE_ENV || 'development' // Current mode @@ -25,7 +25,7 @@ app .use(KoaSession({ key: SystemConfig.Session_Key })) // Set Session - // .use(PluginLoader(SystemConfig.System_plugin_path)) + .use(PluginLoader(SystemConfig.System_plugin_path)) .use((ctx, next) => { if (ctx.request.header.host.split(':')[0] === 'api.XXX.com' || ctx.request.header.host.split(':')[0] === '127.0.0.1') { ctx.set('Access-Control-Allow-Origin', '*') diff --git a/src/config.js b/src/config.js index b3384a5..c616532 100644 --- a/src/config.js +++ b/src/config.js @@ -5,7 +5,7 @@ export let SystemConfig = { HTTP_server_host: 'localhost', // HTTP服务器地址,请勿添加"http://" HTTP_server_port: '3000', // HTTP服务器端口号 System_country: 'zh-cn', // 所在国家的国家代码 - System_plugin_path: path.join(__dirname, '../src/plugins'), // 插件路径 + System_plugin_path: path.join(__dirname, './plugins'), // 插件路径 Session_Key: 'RESTfulAPI', // 生产环境务必随机设置一个值 mysql_host: 'localhost', // MySQL服务器地址 mysql_user: 'root', // 数据库用户名 diff --git a/src/tool/PluginLoader.js b/src/lib/PluginLoader.js similarity index 99% rename from src/tool/PluginLoader.js rename to src/lib/PluginLoader.js index 138bfd4..4b60ce6 100644 --- a/src/tool/PluginLoader.js +++ b/src/lib/PluginLoader.js @@ -10,7 +10,6 @@ function getDirs (srcpath) { module.exports = (srcpath, filename = 'index.js') => { let plugins = {} - let dirs = getDirs(srcpath) let list = [] diff --git a/src/plugins/smtp_sendemail/index.js b/src/plugins/smtp_sendemail/index.js index 931966b..188017f 100644 --- a/src/plugins/smtp_sendemail/index.js +++ b/src/plugins/smtp_sendemail/index.js @@ -1,6 +1,10 @@ import nodemailer from 'nodemailer' import { SendEmail } from '../../config' +export default () => { + console.log('ok') +} + // 发送Email(目前使用的是阿里云SMTP发送邮件) // receivers 目标邮箱,可以用英文逗号分隔多个。(我没试过) // subject 邮件标题