From 54088e3f106c1a9c5af35a8f0a20f5fc84ef61eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BD=B6=E5=93=A5?= Date: Tue, 7 Feb 2017 16:05:12 +0800 Subject: [PATCH] v0.0.4 --- .eslintrc.js | 4 ++-- README.md | 7 +++++++ gulpfile.js | 4 ++-- src/app.js | 2 +- src/config.js | 19 ++++++++++++------- src/lib/sequelize.js | 8 ++++---- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ab1a81f..4692b8e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,7 @@ module.exports = { root: true, parserOptions: { - ecmaVersion: 6, //指定ECMAScript支持的版本,6为ES6 + ecmaVersion: 8, //指定ECMAScript支持的版本,6为ES6,这里为了兼容async和await,设置为8 sourceType: 'module' }, extends: 'standard', @@ -12,7 +12,7 @@ module.exports = { env: { 'node': true }, - rules: { // add your custom rules here + rules: { // allow console 'no-console': 0, // allow paren-less arrow functions diff --git a/README.md b/README.md index 30913c2..2627545 100644 --- a/README.md +++ b/README.md @@ -470,3 +470,10 @@ request.post('/api').form({key:'value'}), function(err,httpResponse,body){ /* .. ``` 删除gulpfile.js中的lint、eslint_start两个任务,并且把default改为“gulp.task('default', ['start']”。 + +## 更新说明 + +*v0.0.4 2017年02月07日15:57:17* +1、修改了部分配置文件的配置方法,使之更为规范(老版本用户无须理会,对程序没有影响)。 +2、修改了eslintrc.js文件中的JavaScript版本配置,改为ES8,兼容async、await。 +3、修改gulpfile.js文件第12行,检查`src/**/*.js`文件。 diff --git a/gulpfile.js b/gulpfile.js index 85dee3f..e5ddbd0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,8 +9,8 @@ if (process.env.npm_config_argv.indexOf('debug') > 0) { } gulp.task('lint', () => { - return gulp.src(['src/*.js', '!node_modules/**']) - .pipe(eslint({configFile: '.eslintrc.js'})) + return gulp.src(['src/**/*.js', '!node_modules/**']) + .pipe(eslint({configFile: './.eslintrc.js'})) .pipe(eslint.format(friendlyFormatter)) // .pipe(eslint.failAfterError()) .pipe(eslint.results(results => { diff --git a/src/app.js b/src/app.js index f86cefa..29a7b79 100644 --- a/src/app.js +++ b/src/app.js @@ -3,7 +3,7 @@ import KoaBody from 'koa-body' import KoaSession from 'koa-session2' import KoaStatic from 'koa-static2' import { - SystemConfig + System as SystemConfig } from './config' import path from 'path' import MainRoutes from './routes/main-routes' diff --git a/src/config.js b/src/config.js index c616532..c8fba11 100644 --- a/src/config.js +++ b/src/config.js @@ -1,18 +1,23 @@ import path from 'path' -export let SystemConfig = { +// 系统配置 +export let System = { HTTP_server_type: 'http://', // HTTP服务器地址,包含"http://"或"https://" HTTP_server_host: 'localhost', // HTTP服务器地址,请勿添加"http://" HTTP_server_port: '3000', // HTTP服务器端口号 System_country: 'zh-cn', // 所在国家的国家代码 System_plugin_path: path.join(__dirname, './plugins'), // 插件路径 Session_Key: 'RESTfulAPI', // 生产环境务必随机设置一个值 - mysql_host: 'localhost', // MySQL服务器地址 - mysql_user: 'root', // 数据库用户名 - mysql_password: 'root', // 数据库密码 - mysql_database: 'test', // 数据库名称 - mysql_port: 3306, // 数据库端口号 - mysql_prefix: 'api_' // 默认"api_" + db_type: 'mysql' // 数据库类型 +} + +export let DB = { + host: 'localhost', // 服务器地址 + port: 3306, // 数据库端口号 + username: 'admin', // 数据库用户名 + password: 'admin888', // 数据库密码 + database: 'development', // 数据库名称 + prefix: 'api_' // 默认"api_" } export let SendEmail = { diff --git a/src/lib/sequelize.js b/src/lib/sequelize.js index 41f80f9..390321d 100644 --- a/src/lib/sequelize.js +++ b/src/lib/sequelize.js @@ -1,9 +1,9 @@ import Sequelize from 'sequelize' -import { SystemConfig } from '../config' +import { DB as DBConfig, System as SystemConfig } from '../config' -export default new Sequelize(SystemConfig.mysql_database, SystemConfig.mysql_user, SystemConfig.mysql_password, { - host: SystemConfig.mysql_host, - dialect: 'mysql', +export default new Sequelize(DBConfig.database, DBConfig.username, DBConfig.password, { + host: DBConfig.host, + dialect: SystemConfig.db_type, pool: { max: 50, min: 0,