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
Showing
60 changed files
with
4,163 additions
and
1 deletion.
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,15 @@ | ||
# Logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
*.pid | ||
.tmp | ||
.sass-cache | ||
uploads | ||
|
||
############### | ||
.DS_Store | ||
node_modules | ||
test_coverage | ||
private |
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,21 @@ | ||
sudo: false | ||
language: node_js | ||
env: | ||
- CXX=g++-4.8 | ||
node_js: | ||
- "4.1" | ||
services: | ||
- mongodb | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- g++-4.8 | ||
|
||
before_install: | ||
- $CXX --version | ||
before_script: | ||
- npm install -g gulp | ||
script: gulp test | ||
after_script: gulp coveralls |
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 |
---|---|---|
@@ -1 +1,37 @@ | ||
# jackblog-api-es6 | ||
# jackblog api koa版 | ||
|
||
Jackblog 是使用 Node.js 和 MongoDB 开发的个人博客系统,前后端分离,仿简书模板.此为服务端koa版. | ||
服务端有: | ||
[express版](https://github.com/jackhutu/jackblog-api-es5) | ||
[koa版](https://github.com/jackhutu/jackblog-api-koa) | ||
客户端有: | ||
[angular1.x版](https://github.com/jackhutu/jackblog-angular1) | ||
[react redux 版](https://github.com/jackhutu/jackblog-react-redux) | ||
移动端有: | ||
[react native 版](https://github.com/jackhutu/jackblog-react-native-redux) | ||
|
||
|
||
## 开发 | ||
``` | ||
$ npm install | ||
$ gulp serve | ||
``` | ||
配合客户端测试的测试模式 | ||
|
||
``` | ||
$ gulp serve:test | ||
``` | ||
|
||
## 线上布署 | ||
``` | ||
$ pm2 start process.json | ||
``` | ||
可参考[利用git和pm2一键布署项目到vps](http://angular1.jackhu.top/article/55cd8e00c6e998b817a930c7) | ||
|
||
## 测试 | ||
``` | ||
$ gulp test | ||
``` | ||
|
||
## License | ||
MIT |
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,19 @@ | ||
'use strict'; | ||
|
||
var gutil = require('gulp-util'); | ||
|
||
exports.paths = { | ||
mocha: 'test', | ||
istanbul: 'test_coverage', | ||
server:'server' | ||
}; | ||
|
||
/** | ||
* 错误处理 | ||
*/ | ||
exports.errorHandler = function() { | ||
return function (err) { | ||
gutil.beep(); | ||
gutil.log(err.toString()); | ||
} | ||
}; |
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,48 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
var config = require('./config'); | ||
var path = require('path'); | ||
var pkg = require('../package.json'); | ||
var nodemon = require('gulp-nodemon'); | ||
|
||
//默认development模式 | ||
gulp.task('nodemon',function () { | ||
nodemon({ | ||
script: path.join(config.paths.server,'/app.js'), | ||
ext: 'js', | ||
watch: [ | ||
path.join(config.paths.server,'/') | ||
], | ||
env: { 'NODE_ENV': 'development','DEBUG': pkg.name +':*' } | ||
}) | ||
}); | ||
//test模式 | ||
gulp.task('nodemon:test',function () { | ||
//http://localhost:8080 test mode | ||
nodemon({ | ||
script: path.join(config.paths.server,'/app.js'), | ||
ext: 'js json', | ||
watch: [ | ||
path.join(config.paths.server,'/') | ||
], | ||
env: { 'NODE_ENV': 'test' } | ||
}) | ||
}); | ||
//production模式 | ||
gulp.task('nodemon:production',function () { | ||
nodemon({ | ||
script: path.join(config.paths.server,'/app.js'), | ||
ext: 'js json', | ||
watch: [ | ||
path.join(config.paths.server,'/') | ||
], | ||
env: { 'NODE_ENV': 'production' } | ||
}) | ||
}); | ||
|
||
|
||
gulp.task('serve',['nodemon']); | ||
gulp.task('serve:test',['nodemon:test']); | ||
gulp.task('serve:production',['nodemon:production']); | ||
|
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,72 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var gulp = require('gulp'); | ||
var config = require('./config'); | ||
var mocha = require('gulp-mocha'); | ||
var istanbul = require('gulp-istanbul'); | ||
var env = require('gulp-env'); | ||
var gulpSequence = require('gulp-sequence'); | ||
var coveralls = require('gulp-coveralls'); | ||
|
||
//设置环境变量,mocha,istanbul测试必须在test mode | ||
gulp.task('set-env', function () { | ||
env({ | ||
vars: { | ||
'NODE_ENV':'test' | ||
} | ||
}); | ||
}); | ||
//istanbul | ||
gulp.task('pre-test', function () { | ||
return gulp.src([ | ||
path.join(config.paths.server,'/**/*.js'), | ||
path.join('!' + config.paths.server,'/config/**/*.js'), | ||
path.join('!' + config.paths.server,'/auth/**/*.js'), | ||
path.join('!' + config.paths.server,'/{app,routes}.js'), | ||
path.join('!' + config.paths.server,'/model/**/*.js') | ||
]) | ||
.pipe(istanbul()) // Covering files | ||
.pipe(istanbul.hookRequire()) | ||
}); | ||
|
||
gulp.task('test:istanbul',['set-env','pre-test'],function () { | ||
|
||
gulp.src(path.join(config.paths.mocha,'/**/*.test.js'),{read: false}) | ||
.pipe(mocha({ | ||
require: ['should'], | ||
timeout: 5000 | ||
})) | ||
.pipe(istanbul.writeReports({ | ||
dir: path.join(config.paths.istanbul,'/') | ||
})) | ||
.once('error', function () { | ||
process.exit(1); | ||
}) | ||
.once('end', function () { | ||
process.exit(); | ||
}); | ||
|
||
}); | ||
//mocha test | ||
gulp.task('test:mocha',['set-env'],function () { | ||
gulp.src(path.join(config.paths.mocha,'/**/*.test.js'),{read: false}) | ||
.pipe(mocha({ | ||
reporter: 'list', //list,nyan,spec(default),progress | ||
require: ['should'], | ||
timeout: 5000 | ||
})) | ||
.once('error', function () { | ||
process.exit(1); | ||
}) | ||
.once('end', function () { | ||
process.exit(); | ||
}); | ||
}); | ||
//coveralls | ||
gulp.task('coveralls',function () { | ||
gulp.src(path.join(config.paths.istanbul, '/lcov.info')) | ||
.pipe(coveralls()); | ||
}); | ||
|
||
gulp.task('test',gulpSequence('test:istanbul')); |
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,12 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
var fs = require('fs'); | ||
|
||
fs.readdirSync('./gulp').forEach(function (file) { | ||
if((/\.(js|coffee)$/i).test(file)){ | ||
require('./gulp/' + file); | ||
} | ||
}); | ||
|
||
gulp.task('default', ['serve']); |
Empty file.
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,58 @@ | ||
{ | ||
"name": "jackblog-api-koa", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"test": "gulp test", | ||
"start": "gulp serve", | ||
"pm2-start": "pm2 start process.json", | ||
"pm2-restart": "pm2 restart process.json" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^3.1.1", | ||
"bunyan": "^1.5.1", | ||
"ccap": "^0.6.4", | ||
"co": "^4.6.0", | ||
"debug": "^2.2.0", | ||
"koa": "^1.1.2", | ||
"koa-bodyparser": "^2.0.1", | ||
"koa-compose": "^2.3.0", | ||
"koa-compress": "^1.0.8", | ||
"koa-cors": "0.0.16", | ||
"koa-generic-session": "^1.10.1", | ||
"koa-generic-session-mongo": "^0.2.4", | ||
"koa-json": "^1.1.1", | ||
"koa-jwt": "^1.1.1", | ||
"koa-logger": "^1.3.0", | ||
"koa-multer": "0.0.2", | ||
"koa-onerror": "^1.2.1", | ||
"koa-passport": "^1.2.0", | ||
"koa-response-time": "^1.0.2", | ||
"koa-router": "^5.3.0", | ||
"lodash": "^4.0.0", | ||
"markdown-it": "^5.1.0", | ||
"mongoose": "^4.3.6", | ||
"passport-github": "^1.0.0", | ||
"passport-local": "^1.0.0", | ||
"passport-qq": "0.0.3", | ||
"passport-weibo": "^0.1.2", | ||
"qiniu": "^6.1.9" | ||
}, | ||
"devDependencies": { | ||
"del": "^2.2.0", | ||
"gulp": "^3.9.0", | ||
"gulp-coveralls": "^0.1.4", | ||
"gulp-env": "^0.4.0", | ||
"gulp-istanbul": "^0.10.3", | ||
"gulp-mocha": "^2.2.0", | ||
"gulp-nodemon": "^2.0.6", | ||
"gulp-sequence": "^0.4.4", | ||
"gulp-util": "^3.0.7", | ||
"mocha": "^2.3.4", | ||
"nock": "^6.0.1", | ||
"should": "^8.2.0", | ||
"should-promised": "^0.3.1", | ||
"sinon": "^1.17.2", | ||
"supertest": "^1.1.0" | ||
} | ||
} |
Oops, something went wrong.