-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
周立
committed
Oct 27, 2018
0 parents
commit 13d94a5
Showing
264 changed files
with
33,019 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"presets": ["es2015", "stage-0"], | ||
"plugins": [ | ||
["transform-runtime", { | ||
"helpers": false, // defaults to true | ||
"polyfill": false, // defaults to true | ||
"regenerator": true, // defaults to true | ||
"moduleName": "babel-runtime" // defaults to "babel-runtime" | ||
}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.html] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 以下文件不检测,只是针对controller service 目录检测 | ||
install.js | ||
watchChange.js | ||
webpack.config.js | ||
backup-db.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
node_modules/ | ||
dist/ | ||
.idea/ | ||
logs/ |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"/Users/zhouli/mygithub/node-blog/settings/appSettings.js":{"path":"/Users/zhouli/mygithub/node-blog/settings/appSettings.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":8,"column":0},"end":{"line":43,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1,"1":1},"f":{},"b":{},"_coverageSchema":"43e27e138ebf9cfc5966b082cf9a028302ed4184","hash":"6bb94d11f434e71a7a4d80eee562f0114ff7c00c","contentHash":"58cf67ac74a427317125b177fdc8d70a"}} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"/Users/zhouli/mygithub/node-blog/src/utils/install.js":{"path":"/Users/zhouli/mygithub/node-blog/src/utils/install.js","statementMap":{"0":{"start":{"line":4,"column":9},"end":{"line":4,"column":22}},"1":{"start":{"line":5,"column":11},"end":{"line":5,"column":40}},"2":{"start":{"line":6,"column":11},"end":{"line":6,"column":56}},"3":{"start":{"line":7,"column":18},"end":{"line":127,"column":1}},"4":{"start":{"line":128,"column":15},"end":{"line":128,"column":37}},"5":{"start":{"line":129,"column":22},"end":{"line":129,"column":29}},"6":{"start":{"line":130,"column":4},"end":{"line":130,"column":23}},"7":{"start":{"line":135,"column":15},"end":{"line":135,"column":55}},"8":{"start":{"line":136,"column":15},"end":{"line":136,"column":51}},"9":{"start":{"line":137,"column":4},"end":{"line":137,"column":16}},"10":{"start":{"line":142,"column":22},"end":{"line":142,"column":54}},"11":{"start":{"line":143,"column":20},"end":{"line":143,"column":73}},"12":{"start":{"line":144,"column":4},"end":{"line":144,"column":119}},"13":{"start":{"line":149,"column":4},"end":{"line":149,"column":104}},"14":{"start":{"line":154,"column":4},"end":{"line":154,"column":37}},"15":{"start":{"line":155,"column":4},"end":{"line":155,"column":55}},"16":{"start":{"line":156,"column":12},"end":{"line":156,"column":13}},"17":{"start":{"line":157,"column":4},"end":{"line":168,"column":5}},"18":{"start":{"line":158,"column":8},"end":{"line":158,"column":12}},"19":{"start":{"line":159,"column":8},"end":{"line":167,"column":9}},"20":{"start":{"line":161,"column":12},"end":{"line":161,"column":69}},"21":{"start":{"line":162,"column":12},"end":{"line":162,"column":68}},"22":{"start":{"line":165,"column":12},"end":{"line":165,"column":69}},"23":{"start":{"line":166,"column":12},"end":{"line":166,"column":68}},"24":{"start":{"line":169,"column":4},"end":{"line":169,"column":53}},"25":{"start":{"line":174,"column":13},"end":{"line":174,"column":33}},"26":{"start":{"line":175,"column":4},"end":{"line":194,"column":5}},"27":{"start":{"line":176,"column":18},"end":{"line":176,"column":42}},"28":{"start":{"line":177,"column":8},"end":{"line":191,"column":9}},"29":{"start":{"line":178,"column":12},"end":{"line":178,"column":39}},"30":{"start":{"line":180,"column":12},"end":{"line":180,"column":51}},"31":{"start":{"line":181,"column":12},"end":{"line":181,"column":30}},"32":{"start":{"line":182,"column":12},"end":{"line":182,"column":50}},"33":{"start":{"line":184,"column":12},"end":{"line":190,"column":15}},"34":{"start":{"line":185,"column":16},"end":{"line":188,"column":17}},"35":{"start":{"line":186,"column":20},"end":{"line":186,"column":46}},"36":{"start":{"line":187,"column":20},"end":{"line":187,"column":52}},"37":{"start":{"line":189,"column":16},"end":{"line":189,"column":36}},"38":{"start":{"line":193,"column":8},"end":{"line":193,"column":19}},"39":{"start":{"line":199,"column":4},"end":{"line":199,"column":34}},"40":{"start":{"line":200,"column":4},"end":{"line":215,"column":7}},"41":{"start":{"line":201,"column":8},"end":{"line":201,"column":28}},"42":{"start":{"line":202,"column":8},"end":{"line":214,"column":11}},"43":{"start":{"line":203,"column":12},"end":{"line":203,"column":32}},"44":{"start":{"line":204,"column":12},"end":{"line":213,"column":15}},"45":{"start":{"line":205,"column":16},"end":{"line":205,"column":36}},"46":{"start":{"line":206,"column":16},"end":{"line":212,"column":19}},"47":{"start":{"line":207,"column":20},"end":{"line":207,"column":40}},"48":{"start":{"line":208,"column":20},"end":{"line":211,"column":23}},"49":{"start":{"line":209,"column":24},"end":{"line":209,"column":44}},"50":{"start":{"line":210,"column":24},"end":{"line":210,"column":47}},"51":{"start":{"line":221,"column":4},"end":{"line":228,"column":5}},"52":{"start":{"line":222,"column":8},"end":{"line":222,"column":18}},"53":{"start":{"line":223,"column":11},"end":{"line":228,"column":5}},"54":{"start":{"line":224,"column":8},"end":{"line":224,"column":46}},"55":{"start":{"line":225,"column":8},"end":{"line":225,"column":19}},"56":{"start":{"line":227,"column":8},"end":{"line":227,"column":32}},"57":{"start":{"line":231,"column":0},"end":{"line":235,"column":2}}},"fnMap":{"0":{"name":"getInputCommandName","decl":{"start":{"line":127,"column":11},"end":{"line":127,"column":30}},"loc":{"start":{"line":127,"column":33},"end":{"line":131,"column":1}},"line":127},"1":{"name":"getAppConfig","decl":{"start":{"line":134,"column":9},"end":{"line":134,"column":21}},"loc":{"start":{"line":134,"column":38},"end":{"line":138,"column":1}},"line":134},"2":{"name":"getMysqlCreateShell","decl":{"start":{"line":141,"column":9},"end":{"line":141,"column":28}},"loc":{"start":{"line":141,"column":35},"end":{"line":145,"column":1}},"line":141},"3":{"name":"getMysqlImportShell","decl":{"start":{"line":148,"column":9},"end":{"line":148,"column":28}},"loc":{"start":{"line":148,"column":35},"end":{"line":150,"column":1}},"line":148},"4":{"name":"showTips","decl":{"start":{"line":153,"column":9},"end":{"line":153,"column":17}},"loc":{"start":{"line":153,"column":20},"end":{"line":170,"column":1}},"line":153},"5":{"name":"runCommand","decl":{"start":{"line":173,"column":9},"end":{"line":173,"column":19}},"loc":{"start":{"line":173,"column":29},"end":{"line":195,"column":1}},"line":173},"6":{"name":"(anonymous_6)","decl":{"start":{"line":184,"column":22},"end":{"line":184,"column":23}},"loc":{"start":{"line":184,"column":53},"end":{"line":190,"column":13}},"line":184},"7":{"name":"initAll","decl":{"start":{"line":198,"column":9},"end":{"line":198,"column":16}},"loc":{"start":{"line":198,"column":27},"end":{"line":216,"column":1}},"line":198},"8":{"name":"(anonymous_8)","decl":{"start":{"line":200,"column":30},"end":{"line":200,"column":31}},"loc":{"start":{"line":200,"column":61},"end":{"line":215,"column":5}},"line":200},"9":{"name":"(anonymous_9)","decl":{"start":{"line":202,"column":39},"end":{"line":202,"column":40}},"loc":{"start":{"line":202,"column":70},"end":{"line":214,"column":9}},"line":202},"10":{"name":"(anonymous_10)","decl":{"start":{"line":204,"column":49},"end":{"line":204,"column":50}},"loc":{"start":{"line":204,"column":80},"end":{"line":213,"column":13}},"line":204},"11":{"name":"(anonymous_11)","decl":{"start":{"line":206,"column":55},"end":{"line":206,"column":56}},"loc":{"start":{"line":206,"column":86},"end":{"line":212,"column":17}},"line":206},"12":{"name":"(anonymous_12)","decl":{"start":{"line":208,"column":54},"end":{"line":208,"column":55}},"loc":{"start":{"line":208,"column":85},"end":{"line":211,"column":21}},"line":208},"13":{"name":"initByArgs","decl":{"start":{"line":219,"column":9},"end":{"line":219,"column":19}},"loc":{"start":{"line":219,"column":33},"end":{"line":229,"column":1}},"line":219}},"branchMap":{"0":{"loc":{"start":{"line":159,"column":8},"end":{"line":167,"column":9}},"type":"if","locations":[{"start":{"line":159,"column":8},"end":{"line":167,"column":9}},{"start":{"line":159,"column":8},"end":{"line":167,"column":9}}],"line":159},"1":{"loc":{"start":{"line":175,"column":4},"end":{"line":194,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":194,"column":5}},{"start":{"line":175,"column":4},"end":{"line":194,"column":5}}],"line":175},"2":{"loc":{"start":{"line":177,"column":8},"end":{"line":191,"column":9}},"type":"if","locations":[{"start":{"line":177,"column":8},"end":{"line":191,"column":9}},{"start":{"line":177,"column":8},"end":{"line":191,"column":9}}],"line":177},"3":{"loc":{"start":{"line":185,"column":16},"end":{"line":188,"column":17}},"type":"if","locations":[{"start":{"line":185,"column":16},"end":{"line":188,"column":17}},{"start":{"line":185,"column":16},"end":{"line":188,"column":17}}],"line":185},"4":{"loc":{"start":{"line":210,"column":24},"end":{"line":210,"column":46}},"type":"binary-expr","locations":[{"start":{"line":210,"column":24},"end":{"line":210,"column":32}},{"start":{"line":210,"column":36},"end":{"line":210,"column":46}}],"line":210},"5":{"loc":{"start":{"line":221,"column":4},"end":{"line":228,"column":5}},"type":"if","locations":[{"start":{"line":221,"column":4},"end":{"line":228,"column":5}},{"start":{"line":221,"column":4},"end":{"line":228,"column":5}}],"line":221},"6":{"loc":{"start":{"line":223,"column":11},"end":{"line":228,"column":5}},"type":"if","locations":[{"start":{"line":223,"column":11},"end":{"line":228,"column":5}},{"start":{"line":223,"column":11},"end":{"line":228,"column":5}}],"line":223}},"s":{"0":1,"1":1,"2":1,"3":1,"4":0,"5":0,"6":0,"7":1,"8":1,"9":1,"10":3,"11":3,"12":3,"13":1,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":1},"f":{"0":0,"1":1,"2":3,"3":1,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0]},"_coverageSchema":"43e27e138ebf9cfc5966b082cf9a028302ed4184","hash":"e0bf2b6dbc9728dac52e2105d82e70374bb8e231","contentHash":"afdc334f140033380a8d8a77e71b03c0"}} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
'config': path.resolve('src/config', 'config.js'), | ||
'models-path': path.resolve('src', 'models'), | ||
'seeders-path': path.resolve('src', 'seeders'), | ||
'migrations-path': path.resolve('src', 'migrations') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,301 @@ | ||
# nice-swa-s | ||
## 项目说明 | ||
- nice-swa,读着:laishua,中文名:来耍,加了-s,是代表serve,服务端。 | ||
- 这是NODE后台脚手架模板, | ||
使用 koa2 后端框架,数据库 mysql,ES6 语法开发, | ||
打包工具为webpack4。 | ||
既可以直接原生连接进行数据操作,也可以使用Sequlize ORM框架对数据操作。 | ||
此脚手架项目已经完成一个基本的博客系统搭建。如果需要搭建其他项目,可以对相关文件夹进行修改或删除。 | ||
|
||
[项目地址](https://github.com/QCCS/nice-swa-s) | ||
|
||
[在线文档](https://qccs.github.io/nice-swa-s/docs/#/) | ||
|
||
## nice-swa前端-react+materailDesign | ||
[nice-swa前端项目地址](https://github.com/QCCS/nice-swa) | ||
|
||
## 功能介绍 | ||
+ [x] 注册与Jwt登陆认证 | ||
+ [ ] 用户以及权限管理 | ||
+ [ ] 博客发布管理 | ||
+ [x] 文件上传 | ||
+ [ ] 博客标签管理 | ||
+ [ ] 博客评论管理 | ||
+ [x] ~~博客点赞~~ | ||
+ [ ] 博客阅读量 | ||
+ [ ] 博客前台 ejs 模板引擎 | ||
+ [x] 集成 swagger 文档 | ||
+ [x] 日志记录 | ||
+ [x] 项目数据备份 | ||
+ [ ] 开发扫描工具 | ||
+ [x] 安装部署命令行工具 | ||
+ [ ] 集成测试 | ||
|
||
## 开发相关 | ||
+ [x] 控制器自动扫描 | ||
+ [x] service 自动扫描 | ||
+ [ ] swagger 文档自动生成 | ||
+ [ ] 接口自动扫描 | ||
+ [ ] 开发自动化 | ||
|
||
## 项目目录 | ||
> nice-swa-s | ||
- dist 打包之后的目录 | ||
- docs 文档目录 | ||
- publicImg 上传的图片目录 | ||
- settings 应用设置目录 | ||
- src 核心源码目录 | ||
- backup-db 数据库备份目录 | ||
- config 项目配置目录 | ||
- controller 控制器目录 | ||
- dao 数据获取与ORM框架model对应 | ||
- middleware 中间件目录 | ||
- migrations 迁移文件目录 | ||
- models 数据模型目录 | ||
- route 路由目录 | ||
- seeders 数据种子文件目录 | ||
- service 链接控制器与模型 | ||
- utils 工具函数目录 | ||
- static 静态文件目录 | ||
- views 前端模板引擎目录 | ||
- index.js 入口文件 | ||
- backup-db.js 备份 | ||
- install.js 命令行工具 | ||
- watchChange.js 开发时工具,扫描器 | ||
- webpack.config.js 打包配置 | ||
|
||
## 环境准备 | ||
``` | ||
mysql 5.6 | ||
node 9 | ||
pm2 2.8 | ||
``` | ||
|
||
## 开始使用 | ||
``` | ||
git clone -b master https://github.com/QCCS/nice-swa-s.git | ||
``` | ||
|
||
## 项目设置 | ||
应用端口与数据库设置 settings/appSetting.js | ||
``` | ||
//此文件不要修改其他,除了添加key与value | ||
export default { | ||
"development": { | ||
"app_port": 9313, | ||
"host": "127.0.0.1", | ||
"user": "root", | ||
"password": "password", | ||
"port": "3306", | ||
"database": "node_blog_dev" | ||
}, | ||
"test": { | ||
"app_port": 9314, | ||
"host": "127.0.0.1", | ||
"user": "root", | ||
"password": "password", | ||
"port": "3306", | ||
"database": "node_blog_test" | ||
}, | ||
"production": { | ||
"app_port": 9315, | ||
"host": "127.0.0.1", | ||
"user": "root", | ||
"password": "password", | ||
"port": "3306", | ||
"database": "node_blog_prod" | ||
} | ||
} | ||
``` | ||
## 安装项目 | ||
``` | ||
node install initAll | ||
pm2 start dist/index.js -i 0 --name "app-name" | ||
``` | ||
|
||
## 开发项目 | ||
``` | ||
nvm use 9 | ||
//环境准备 | ||
node install init | ||
node install mysqlCreateDev | ||
node install sequlizeDevTable | ||
node install seedDataDev | ||
//打包与启动 | ||
node install buildDev | ||
node install runDev | ||
``` | ||
开发实时编译与重启 | ||
``` | ||
node watchChange.js | ||
npm run superdev | ||
``` | ||
开发时建议运行 watchChange.js 让扫描器自动扫描 | ||
|
||
## 开发自动测试 | ||
``` | ||
//测试 | ||
npm run test | ||
//测试并且生成报表 | ||
npm run nyc | ||
//生成html测试报表 | ||
npm run testReport | ||
``` | ||
测试截图 npm run nyc | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/testing.png) | ||
测试报表 npm run testReport | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/test-report.png) | ||
## 部署测试环境 | ||
``` | ||
//环境准备 | ||
node install init | ||
node install mysqlCreateTest | ||
node install sequlizeTestTable | ||
node install seedDataTest | ||
//打包与启动 | ||
node install buildTest | ||
node install runTest | ||
``` | ||
|
||
## 命令行工具 | ||
运行 | ||
|
||
``` | ||
node install help | ||
``` | ||
输出 | ||
``` | ||
显示帮助: | ||
node install help | ||
生成环境:打包与数据库环境准备: | ||
node install initAll | ||
测试: | ||
node install test | ||
测试,显示报表: | ||
node install nyc | ||
生成html测试报表: | ||
node install testReport | ||
安装项目依赖: | ||
node install init | ||
推荐使用:shell创建Prod数据库: | ||
node install mysqlCreateProd | ||
推荐使用:shell创建dev数据库: | ||
node install mysqlCreateDev | ||
推荐使用:shell创建test数据库: | ||
node install mysqlCreateTest | ||
直接导入生产环境sql文件,sql文件放在项目跟目录: | ||
node install mysqlSource | ||
不推荐使用:sequlize创建dev数据库: | ||
node install sequlizeDevDB | ||
sequlize创建dev数据表: | ||
node install sequlizeDevTable | ||
不推荐使用:sequlize创建test数据库: | ||
node install sequlizeTestDB | ||
sequlize创建test数据表: | ||
node install sequlizeTestTable | ||
不推荐使用:sequlize创建Prod数据库: | ||
node install sequlizeProdDB | ||
sequlize创建Prod数据表: | ||
node install sequlizeProdTable | ||
dev填充数据: | ||
node install seedDataDev | ||
test填充数据: | ||
node install seedDataTest | ||
prod填充数据: | ||
node install seedDataProd | ||
打包开发环境: | ||
node install buildDev | ||
运行开发环境: | ||
node install runDev | ||
打包Test环境: | ||
node install buildTest | ||
运行Test环境: | ||
node install runTest | ||
打包Prod环境: | ||
node install buildProd | ||
运行Prod环境: | ||
node install runProd | ||
备份dev数据库: | ||
node install backup | ||
备份test数据库: | ||
node install backupTest | ||
备份prod数据库: | ||
node install backupProd | ||
``` | ||
|
||
## 项目依赖介绍 | ||
> dependencies & devDependencies | ||
- koa2 node后端框架 | ||
- babel-cli 语言转换工具 | ||
- babel-plugin-transform-runtime 运行时转换语言包 | ||
- webpack 打包工具 | ||
- webpack-cli 打包命令工具 | ||
- copy-webpack-plugin 打包时拷贝文件 | ||
- koa-bodyparser 请求体转换 | ||
- koa2-swagger-ui swagger文档 | ||
- koa-views 模板引擎 | ||
- ejs 模板引擎语法 | ||
- koa-router 路由中间件 | ||
- koa2-file-upload 文件上传 | ||
- jsonwebtokentoken 签名与解密 | ||
- koa-jwt token http认证 | ||
- koa-static 静态文件配置 | ||
- koa-logger 请求输出log中间件 | ||
- bcryptjs 密码加密加盐 | ||
- mysql 原生node链接数据库 | ||
- mysql2 sequelize 链接数据库依赖 | ||
- sequelize orm框架 | ||
- sequelize-cli 迁移文件命令行工具 | ||
- ava 测试 | ||
- request 测试接口 | ||
- nyc 测试报表 | ||
- chokidar 监听文件变化 | ||
- mysql-backup-db 备份数据库 | ||
|
||
| name | desc | | ||
| :---------- | :--- | | ||
| koa2 | node后端框架 | | ||
| babel-cli | 语言转换工具 | | ||
|
||
|
||
## 项目截图 | ||
登陆 | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/login.png) | ||
新增博客 | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/create_post.png) | ||
获取单个博客(可浏览器直接查看) | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/get_post.png) | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/post_detail.png) | ||
获取全部博客(可浏览器直接查看) | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/get_all_post.png) | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/post_list.png) | ||
获取用户列表1 | ||
![](https://raw.githubusercontent.com/QCCS/nice-swa-s/master/docs/imgs/user.png) | ||
|
||
## 其他博客项目 | ||
这也是我为什么做博客系统的原因,找不到一个我想要的。 | ||
方便开发,扩展,测试,与部署 | ||
+ ~~无接口文档~~ | ||
+ ~~无开发自动化~~ | ||
+ ~~无扫描器~~ | ||
+ ~~无测试报告~~ | ||
+ ~~无多环境一键部署~~ | ||
+ ~~无前后端分离~~ | ||
+ ~~无数据迁移与备份~~ | ||
+ ~~无日志记录~~ | ||
+ ~~无运维监控~~ | ||
|
||
## 发布历史 | ||
branch:date-feature_name | ||
|
||
## 参考网站 | ||
- [Node支持情况](https://node.green) | ||
- [koajs](https://koajs.com) | ||
- [sequelizejs](http://docs.sequelizejs.com) | ||
- [ejs](http://ejs.co) | ||
- [ava](https://github.com/avajs/ava) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//备份数据 | ||
const fs = require('fs'); | ||
var dataConf = fs.readFileSync('./settings/appSettings.js', 'utf8'); | ||
var appSettings = JSON.parse(dataConf.split("default")[1]); | ||
let databaseConf = appSettings.development; | ||
let env = process.env.NODE_ENV || 'development'; | ||
|
||
if (env === "test") { | ||
databaseConf = appSettings.test; | ||
} | ||
if (env === "production") { | ||
databaseConf = appSettings.production; | ||
} | ||
console.log("备份数据库:" + databaseConf.database); | ||
const Backup = require('mysql-backup-db'); | ||
var mysqlConf = { | ||
host: databaseConf.host, | ||
user: databaseConf.user, | ||
password: databaseConf.password, | ||
database: databaseConf.database, | ||
port: databaseConf.port, | ||
backupPath: "./src/backup-db/" | ||
} | ||
//30分支备份 | ||
var gapTime = 1000 * 60 * 30; | ||
gapTime = 3000; | ||
//最近3份 | ||
var count = 3; | ||
Backup.backupWithGaptime(mysqlConf, gapTime, count); |
Oops, something went wrong.